Send all your project code to GPT and enjoy!
CodeCollector is a command-line tool that helps developers gather and consolidate code from various files and directories into a single text file. This is particularly useful for passing entire projects to GPT models for code analysis, refactoring, or documentation.
- Recursively collect code from specified directories and files.
- Build a project structure.
- Filter files by specified formats.
- Ignore specific files and directories.
- Output all collected code into a single text file.
To use CodeCollector, you need to have Python.
git clone https://github.com/werserk/CodeCollector.git
cd CodeCollector
poetry install
- Create a virtual environment (optional but recommended):
python3 -m venv venv && \
source venv/bin/activate # On Windows use `venv\Scripts\activate`
- Install dependencies:
pip install -r requirements.txt
You can run CodeCollector using Poetry with various options to customize the behavior of the tool.
To collect code from specific directories and files:
poetry run python code_collector.py /path/to/your_directory
--formats
or-f
: Specify file formats to include. By default, all formats are collected.--ignore-paths
or-i
: Specify paths to ignore. By default, only hidden files are ignored.--output
or-o
: Specify the output file. By default, the output file iscollected_code.txt
.
To collect code from multiple directories, including only Python and JavaScript files, ignoring specific files and directories, and outputting to a custom file:
poetry run python code_collector.py \
my_directory another_directory specific_file.py \
-f .py \
-f .js \
-i ignore_this.py \
-i ignore_this_directory \
-o output.txt
Project Structure:
my_directory/
├── file1.py
└── file2.js
another_directory/
└── subdir/
└── file3.py
specific_file.py
Code Files:
================
Filepath: my_directory/file1.py
<code of file1.py>
================
Filepath: my_directory/file2.js
<code of file2.js>
================
Filepath: another_directory/subdir/file3.py
<code of file3.py>
================
Filepath: specific_file.py
<code of specific_file.py>
================
This project is licensed under the MIT license.