Getting started¶
Requirements¶
- Node.js 20 or newer
CLI¶
npx ctxpack # whole repo → stdout (markdown)
npx ctxpack . --out context.md # write to a file
npx ctxpack . --budget 100000 # cap estimated tokens
npx ctxpack . --format xml --out context.xml # XML output
npx ctxpack src --ignore "*.snap" # extra ignores (repeatable)
npx ctxpack . --no-redact # keep secrets (not recommended)
When writing to a file, a summary is printed to stderr: files included, estimated tokens, redactions, and skipped count.
Typical workflows¶
- Ask a model about your repo:
npx ctxpack --budget 120000 --out ctx.md, then attachctx.md. - RAG ingestion: emit XML (
--format xml) with a token budget per document and chunk downstream. - Code review prep: pack a subdirectory (
npx ctxpack src/feature) to focus the model.