skills/branch-context/SKILL.md
Triggers: 'branch diff', 'what changed on this branch', 'merge base', 'stacked branches', 'branch-context.sh', 'what does this branch do', 'PR description', 'changelog', 'branch comparison', 'diff since', 'what work is on this branch'. Also relevant during PR creation and finishing-a-development-branch workflows.
npx skillsauth add axiomantic/spellbook branch-contextInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Type: Reference + Technique
Practical guide for inspecting branch context, handling stacked branches, and producing branch-relative documentation. Core definitions (merge target, merge base, branch diff) live in AGENTS.spellbook.md; this skill covers usage details.
Use $SPELLBOOK_DIR/scripts/branch-context.sh to detect branch context
automatically:
branch-context.sh # summary: target, base, stats, uncommitted state
branch-context.sh diff # full diff (merge base to working tree)
branch-context.sh diff-committed # committed only (merge base to HEAD)
branch-context.sh diff-uncommitted # uncommitted only (staged + unstaged vs HEAD)
branch-context.sh log # commit log since merge base
branch-context.sh files # changed file list
branch-context.sh json # machine-readable JSON
$SPELLBOOK_DIR is substituted at load time from spellbook configuration.
This matters for stacked branches: if master -> branch-A -> branch-B, the
work on branch-B is only what branch-B added on top of branch-A. The script
auto-detects stacking via PR base refs.
When reviewing stacked branches:
branch-context.sh to confirm the detected merge target.branch-A), not main
or master.In worktrees, run this script FROM the worktree directory. It detects worktree context automatically.
Before running any branch-context command in a worktree, verify you are in the correct directory:
cd <worktree-path> && pwd && git branch --show-current
Running branch-context.sh from the main repo while intending to inspect a
worktree branch will produce silently wrong results (empty diffs, wrong merge
base).
Changelogs, PR titles, PR descriptions, commit messages, and code comments
describe the merge-base delta only. No historical narratives in code comments.
Full policy in finishing-a-development-branch skill.
Rules:
testing
Use when creating new skills, editing existing skills, or verifying skills work before deployment. Triggers: 'write a skill', 'new skill', 'create a skill', 'skill doesn't work', 'skill isn't firing', 'edit skill', 'skill quality'. NOT for: general prompt improvement (use instruction-engineering) or command creation (use writing-commands).
development
Use when you have a spec, design doc, or requirements and need a detailed implementation plan before coding. Triggers: 'write a plan', 'create implementation plan', 'plan this out', 'break this down into steps', 'convert design to tasks', 'implementation order'. Also invoked by develop during planning. NOT for: reviewing existing plans (use reviewing-impl-plans).
testing
Use when creating new commands, editing existing commands, or reviewing command quality. Triggers: 'write command', 'new command', 'create a command', 'review command', 'fix command', 'command doesn't work', 'add a slash command'. NOT for: skill creation (use writing-skills).
development
Use when about to claim discovery during debugging. Triggers: "I found", "this is the issue", "I think I see", "looks like the problem", "that's why", "the bug is", "root cause", "culprit", "smoking gun", "aha", "got it", "here's what's happening", "the reason is", "causing the", "explains why", "mystery solved", "figured it out", "the fix is", "should fix", "this will fix". Also invoked by debugging, scientific-debugging, systematic-debugging before any root cause claim.