context-hub/generator

A tool for generating contextual documentation from your codebase.

Fund package maintenance!
Patreon

1.30.0 2025-09-15 06:57 UTC

README

Docs Json schema Telegram License Latest Version

Good morning, LLM

Table of Contents

During development, your codebase constantly evolves. Files are added, modified, and removed. Each time you need to continue working with an LLM, you need to regenerate context to provide updated information about your current codebase state.

CTX helps developers organize contexts and automatically collect information from their codebase into structured documents that can be easily shared with LLM.

For example, a developer describes what context they need:

# context.yaml
documents:
  - description: User Authentication System
    outputPath: auth.md
    sources:
      - type: file
        description: Authentication Controllers
        sourcePaths:
          - src/Auth
        filePattern: "*.php"

      - type: file
        description: Authentication Models
        sourcePaths:
          - src/Models
        filePattern: "*User*.php"

  - description: Another Document
    outputPath: another-document.md
    sources:
      - type: file
        sourcePaths:
          - src/SomeModule

This configuration will gather all PHP files from the src/Auth directory and any PHP files containing "User" in their name from the src/Models directory into a single context file .context/auth.md. This file can then be pasted into a chat session or provided via the built-in MCP server.

How it works

CTX automatically builds structured context documents from:

Process:

  • Collects code from specified sources
  • Filters files through pattern matching, content search, size, or date criteria
  • Applies modifiers (e.g., extracting function signatures without implementation)
  • Organizes content into structured markdown documents
  • Saves context files ready for LLM consumption
  • Optionally serves context through MCP server for direct AI assistant access

Here is a Quickstart guide to get you started with CTX.

The Problem CTX Solves

Without such a tool, you would need to:

  • Manually search for all files that were changed
  • Copy their contents each time
  • Explain the codebase structure repeatedly
  • Spend significant time maintaining context consistency

This repetitive process becomes frustrating and can discourage continued development, as you end up doing the same context-gathering work over and over instead of writing code.

Since CTX describes contexts, this process becomes automated.

Quick Start

Getting started with CTX is straightforward. Follow these simple steps to create your first context file.

1. Install CTX

Download and install the tool using our installation script:

curl -sSL https://raw.githubusercontent.com/context-hub/generator/main/download-latest.sh | sh

This installs the ctx command to your system (typically in /usr/local/bin).

Want more options? See the complete Installation Guide for alternative installation methods.

2. Initialize a Configuration File

Create a new configuration file in your project directory:

ctx init

This generates a context.yaml file with a basic structure to get you started.

Check the Command Reference for all available commands and options.

3. Describe Your Project Structure

Edit the generated context.yaml file to specify what code or content you want to include.

For example:

$schema: 'https://raw.githubusercontent.com/context-hub/generator/refs/heads/main/json-schema.json'

documents:
  - description: "User Authentication System"
    outputPath: "auth-context.md"
    sources:
      - type: file
        description: "Authentication Controllers"
        sourcePaths:
          - src/Auth
        filePattern: "*.php"

      - type: file
        description: "Authentication Models"
        sourcePaths:
          - src/Models
        filePattern: "*User*.php"

This configuration will gather all PHP files from the src/Auth directory and any PHP files containing "User" in their name from the src/Models directory.

Need more advanced configuration?

4. Build the Context

Generate your context file by running:

ctx

CTX will process your configuration and create the specified output file (auth-context.md in our example).

Tip: Configure Logging with -v, -vv, or -vvv for detailed output

5. Share with an LLM

Upload or paste the generated context file to your favorite LLM (like ChatGPT or Claude). Now you can ask specific questions about your codebase, and the LLM will have the necessary context to provide accurate assistance.

Example prompt:

I've shared my authentication system code with you. Can you help me identify potential security vulnerabilities in the user registration process?

Next steps: Check out Development with Context Generator for best practices on integrating context generation into your AI-powered development workflow.

That's it! You're now ready to leverage LLMs with proper context about your codebase.

6. Connect to Claude AI (Optional)

For a more seamless experience, you can connect Context Generator directly to Claude AI using the MCP server:

There is a built-in MCP server that allows you to connect Claude AI directly to your codebase.

Point the MCP client to the Context Generator server:

{
  "mcpServers": {
    "ctx": {
      "command": "ctx",
      "args": [
        "server",
        "-c",
        "/path/to/your/project"
      ]
    }
  }
}

Note: Read more about MCP Server for detailed setup instructions.

Now you can ask Claude questions about your codebase without manually uploading context files!

Full Documentation

For complete documentation, including all available features and configuration options, please visit:

https://docs.ctxgithub.com

License

This project is licensed under the MIT License.