CTX
STDIOAI开发上下文管理工具,精确控制代码库内容
AI开发上下文管理工具,精确控制代码库内容
Create LLM-ready contexts in minutes
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 is a context management tool that gives developers full control over what AI sees from their codebase. Instead of letting AI tools guess what's relevant, you define exactly what context to provide - making your AI-assisted development more predictable, secure, and efficient.
It 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.
Current AI coding tools automatically scan your entire codebase, which creates several issues:
You know your code better than any AI. CTX puts you in control:
Download and install the tool using our installation script:
curl -sSL https://raw.githubusercontent.com/context-hub/generator/main/download-latest.sh | sh
powershell -c "& ([ScriptBlock]::Create((irm 'https://raw.githubusercontent.com/context-hub/generator/main/download-latest.ps1'))) -AddToPath"
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.
cd your-project ctx init
This generates a context.yaml file with a basic configuration and shows your project structure, helping you understand
what contexts might be useful.
Check the Command Reference for all available commands and options.
ctx generate
# Quick project overview for new developers documents: - description: "Project Architecture Overview" outputPath: "docs/architecture.md" sources: - type: tree sourcePaths: [ "src" ] maxDepth: 2 - type: file description: "Core interfaces and main classes" sourcePaths: [ "src" ] filePattern: "*Interface.php"
# Context for developing a new feature documents: - description: "User Authentication System" outputPath: "contexts/auth-context.md" sources: - type: file sourcePaths: [ "src/Auth", "src/Models" ] filePattern: "*.php" - type: git_diff description: "Recent auth changes" commit: "last-week"
# Generate API documentation documents: - description: "API Documentation" outputPath: "docs/api.md" sources: - type: file sourcePaths: [ "src/Controllers" ] modifiers: [ "php-signature" ] contains: [ "@Route", "@Api" ]
CTX follows a simple pipeline:
Configuration → Sources → Filters → Modifiers → Output
For a more seamless experience, you can connect CTX to any MCP-compatible client using the built-in MCP server.
# Interactive setup: detect OS and install config for your client ctx mcp:config
This command:
Global Registry Mode (recommended for multiple projects/clients):
{ "mcpServers": { "ctx": { "command": "ctx", "args": [ "server" ] } } }
If you prefer manual setup, point your MCP client to the CTX server:
{ "mcpServers": { "ctx": { "command": "ctx", "args": [ "server", "-c", "/path/to/project" ] } } }
Note: Read more about the MCP server for detailed setup instructions and troubleshooting. Specific config file locations vary by client.
Now you can use your preferred MCP client (including Claude Desktop) to ask questions about your codebase without manually uploading context files.
Define project-specific commands that can be executed through the MCP interface:
tools: - id: run-tests description: "Run project tests with coverage" type: run commands: - cmd: npm args: [ "test", "--coverage" ]
For complete documentation, including all available features and configuration options, please visit:
Join hundreds of developers using CTX for professional AI-assisted coding:
What you'll find in our Discord:
This project is licensed under the MIT License.