CLI tool to generate codebase context for LLMs
Project description
CTX - Codebase Context Generator 🔍
A CLI tool to generate consolidated codebase context for LLMs with intelligent file handling and structure visualization.
Features ✨
- 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
Installation 📦
pip install git+https://github.com/Aditya-en/ctx-cli.git
Prerequisites
- Python 3.6+
- Git (for installation from repository)
Basic Usage 🚀
Process the current directory:
ctx
Target specific files/directories:
ctx src/ utils.py README.md
Custom ignores and no tree:
ctx --ignore "*.log" --ignore tmp/ --no-tree
Advanced Options ⚙️
| 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 |
Example Output 📄
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
Token Estimation and File Handling
- 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
Dependencies
- gitignore-parser
- pathspec
- pyperclip (optional, for clipboard feature)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctx_codebase_helper-0.4.0-py3-none-any.whl.
File metadata
- Download URL: ctx_codebase_helper-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96ea80fd1cc70b9f35c231c819a7d64b67d8f58ef9cad91927e10c7cd2f61573
|
|
| MD5 |
18041be554dd2c8b9ec27c0ad3ba49e0
|
|
| BLAKE2b-256 |
3e2078c7678d558043a88a29a4f4f3108de1c5c5f7d40213117b35bb0d43f8fc
|