Skip to content

Recipes

Pack for a chat, within a budget

npx ctxpack . --budget 120000 --out context.md
# attach context.md to your model chat

Focus on a subdirectory (code review)

npx ctxpack src/feature --out feature.md

Pipe straight to the clipboard

npx ctxpack . --budget 100000 | pbcopy      # macOS
npx ctxpack . --budget 100000 | xclip -sel c # Linux

RAG ingestion (XML + custom ignores)

npx ctxpack . --format xml --budget 8000 --ignore "tests/**" --ignore "*.snap" --out chunk.xml

Programmatic

import { pack } from 'ctxpack';

const { output, includedFiles, tokenCount, redactions } = pack('.', {
  budgetTokens: 120_000,
  format: 'md',
  extraIgnore: ['docs/**'],
});
console.log(`${includedFiles.length} files, ~${tokenCount} tokens, ${redactions} redactions`);

Verify nothing sensitive leaks

npx ctxpack . --out ctx.md
grep -i "api_key\|secret\|BEGIN .*PRIVATE KEY" ctx.md   # should show only [REDACTED …]