|
1 | | -# CTX: Context as Code (CaC) tool with MCP server inside. |
2 | | - |
3 | | -### The missing link between your codebase and your LLM. |
| 1 | +# CTX: The missing link between your codebase and your LLM. |
4 | 2 |
|
5 | 3 |  |
6 | 4 |
|
7 | | -## What is **CTX**? |
8 | | - |
9 | | -**CTX** is a tool made to solve a big problem when chatting with LLMs like ChatGPT or Claude: **giving them enough |
10 | | -context about your project**. |
11 | | - |
12 | | -> There is an article about **CTX** |
13 | | -> on [Medium](https://medium.com/@butschster/context-not-prompts-2-0-the-evolution-9c4a84214784) that explains the |
14 | | -> motivation behind the project and the problem it solves. |
| 5 | +**CTX** is a tool that solves the context management gap when working with LLMs like ChatGPT or Claude. It helps |
| 6 | +developers organize and automatically collect information from their codebase into structured documents that can be |
| 7 | +easily shared with AI assistants. |
15 | 8 |
|
16 | | -Instead of manually copying or explaining your entire codebase each time, ctx automatically builds neat, organized |
17 | | -context files from: |
| 9 | +**The tool doesn't work instead of developer - it's a tool where developers can describe their contexts and use them |
| 10 | +to provide information to LLMs.** |
18 | 11 |
|
19 | | -- Code files, |
20 | | -- GitHub repositories, |
21 | | -- Git commit changes and diffs |
22 | | -- Web pages (URLs) with CSS selectors, |
23 | | -- and plain text. |
| 12 | +For example, a developer describes what context they need: |
24 | 13 |
|
25 | | -It was created to solve a common problem: efficiently providing AI language models like ChatGPT, Claude with necessary |
26 | | -context about your codebase. |
| 14 | +```yaml |
| 15 | +# context.yaml |
| 16 | +documents: |
| 17 | + - description: "User Authentication System" |
| 18 | + outputPath: "auth-context.md" |
| 19 | + sources: |
| 20 | + - type: file |
| 21 | + description: "Authentication Controllers" |
| 22 | + sourcePaths: |
| 23 | + - src/Auth |
| 24 | + filePattern: "*.php" |
27 | 25 |
|
28 | | -## CTX, CaC, and CDD: A Powerful Combination |
| 26 | + - type: file |
| 27 | + description: "Authentication Models" |
| 28 | + sourcePaths: |
| 29 | + - src/Models |
| 30 | + filePattern: "*User*.php" |
| 31 | +``` |
29 | 32 |
|
30 | | -**CTX** is the foundational tool that enables two powerful development approaches: |
| 33 | +This configuration will gather all PHP files from the `src/Auth` directory and any PHP files containing "**User**" in |
| 34 | +their name from the `src/Models` directory into a single context file `.context/auth.md`. This file can then be pasted |
| 35 | +into a chat session or provided via the built-in [MCP server](./mcp/index.md). |
31 | 36 |
|
32 | | -- **CaC (Context as Code)**: An approach where code, documentation, and structure serve as explicit context for both |
33 | | - humans and AI. With CaC, your codebase becomes self-documenting through meaningful comments, examples, and |
34 | | - well-structured organization. CTX automatically extracts and formats this context, making it consumable by LLMs. |
| 37 | +### How it works |
35 | 38 |
|
36 | | -- **CDD (Claude/Context Driven Development)**: A methodology where AI assistants like Claude help generate and review |
37 | | - code based on well-structured context, with humans providing guidance and final approval. CTX facilitates CDD by |
38 | | - automating the context gathering process and maintaining a constant bridge between your code and the AI assistant. |
| 39 | +**CTX automatically builds structured context documents from:** |
39 | 40 |
|
40 | | -This virtuous cycle means better context leads to better AI assistance, which leads to better code, which in turn |
41 | | -provides even better context. |
| 41 | +- [Code files and directories](./sources/file-source.md) |
| 42 | +- [GitHub repositories](./sources/github-source.md) |
| 43 | +- [Git commit changes and diffs](./sources/git-diff-source.md) |
| 44 | +- W[eb pages (URLs) with CSS selectors](./sources/url-source.md) |
| 45 | +- Plain text |
| 46 | +- and more! |
42 | 47 |
|
43 | | -> **Read more about the principles of CaC and CDD in the [Understanding CaC, CDD](/cdd.md) section.** |
| 48 | +**Process:** |
44 | 49 |
|
45 | | -## Why You Need This |
| 50 | +- Collects code from specified sources |
| 51 | +- Filters files through pattern matching, content search, size, or date criteria |
| 52 | +- Applies modifiers (e.g., extracting function signatures without implementation) |
| 53 | +- Organizes content into structured markdown documents |
| 54 | +- Saves context files ready for LLM consumption |
| 55 | +- Optionally serves context through MCP server for direct AI assistant access |
46 | 56 |
|
47 | | -When working with AI-powered development tools context is everything. |
48 | | - |
49 | | -- **Code Refactoring Assistance**: Want AI help refactoring a complex class? **CTX** builds a properly |
50 | | - formatted document containing all relevant code files. |
| 57 | +> Here is a [Quickstart guide](./quick-start.md) to get you started with CTX. |
51 | 58 |
|
52 | | -- **Multiple Iteration Development**: Working through several iterations with an AI helper requires constantly updating |
53 | | - the context. **CTX** automates this process. |
| 59 | +### The Problem CTX Solves |
54 | 60 |
|
55 | | -- **Documentation Generation:** Transform your codebase into comprehensive documentation by combining source code with |
56 | | - custom explanations. Use AI to generate user guides, API references, or developer documentation based on your actual |
57 | | - code. |
| 61 | +**Without such a tool, you would need to:** |
58 | 62 |
|
59 | | -- **Reusable Prompt Libraries:** Create, share, and import collections of specialized prompts for common development |
60 | | - tasks. Build once, use everywhere, and leverage the community's expertise without reinventing the wheel. |
| 63 | +- Manually search for all files that were changed |
| 64 | +- Copy their contents each time |
| 65 | +- Explain the codebase structure repeatedly |
| 66 | +- Spend significant time maintaining context consistency |
61 | 67 |
|
62 | | -- **Standardized Team Workflows:** Establish consistent AI interaction patterns across your team by sharing prompt |
63 | | - libraries that encode best practices and domain expertise for your specific projects. |
| 68 | +This repetitive process becomes frustrating and can discourage continued development, as you end up doing the same |
| 69 | +context-gathering work over and over instead of writing code. |
64 | 70 |
|
65 | | -- **Seamless AI Integration**: With MCP support, [connect](/mcp-server) Claude AI directly to your codebase, allowing |
66 | | - for real-time, context-aware assistance without manual context sharing. |
| 71 | +Since CTX describes contexts, this process becomes automated. |
67 | 72 |
|
68 | | -- **Automated Tool Execution**: Define [custom tools](/mcp/tools) that can be triggered through the MCP server, enabling |
69 | | - automated code checks, builds, and other development workflows directly from your AI assistant. |
| 73 | +## Use Cases |
70 | 74 |
|
71 | | -## How it works |
| 75 | +When working with AI-powered development tools context is everything. |
72 | 76 |
|
73 | | -1. Gathers code from files, directories, GitHub repositories, web pages, or custom text. |
74 | | -2. Targets specific files through pattern matching, content search, size, or date filters |
75 | | -3. Applies optional modifiers (like extracting PHP signatures without implementation details) |
76 | | -4. Organizes content into well-structured markdown documents |
77 | | -5. Provides pre-defined prompts for common tasks that can be imported, shared, and reused |
78 | | -6. Saves context files ready to be shared with LLMs |
79 | | -7. Optionally serves context through an MCP server, allowing AI assistants like Claude to directly access project |
80 | | - information |
| 77 | +- **Code Development**: Maintain up-to-date context for iterative development sessions with AI assistants. When your |
| 78 | + codebase changes, regenerate context documents to continue working with current code state. |
| 79 | +- **Code Refactoring**: Provide AI with complete context about classes, functions, and their dependencies for |
| 80 | + refactoring assistance. |
| 81 | +- **Documentation**: Generate documentation by combining source code with explanations, using AI to create guides and |
| 82 | + references based on actual code. |
| 83 | +- **Team Workflows**: Share context configurations across team members to maintain consistent AI interaction patterns. |
| 84 | +- **MCP Integration**: Connect Claude AI directly to your codebase for real-time, context-aware assistance without |
| 85 | + manual context sharing. |
0 commit comments