Skip to main content

A CLI tool to bundle entire projects into a single AI-friendly context file.

Project description

codefile

PyPI version GitHub stars GitHub forks Downloads

Pack an entire project directory into one structured text file, ready to paste into any LLM context window. Rebuild the original files back from that same file when you need to.


Installation

Requires Python 3.10 or later.

pip install codefile

What it does

When you run codefile on a project directory, it produces a single .txt file that contains:

  • A metadata header (project name, timestamp, file count)
  • An ASCII directory tree
  • Every text file's content, each wrapped between FILE_START and FILE_END markers with a SHA-256 fingerprint
  • Inline markers for binary files, empty files, and symlinks instead of garbage content

Your .gitignore rules are respected. The .git folder is always excluded.


Usage

Pack the current directory:

codefile

Pack a specific directory:

codefile /path/to/project

Write to a custom output path:

codefile /path/to/project -o context.txt

Rebuild a project from a pack file:

codefile --build

Rebuild from a custom-named pack file:

codefile --build -o context.txt

Options

Argument Description
directory Directory to pack. Defaults to the current directory. Ignored when using --build.
-o, --output Pack mode: where to write the output file. Build mode: which pack file to read from.
-b, --build Rebuild project files from a pack file instead of creating one.
-h, --help Show help and exit.

Output format

ROOT_NAME        myproject
CREATED_UTC      2026-03-21T12: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

Binary files, empty files, and symlinks appear as:

FILE_START assets/logo.png d7e2b45f9c33
BINARY_CONTENT
FILE_END assets/logo.png d7e2b45f9c33

.gitignore support

codefile parses your .gitignore properly. The following pattern types all work:

  • Glob patterns: *.log, *.pyc
  • Directory rules: build/, dist/
  • Root-anchored rules: /.env
  • Deep globs: **/*.min.js
  • Negation: !important.log

Ignored directories are pruned immediately during the walk, so large folders like node_modules/ are never descended into.


License

Apache-2.0

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.3.tar.gz (12.4 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.3-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file codefile-26.0.3.tar.gz.

File metadata

  • Download URL: codefile-26.0.3.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codefile-26.0.3.tar.gz
Algorithm Hash digest
SHA256 533ca7cd7558c48c4fb7217a3bdf058a618592525dd91e669c5129d0bafa1456
MD5 9d8d73a5fc353b39703989a76876a0fd
BLAKE2b-256 2bae8f76d8e0c4c6d79d457f1b6a059610c2b571aeb080db80551c6fc36ea6f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for codefile-26.0.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: codefile-26.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codefile-26.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4ad378f54c08d81fa1b04212ae7bd7b32b972d27c43f015e69f8efd59ddd4477
MD5 a25631345695397a757b333eacad21ac
BLAKE2b-256 27fd90076a3bf097c4cd946494db93bfa7b35762a4080c4d6a4e0d857b215eb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for codefile-26.0.3-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