A simple Python tool to extract every text-based file from a project and bundle its contents into a single .txt for AI review and analysis.
Repository: https://github.com/odutradev/digest-code Creator & Main Contributor: João Dutra (@odutradev)
- Recursive directory scan for all text-based files
- Respects
.gitignoreplus default ignore patterns (e.g.,__pycache__/,node_modules/) - Filters by common text extensions:
.py,.js,.md,.json,.env, etc. - Interactive prompt to enter project directory
- Aggregated output with
STARTOFFILE <path>/ENDOFFILE <path>blocks - Single output file named after the project root, saved in the
result/folder
# Clone the repository
git clone https://github.com/odutradev/digest-code.git
cd digest-code
# Install dependencies
pip install -r requirements.txtFor development, run the main module:
python -m mainFollow the on-screen prompt to enter your project directory. The script will:
- Recursively scan the specified directory.
- Filter out non-text files and apply ignore rules.
- Wrap each file's content in
STARTOFFILE <relative_path>/ENDOFFILE <relative_path>blocks. - Save the aggregated output to:
result/<project_folder_name>.txt
.
├── main.py # Entry point and input handler
├── .env.example # Example environment file (optional)
├── requirements.txt # Python dependencies
└── src
├── resources
│ ├── digest_handler.py # Core scanning and bundling logic
│ └── gitignore.py # .gitignore parser and default ignore patterns
└── utils
├── config.py # Loads DIRECTORY from .env for development
└── file.py # Helpers for file existence and reading
After running:
python -m mainThe result/ folder will contain:
result/
└── my-project.txt
Inside my-project.txt:
STARTOFFILE src/app.py
<file contents>
ENDOFFILE src/app.py
STARTOFFILE src/utils/helper.py
<file contents>
ENDOFFILE src/utils/helper.py
...
- Extensions: Update the
TEXT_EXTENSIONSset insrc/resources/digest_handler.py - Ignore patterns: Modify default patterns in
src/resources/gitignore.py - Output folder: Change the
result_dirpath inDigestHandler.create_file()
- Fork the repository
- Create a branch:
git checkout -b feature/YourFeature - Commit your changes:
git commit -m "feat: Add YourFeature" - Push to your branch:
git push origin feature/YourFeature - Open a Pull Request
Please read CONTRIBUTING.md for contribution guidelines.
This project is licensed under the MIT License. See LICENSE for details.