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
# Default budget (272000), code + docs + tests pack
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui
# Code-focused pack (exclude docs and tests)
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui --no-docs --no-tests
# Include env/sensitive files explicitly (off by default for safety)
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui --include-env --include-secrets
# Custom budget and output name
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui \
--budget 272000 \
--output pui-gpt5.txt
# Fail with exit code 2 if over budget
$HOME/dev/pi-skills/context-packer/prepare-context.sh ~/dev/pui --fail-over-budget
Options
--output <name>output filename (default:context-dump.txt)--tmp-outputwrite output to/tmp/context-packer/...instead of<project>/prompt/--budget <tokens>token budget (default:272000)--with-docsincludedocs/(default: on)--with-testsinclude test files (__tests__,tests/,test/,*.test.*,*.spec.*, etc.) (default: on)--no-docsexcludedocs/--no-testsexclude test files (__tests__,tests/,test/,*.test.*,*.spec.*, etc.)--include-lockfilesinclude lockfiles (pnpm-lock.yaml,Cargo.lock, etc.)--include-envinclude env files (.env,.env.*,.envrc) (default: off)--include-secretsinclude potentially sensitive files (.npmrc,.netrc, keys/certs, cloud credential files, etc.) (default: off)--no-clipboarddo not refresh clipboard from output file--fail-over-budgetreturn non-zero if budget exceeded--install-toolsinstall missingtokencountvia cargo
Requirements
tokencountinstalled (cargo install tokencount)- Optional helper utility:
copy_files(not required) - Optional clipboard tools:
- macOS:
pbcopy - Linux Wayland:
wl-copy
- macOS:
If no clipboard tool is available, the script still writes output files; it just skips clipboard copy.