PR Context Packer
Use this skill when the user wants high-signal PR context for an LLM:
- •include GitHub PR title/body by default,
- •include the actual diff,
- •include full current code for changed files,
- •optionally expand with related files discovered via Scribe,
- •fit related files into the remaining token budget,
- •verify final fit against a context window budget.
What it does
prepare-pr-context.sh:
- •Resolves PR base (
--baseor auto-detect) - •Pulls GitHub PR title/body by default (via
gh, with graceful fallback) - •Captures changed files + full git diff (
base...HEAD) - •Includes full current content of changed files (safe filters applied)
- •Optionally expands related files using Scribe covering-set (dependents included by default)
- •Ranks related candidates and greedily fits them into remaining token budget
- •Writes a single final text file plus manifests (changed/related/omitted + related-omitted + selection + scribe-target audit)
- •Counts tokens with
tokencount --encoding o200k-baseand trims low-priority related files if needed
Command
bash
$HOME/dev/pi-skills/pr-context-packer/prepare-pr-context.sh <project_dir> [options]
Common invocations
bash
# Typical PR pack (tmp output by default) $HOME/dev/pi-skills/pr-context-packer/prepare-pr-context.sh ~/dev/mobile-1 --base origin/main # Disable Scribe expansion (diff + changed files only) $HOME/dev/pi-skills/pr-context-packer/prepare-pr-context.sh ~/dev/mobile-1 --base origin/main --no-scribe # Keep output in repo prompt/ instead of /tmp $HOME/dev/pi-skills/pr-context-packer/prepare-pr-context.sh ~/dev/mobile-1 --base origin/main --in-project-output # Tight budget + fail if over $HOME/dev/pi-skills/pr-context-packer/prepare-pr-context.sh ~/dev/mobile-1 --base origin/main --budget 180000 --fail-over-budget
Key options
- •
--base <ref>base ref to diff against (default: auto-detect) - •
--pr <ref>explicit PR number/url/branch forgh pr viewlookup - •
--no-pr-descriptionskip GitHub PR title/body section - •
--tmp-outputwrite output to/tmp/context-packer/...(default) - •
--in-project-outputwrite output to<repo>/prompt/ - •
--no-scribedisable Scribe related-file expansion - •
--no-dependentsdisable dependent-file expansion (dependents are included by default) - •
--scribe-max-depth <n>and--scribe-max-files <n>control each covering-set query - •
--scribe-target-limit <n>cap number of changed files used as Scribe targets (default:0= all) - •
--max-related <n>cap ranked related candidate pool before budget fitting (0disables related section) - •
--budget <tokens>token budget (default:272000) - •
--fail-over-budgetreturn non-zero when over budget - •
--include-lockfiles,--include-env,--include-secretsfor explicit opt-ins
Output manifests
For <output>.txt, the script writes:
- •
<output>.changed.files.txt - •
<output>.related.files.txt - •
<output>.omitted.files.txt(changed files omitted by safety filters) - •
<output>.related.omitted.files.txt(related candidates omitted with reasons) - •
<output>.related.selection.tsv(per-related candidate decision + token estimate) - •
<output>.scribe.targets.tsv(per-target Scribe status + possible max-files cap signals)
Requirements
- •
tokencount(cargo install tokencount) - •Optional GitHub CLI (
gh) for auto PR title/body inclusion - •Optional Scribe for related-file expansion:
- •
npm i -g @sibyllinesoft/scribe, or - •
cargo install scribe-cli, or - •
npx @sibyllinesoft/scribeavailable
- •
- •Optional clipboard tools:
- •macOS:
pbcopy - •Linux Wayland:
wl-copy
- •macOS: