You give it a manifest: a JSON file that names each segment of material you might put in a prompt, what kind of thing it is, how important it is, whether it is mandatory, which other segments it cites, and where its text comes from. You give it a token budget. It tells you what fits.
This walkthrough uses the tool's public README and checked-in example files. Run the command from a repository checkout with Node.js 22+.
Run the checked-in example
# Pack the worked example and write the retained segments out
node bin/context-window-packer.mjs \
--manifest examples/brief/manifest.json \
--config examples/packer.config.json \
--pack-out build/example-pack.json
# The same run as machine-readable JSON
node bin/context-window-packer.mjs \
--manifest examples/brief/manifest.json \
--token-cost estimate --budget-tokens 240 --json
# A manifest whose mandatory instructions do not fit: exits 1
node bin/context-window-packer.mjs \
--manifest examples/over-budget/manifest.json \
--token-cost declared --budget-tokens 256
# Everything: lint, tests, both examples, packaging
npm run checkRead the result
A consumer piping stdout must handle the empty case. Emitting a fake report for a run that never started would be worse.
Scope
Every limit is enforced, overridable from the command line, and named in the finding when it is reached. Exceeding one is an incomplete result with no pack — never a quietly shorter window.