A utility tool designed to help developers provide code context to AI chat assistants (like ChatGPT, Claude, etc.) by combining multiple project files into a single, well-formatted text file.
When seeking help with coding questions, providing proper context about your codebase is crucial for getting accurate assistance. However, copying and pasting multiple files or explaining complex directory structures can be tedious and error-prone. concat_proj
solves this by:
- Automatically combining multiple files from your project into a single file
- Preserving directory structure information
- Making it easy to share your code context with AI assistants
- Download
concat_proj.py
to your local machine - Ensure you have Python 3.6 or higher installed
- No additional dependencies required!
You can use the script in two ways:
- Copy
concat_proj.py
to your project directory - Run:
python concat_proj.py
- Keep
concat_proj.py
in a convenient location (e.g., your tools or scripts directory) - Use the
--root
option to specify your project path:
# Windows example
python C:/Users/YourName/Tools/concat_proj.py --root C:/Projects/MyProject
# Unix/Mac example
python ~/tools/concat_proj.py --root ~/projects/my_project
Pro Tip: You can create an alias or add the script to your PATH for easier access:
# Unix/Mac alias example (add to .bashrc or .zshrc)
alias concat_proj='python ~/tools/concat_proj.py'
# Then use it like this:
concat_proj --root ~/projects/my_project
# Script is in current directory, project is elsewhere
python concat_proj.py --root ../other_project
# Script is in tools directory, analyzing current directory
python ~/tools/concat_proj.py --root .
# Script is in tools directory, analyzing specific project
python ~/tools/concat_proj.py --root ~/projects/my_project
# Include specific files from a different project
python ~/tools/concat_proj.py --root ~/projects/my_project --include "**.py" "**.java"
# Specify output location in a different directory
python ~/tools/concat_proj.py --root ~/projects/my_project --output ~/Desktop/context.txt
# Only Python files
python concat_proj.py --include "**.py"
# Python and Java files
python concat_proj.py --include "**.py" "**.java"
# Files in specific directory
python concat_proj.py --include "**/models/**.py"
python concat_proj.py --output my_context.txt
python concat_proj.py --list-extensions
# Exclude directory structure visualization
python concat_proj.py --no-structure
# Add custom ignore patterns
python concat_proj.py --ignore "**/tests/*" "**/*.log"
# Specify different project directory
python concat_proj.py --root /path/to/project
-
Be Selective: Only include relevant files to your question. Use the
--include
option to select specific files or directories.python concat_proj.py --include "**/relevant_module/**.py"
-
Provide Context: When pasting into AI chat, start with a clear description of your question or issue, then mention you're providing code context. Example:
I'm having trouble with the authentication system in my Flask application. Here's my current code structure and implementation: [paste concat_proj output here]
-
Check File Size: If the combined output is very large, consider using
--include
to focus on the most relevant files for your question. -
Formatting: The output is already formatted to be readable in AI chat interfaces. Each file is clearly marked with separators and its path in the project.
-
Debugging Complex Issues:
python concat_proj.py --include "**/relevant_module/**.py" "**/tests/test_relevant.py"
-
Architecture Questions:
python concat_proj.py --include "**.py" # Include all Python files to show project structure
-
Specific Feature Implementation:
python concat_proj.py --include "**/feature_name/**"
By default, the tool ignores:
- Hidden files and directories (starting with .)
- Build directories (dist, build, target, etc.)
- Compiled files (.pyc, .class, .o, etc.)
- Package management directories (node_modules, pycache, etc.)
- Binary and compressed files (.exe, .dll, .zip, etc.)
- Most virtual environment folders (can be named anything, so ignores common naming patterns)
Feel free to submit issues and enhancement requests!
This project is open source and available under the MIT License.