| name | context-packer |
| description | Build LLM-ready code dumps with optional docs, then count tokens with tokencount (o200k-base) against a context budget (for example 272k for GPT-5). |
Context Packer
Use this skill when the user wants to:
- copy a project into an LLM-friendly single text file,
- include/exclude docs, tests, lockfiles, etc.,
- verify token count against a model context window.
What it does
prepare-context.sh:
- Selects relevant project files (tracked files by default)
- Excludes common junk (generated files, prior dumps, lockfiles/env/sensitive files unless requested)
- Builds a fenced text dump (
path + ``` + contents) for all selected files
- Writes dump to
<project>/prompt/<output>.txt (or /tmp/context-packer/... with --tmp-output)
- Writes a manifest of included files next to the dump
- Counts tokens with
tokencount --encoding o200k-base
- Reports whether it fits the provided budget
Command
$HOME/dev/pi-skills/context-packer/prepare-context.sh <project_dir> [options]
Common invocations
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui --no-docs --no-tests
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui --include-env --include-secrets
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui \
--budget 272000 \
--output pui-gpt5.txt
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui --fail-over-budget
Options
--output <name> output filename (default: context-dump.txt)
--tmp-output write output to /tmp/context-packer/... instead of <project>/prompt/
--budget <tokens> token budget (default: 272000)
--with-docs include docs/ (default: on)
--with-tests include test files (__tests__, tests/, test/, *.test.*, *.spec.*, etc.) (default: on)
--no-docs exclude docs/
--no-tests exclude test files (__tests__, tests/, test/, *.test.*, *.spec.*, etc.)
--include-lockfiles include lockfiles (pnpm-lock.yaml, Cargo.lock, etc.)
--include-env include env files (.env, .env.*, .envrc) (default: off)
--include-secrets include potentially sensitive files (.npmrc, .netrc, keys/certs, cloud credential files, etc.) (default: off)
--no-clipboard do not refresh clipboard from output file
--fail-over-budget return non-zero if budget exceeded
--install-tools install missing tokencount via cargo
Requirements
tokencount installed (cargo install tokencount)
- Optional helper utility:
copy_files (not required)
- Optional clipboard tools:
- macOS:
pbcopy
- Linux Wayland:
wl-copy
If no clipboard tool is available, the script still writes output files; it just skips clipboard copy.