Skip to main content

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 rulesbuild/, dist/
  • Root-anchored rules/.env, /config/secrets.json
  • Deep glob**/*.min.js
  • Negation!important.log re-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

codefile-26.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codefile-26.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

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

Hashes for codefile-26.0.1.tar.gz
Algorithm Hash digest
SHA256 59d0d36ebbaeffd1ca70fec20d3d68e41a22a0b837c9bab33bf3662944c9283c
MD5 745c6076af7f05812f32b9a2257b03d8
BLAKE2b-256 295f152a3979d962664567a8cf82bc3a72294adef13c0339542fbcbced874b07

See more details on using hashes here.

Provenance

The following attestation bundles were made for codefile-26.0.1.tar.gz:

Publisher: python-publish.yml on sapirrior/codefile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for codefile-26.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcc9e07ea71a81cb638c09b30c952bb7aa8d926b8e8a7973b2d83feca01b093f
MD5 653534d41a16d8ce004dc46008733f22
BLAKE2b-256 b6ecaf8b00854e095324a86787b072a67645e5f50dbef9fb91d5071331a16162

See more details on using hashes here.

Provenance

The following attestation bundles were made for codefile-26.0.1-py3-none-any.whl:

Publisher: python-publish.yml on sapirrior/codefile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page