A CLI tool to prepare code as context for AI assistants and other purposes.
Project description
Contextify CLI 💬🌲📝
Contextify (contextify-cli) is a command-line tool designed to scan your codebase, understand its structure, and consolidate relevant file contents into a single, clean Markdown document. This output is perfect for providing context to AI assistants (like ChatGPT, Claude, Gemini, etc.), for documentation purposes, or for quickly getting an overview of a project.
Say goodbye to manually copying and pasting files or struggling with token limits! 👋
🤔 Why Contextify?
When working with Large Language Models (LLMs) or AI coding assistants, providing sufficient and well-structured context is key to getting high-quality responses. Manually gathering this context from a large project can be:
- Time-consuming: Opening, copying, and pasting multiple files.
- Error-prone: Easy to miss important files or include irrelevant ones.
- Repetitive: You often need to do this for different queries or updates.
- Limited by input size: Concatenating too much code can exceed token limits.
Contextify automates this process, allowing you to quickly generate a concise and relevant Markdown representation of your project, tailored to your needs.
✨ Key Features
- 🌲 Directory Tree Generation: Includes an optional, customizable directory tree structure in the Markdown output.
- 📄 File Content Aggregation: Reads specified file types and includes their content in formatted Markdown code blocks.
- 🎯 Flexible Filtering:
- Specify which file extensions to include (e.g.,
.py,.js,.md). - Define maximum scan depth for directories.
- Exclude specific directories (e.g.,
node_modules,.git,__pycache__). - Exclude specific files by pattern (e.g.,
*.log,temp.*).
- Specify which file extensions to include (e.g.,
- ✂️ Content Truncation: Set a maximum character limit per file to keep the context concise and manage token counts.
- 🏷️ Language Tagging: Automatically adds language tags to Markdown code blocks based on file extensions.
- ⚙️ Command-Line Interface: Easy to use directly from your terminal.
- 📝 Output to File or Console: Print to standard output or save directly to a
.mdfile.
🚀 Installation
You can install contextify-cli directly from PyPI using pip:
pip install contextify-cli
Make sure you have Python 3.9 or higher installed.
🛠️ Usage
The basic command structure is:
contextify [OPTIONS] <DIRECTORY_PATH>
Arguments:
DIRECTORY_PATH: (Required) The path to the project directory you want to process.
Common Options:
-o, --output <FILE_PATH>: Save the Markdown output to the specified file. If not provided, output is printed to the console.--no-tree: Do not include the directory tree structure.-ext, --extensions <EXT1,EXT2,...>: Comma-separated list of file extensions to include (e.g.,py,js,md). Defaults topy. UseALLto include all non-ignored files.-depth, --max-depth <N>: Maximum depth to scan directories for both the tree and files.-1for unlimited (default),0for root directory only.-mfc, --max-file-chars <N>: Maximum characters per file to include.-1for unlimited (default). Content exceeding this limit will be truncated.--ignore-dir <DIR_NAME>: Specify a directory name to ignore. Can be used multiple times.--ignore-file <PATTERN>: Specify a file name pattern (fnmatch style, e.g.,*.log,temp.*) to ignore. Can be used multiple times.--version: Show the version ofcontextify-cliand exit.--help: Show the help message and exit.
Examples:
-
Process a Python project in the current directory and print to console:
contextify . -
Process a JavaScript project, include only
.jsand.jsonfiles, and save toproject_context.md:contextify ./my-js-project -ext js,json -o project_context.md
-
Process a project, limit scan depth to 2, and exclude the
distdirectory:contextify ./my-deep-project -depth 2 --ignore-dir dist
-
Process all file types, exclude
.logfiles, and limit file content to 5000 characters each:contextify ./another-project -ext ALL --ignore-file "*.log" -mfc 5000
-
Generate context without the directory tree:
contextify ./my-project --no-tree -o context_no_tree.md
⚙️ Configuration Defaults
Contextify comes with sensible defaults for ignored directories and files to minimize noise in your context.
- Default Ignored Directories:
__pycache__,.git,.venv,venv,node_modules,build,dist,target,.idea,.vscode,docs,tests,test,.DS_Store,Thumbs.db. - Default Ignored File Patterns: Includes common temporary, compiled, log, and OS-specific files (e.g.,
*.pyc,*.log,*.swp,*.o,*.class).
You can always override or add to these with the --ignore-dir and --ignore-file options.
🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.
📜 License
This project is licensed under the Apache Software 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 Distribution
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 contextify_cli-0.1.1.tar.gz.
File metadata
- Download URL: contextify_cli-0.1.1.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11f23b18329a6c3c526be82cca5f019972b60c7d6619ffd3367fc4907c8f003a
|
|
| MD5 |
e7029ffe882baf515173c981309f46d2
|
|
| BLAKE2b-256 |
c4f14f26d866cd9772ec2d875a9a8ab447ae8cb7fbcd4cd1ec599079acb7aa5b
|
File details
Details for the file contextify_cli-0.1.1-py3-none-any.whl.
File metadata
- Download URL: contextify_cli-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c4b606805ad0595cbb78a8c6beb69503b031cf777f01b085ee7948a068c9a6c
|
|
| MD5 |
c76b180c9b71dcfd98c18c89ec6c7a81
|
|
| BLAKE2b-256 |
1bd71a2e98b7feb812c19286300e4ac27f2948d48df61e16e0d184edccbb0fb5
|