A CLI tool to bundle entire projects into a single AI-friendly context file.
Project description
codefile
A CLI tool that bundles an entire project directory into a single, structured text file — purpose-built for feeding codebases to LLMs like Claude, ChatGPT, Gemini, and Grok.
How It Works
codefile walks your project root, respects your .gitignore, and writes every relevant file into one output file with a clear format: a metadata header, an ASCII directory tree, and each file's content wrapped in FILE_START / FILE_END sentinels with a SHA-256 fingerprint. Binary files, symlinks, and empty files are represented with inline markers instead of garbage content.
Installation
pip install codefile
Requires Python 3.10 or later.
Usage
# Pack the current directory
codefile
# Pack a specific directory
codefile /path/to/project
# Write output to a custom path
codefile /path/to/project -o context.txt
Options
| Argument | Description |
|---|---|
directory |
Root directory to pack. Defaults to the current directory. |
-o, --output |
Output file path. Defaults to <directory>/CodeFile.txt. |
Output Format
ROOT_NAME myproject
CREATED_UTC 2025-08-01T12:00:00Z
TOTAL_SOURCE_MB 0.42
FILE_COUNT 18
START_STRUCTURE
myproject/
|-- src/
| |-- main.py
| \-- utils.py
\-- README.md
END_STRUCTURE
FILE_START src/main.py a3f9c12b8e01
def main():
print("hello")
FILE_END src/main.py a3f9c12b8e01
FILE_START assets/logo.png d7e2b45f9c33
BINARY_CONTENT
FILE_END assets/logo.png d7e2b45f9c33
Special Content Markers
| Marker | Meaning |
|---|---|
BINARY_CONTENT |
File is binary (image, compiled object, etc.) |
EMPTY_CONTENT |
File exists but has zero bytes |
SYMLINK_CONTENT |
File is a symbolic link |
.gitignore Support
codefile implements a proper .gitignore parser, not just glob matching. The following pattern types are all handled correctly:
- Glob patterns —
*.log,*.pyc - Directory-only rules —
build/,dist/ - Root-anchored rules —
/.env,/config/secrets.json - Deep glob —
**/*.min.js - Negation —
!important.logre-includes a previously excluded file
Directories matched by an ignore rule are pruned immediately during the walk — node_modules/ or build/ with thousands of files are never descended into.
Project Structure (src layout)
your-project/
├── src/
│ ├── codefile.py ← main module
│ └── config/
│ └── version.txt ← single source of truth for version
├── pyproject.toml
├── README.md
└── LICENSE
The version is read directly from src/config/version.txt at build time. To release a new version, update that file.
License
MIT License — see LICENSE for details.
Author
Nolan Stark
Project details
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 codefile-26.0.1.tar.gz.
File metadata
- Download URL: codefile-26.0.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59d0d36ebbaeffd1ca70fec20d3d68e41a22a0b837c9bab33bf3662944c9283c
|
|
| MD5 |
745c6076af7f05812f32b9a2257b03d8
|
|
| BLAKE2b-256 |
295f152a3979d962664567a8cf82bc3a72294adef13c0339542fbcbced874b07
|
Provenance
The following attestation bundles were made for codefile-26.0.1.tar.gz:
Publisher:
python-publish.yml on sapirrior/codefile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codefile-26.0.1.tar.gz -
Subject digest:
59d0d36ebbaeffd1ca70fec20d3d68e41a22a0b837c9bab33bf3662944c9283c - Sigstore transparency entry: 1109287188
- Sigstore integration time:
-
Permalink:
sapirrior/codefile@0675d76555f241a284e14f4ef7d5fbf7cfb893b8 -
Branch / Tag:
refs/tags/26.0.1 - Owner: https://github.com/sapirrior
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0675d76555f241a284e14f4ef7d5fbf7cfb893b8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file codefile-26.0.1-py3-none-any.whl.
File metadata
- Download URL: codefile-26.0.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcc9e07ea71a81cb638c09b30c952bb7aa8d926b8e8a7973b2d83feca01b093f
|
|
| MD5 |
653534d41a16d8ce004dc46008733f22
|
|
| BLAKE2b-256 |
b6ecaf8b00854e095324a86787b072a67645e5f50dbef9fb91d5071331a16162
|
Provenance
The following attestation bundles were made for codefile-26.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on sapirrior/codefile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codefile-26.0.1-py3-none-any.whl -
Subject digest:
bcc9e07ea71a81cb638c09b30c952bb7aa8d926b8e8a7973b2d83feca01b093f - Sigstore transparency entry: 1109287190
- Sigstore integration time:
-
Permalink:
sapirrior/codefile@0675d76555f241a284e14f4ef7d5fbf7cfb893b8 -
Branch / Tag:
refs/tags/26.0.1 - Owner: https://github.com/sapirrior
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0675d76555f241a284e14f4ef7d5fbf7cfb893b8 -
Trigger Event:
release
-
Statement type: