ctxgen
A Rust CLI tool that generates AGENTS.md and CLAUDE.md files from a .context folder.
Overview
ctxgen reads text files from a .context directory (typically at the root of a code repository) and compiles them into markdown files suitable for AI agents. The tool:
- Flattens nested folder structures into a single output file
- Wraps each file's contents in
<file>tags with path information - Supports fold tags to hide content that agents should read from the source
Installation
See latest release for installation steps.
Usage
# Basic usage (uses .context in current directory)
# Specify a custom context directory
# Specify output directory
# Full options
Context Folder Structure
The .context folder can contain text files organized in any folder structure. Here's an example:
.context/
├── guidelines.txt
├── architecture/
│ ├── overview.txt
│ └── patterns.txt
└── api/
└── conventions.txt
Output Format
Each file is wrapped in a <file> tag:
Content of the file...
Content of nested file...
Fold Tags
Use <ctxgen:fold> tags to hide content in the generated markdown. This is useful for controlling context bloat. Agent can read the folded content using filesystem tools:
This content is always visible.
This detailed content will be replaced with a placeholder.
The agent will be instructed to read the original file to see it.
More visible content here.
When compiled, the fold is replaced with a placeholder:
This content is always visible.
[Folded content: 2 lines (lines 3-4). Read 'filename.txt' for full content.]
More visible content here.
Files containing folds will have has_folds="true" added to their <file> tag:
...
Options
| Option | Short | Default | Description |
|---|---|---|---|
--context-dir |
-c |
.context |
Path to the context folder |
--output-dir |
-o |
. |
Output directory for generated files |
License
MIT