Skip to main content

ctxstash

Pack a codebase into one LLM-ready Markdown file — with a file tree and a token estimate. Zero dependencies, no server, no telemetry.

You're feeding code to ChatGPT / Claude / Cursor and you keep doing the same dance: open file, copy, paste, label it, repeat — then guess whether it'll blow the context window. ctxstash does it in one command: walk a directory, skip the junk (.venv, __pycache__, lockfiles, binaries), and emit a single tidy Markdown document with every file fenced and language-tagged, prefixed by a tree overview and an approximate token count.

ctxstash src > context.md
✓ packed 23 files · 142.3 KB · ~38,210 tokens

This is the Python build. There's a matching, behavior-identical Node version: npx ctxstash.

Install

pip install ctxstash

Requires Python ≥ 3.8. No dependencies. (You can also run it without installing the script: python -m ctxstash .)

Usage

ctxstash [paths...] [options]
ctxstash .                          # pack the current dir to stdout
ctxstash src tests > context.md     # pack two dirs, redirect to a file
ctxstash . -o context.md            # ...or write the file directly
ctxstash . -i "*.py,*.pyi"          # only Python
ctxstash . -e "*_test.py"           # drop tests
ctxstash . --estimate               # just tell me the token cost
ctxstash src --tree                 # just the file tree

Options

Option Description
-o, --out <file> Write to a file instead of stdout
-i, --include <globs> Only include matching files (comma-separated, e.g. "*.py,*.pyi")
-e, --exclude <globs> Exclude matching files (comma-separated)
--tree Print only the file tree (no contents)
--no-tree Omit the file-tree overview from the packed output
--estimate Print only stats (files, size, ~tokens) — pack nothing
--max-size <size> Skip files larger than this (e.g. 256kb, 1mb; default: no limit)
--no-default-ignore Don't auto-skip node_modules / .git / dist / lockfiles / etc.
--no-color Disable colored stderr
-h, --help · -v, --version

Globs support * (within a path segment), ** (across segments), and ?. A slash-less pattern like *.py matches at any depth.

What you get

# Repository context

> Packed by ctxstash — 3 files, 4.1 KB, ~1,040 tokens (estimate).

## File tree

​```
src/
  core.py
  cli.py
README.md
​```

## Files

### src/core.py

​```python
...file contents...
​```

The summary line always goes to stderr, so ctxstash > context.md keeps the file clean while you still see the count in your terminal.

Notes & limits

  • Binary files are skipped automatically (NUL-byte / control-byte sniff), so images and compiled artifacts never end up in your context.
  • Token counts are an estimate (~4 characters per token, OpenAI's rule of thumb) — tokenizer-agnostic and good enough for "will this fit?", not exact billing. For precise counts, run the output through a real tokenizer.
  • Fences are collision-safe: if a file contains a ``` run, ctxstash wraps it in a longer fence so the Markdown stays valid.
  • Symlinks are not followed (avoids loops).

License

MIT

Metadata

Release files for ctxstash 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ctxstash 0.1.0
File Size Uploaded Provenance Actions
ctxstash-0.1.0.tar.gz 14.1 kB Without provenance Details for ctxstash-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ctxstash 0.1.0
File Interpreter ABI Platform Actions
ctxstash-0.1.0-py3-none-any.whl Python 3 none any Details for ctxstash-0.1.0-py3-none-any.whl

Total release size: 26.3 kB

Release files / ctxstash-0.1.0.tar.gz

Download URL ctxstash-0.1.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0e90af08c686903fd686aa84e3d399c98a733275ad2e5ce0b2505d41d0beb325
BLAKE2b-256 checksum
How to use checksums
1299e9b7c2c57c9c59a23681751f6b07cb8c27d92123fd8ccb982bbf4771162d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / ctxstash-0.1.0-py3-none-any.whl

Download URL ctxstash-0.1.0-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab26dde0704e81dce032e78963aa6b1aabb01b294953a894036115b6f4ad6a9f
BLAKE2b-256 checksum
How to use checksums
cb54d52ac4ce1fde224be73576769e6939795028eeb9d97bad888a6532b0e05c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for ctxstash 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page