A CLI tool to generate consolidated codebase context for LLMs with intelligent file handling and structure visualization.
- Smart Ignore System 🔒
- Auto-detects .gitignore rules + custom ignores via --ignore
- Ignores .git folder by default to reduce clutter
- File Tree Visualization 🌳
- Built-in directory structure display (disable with --no-tree)
- Flexible Targeting 🎯
- Specify files/directories or process the entire project
- LLM-Optimized 🤖
- Clean output format with file boundaries and metadata
- Cross-Platform 💻
- Works on Windows, macOS, and Linux
pip install git+https://github.com/Aditya-en/ctx-cli.git- Python 3.6+
- Git (for installation from repository)
ctxctx src/ utils.py README.mdctx --ignore "*.log" --ignore tmp/ --no-tree| Option | Description | Example |
|---|---|---|
| --max-tokens | Set maximum context size in tokens | --max-tokens 100000 |
| --auto-skip | Automatically skip large files | --auto-skip |
| --ignore | Add custom ignore pattern (glob format) | --ignore "*.csv" |
| --no-tree | Disable file tree visualization | --no-tree |
| --tree | Show ONLY the file tree structure | --tree |
| --output, -f | Save output to file | --output context.txt |
| -c, --clipboard | Copy output to clipboard | --clipboard |
| --version, -v | Show version information | --version |
The tool generates a consolidated view of your project, including:
- A hierarchical file tree structure
- Full contents of processed files
- Warning messages for large files
- Optional clipboard and file output
- Uses a conservative token estimation method
- Provides interactive prompts for large files
- Configurable maximum token limit (default: 128,000 tokens)
- Supports custom ignore patterns and .gitignore rules
- gitignore-parser
- pathspec
- pyperclip (optional, for clipboard feature)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.