Understanding CaC, CDD
Context as Code (CaC)
Context as Code (CaC) is an approach where code, documentation, and structure serve as explicit context for both humans and AI systems, making the codebase more comprehensible and maintainable.
Key principles of CaC:
Structured Documentation: Code is organized with meaningful comments, examples, and well-structured organization to make it a rich source of context.
Contextual Awareness: The code and its documentation together provide sufficient context for understanding the system's architecture and design decisions.
Focus on Comprehensibility: Documentation isn't separate from code but integrated as part of the codebase, ensuring it remains up-to-date.
For the CaC approach (Context as Code, describing context with code) to work well, signatures alone aren't always enough. And that's how comments appear in your code. Not those that just repeat method or class names, but meaningful ones with examples.
Claude (Context) Driven Development (CDD)
CDD is a development methodology where an AI assistant like Claude helps generate and review code based on well-structured context, with humans providing guidance and final approval.
CDD workflow:
- Provide relevant context to the LLM
- Define requirements or feature requests
- Collaborate with the LLM to refine the approach
- Generate code with the LLM
- Review and refine the code
- Add tests, documentation and finalize
Benefits:
- Automatic comment updates for changed functions
- Excellent unit test generation
- Reduced procrastination by offloading routine tasks
- Developer focus on more interesting parts of code
CTX: The Bridge Between CaC and CDD
CTX is the tool that connects the principles of CaC with the CDD workflow. It automates the process of gathering and structuring context from code to feed into LLMs like Claude.
How CTX supports CaC and CDD:
Context Generation: CTX automatically builds organized context files from various sources (code files, GitHub repositories, git diffs, web pages, etc.).
Structured Documentation: As described in the documents, CTX creates well-formatted markdown documents containing all relevant context about the codebase.
Modifiers for Optimization: CTX includes modifiers that transform source content to make it more useful for LLM contexts, supporting the CaC principle of making code self-documenting.
MCP Server Integration: CTX provides a built-in MCP (Model Control Protocol) server that allows Claude to directly access project information, enabling a more seamless CDD workflow.
The Connection Between These Concepts:
The quality of LLM-based tools depends on the quality of context. And you can improve context quality using LLMs.
- Well-structured code with good documentation (CaC) provides better context for LLMs
- LLMs with good context can write better code and documentation (CDD)
- This improved code and documentation further enhances the context (CaC)
- CTX automates the process of collecting and formatting this context
Practical Implementation with CTX
CTX facilitates CaC and CDD with specific features:
Document Generation: CTX creates markdown documents with compiled content from various sources, organizing related code and context in a single file.
Source Management: CTX can pull from files, GitHub repositories, git diffs, and other sources to provide comprehensive context.
Modifiers: CTX transforms content to make it more useful, including extracting signatures, filtering content, and generating documentation.
Prompts: CTX allows defining reusable prompts for common tasks, enhancing the CDD workflow.
Tools Integration: Custom tools can be executed directly by the LLM during conversations, enabling more sophisticated interactions.
Benefits for Development
The combined approach of CaC, CDD, and CTX yields significant benefits:
Better Code Structure: As mentioned in the article, "Programming with contexts forces you to structure code properly" - a positive side effect of preparing code for AI interaction.
Maintained Documentation: The CDD process keeps documentation current as Claude updates comments for functions it changes.
Faster Development: The article mentions completing features in about 2 hours that would have taken longer manually.
Reduced Cognitive Load: The author notes they "can parallel CDD with watching conference talks" because writing prompts doesn't require getting into a flow state.
Focus on Interesting Problems: By giving routine tasks to LLMs, developers can focus on the most interesting and challenging aspects of development.
This integrated approach represents a new paradigm in software development where human creativity and AI capabilities complement each other, with tools like CTX serving as the crucial bridge between well-structured code and AI assistance.