branch-context

branch-context is a skill for Claude Code, Codex from axiomantic/spellbook. It costs 58 tokens per session (1,088 once invoked), scanned A, original, MIT.

A guide to comparing a Git branch with the correct merge base, the point where it diverged from its target branch. It also covers stacked branches, where one branch builds on another.

In plain words
What is it for?
It is for inspecting branch differences, finding merge bases, handling worktrees, and producing branch-relative pull request descriptions or changelogs.
Why use it?
It prevents inaccurate descriptions of what changed by separating the branch's own work from changes already present elsewhere. This matters when writing pull requests or changelogs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It is for inspecting branch differences, finding merge bases, handling worktrees, and producing branch-relative pull request descriptions or changelogs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/axiomantic/spellbook/branch-context
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add axiomantic/spellbook --skill branch-context
Clone the repo
git clone --depth 1 https://github.com/axiomantic/spellbook

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for branch-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/axiomantic/spellbook/branch-context/github.svg)](https://agentmods.dev/skills/axiomantic/spellbook/branch-context)
Your own site
<a href="https://agentmods.dev/skills/axiomantic/spellbook/branch-context"><img src="https://agentmods.dev/badge/skills/axiomantic/spellbook/branch-context/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for branch-context

Your own site · 80×15
<a href="https://agentmods.dev/skills/axiomantic/spellbook/branch-context"><img src="https://agentmods.dev/badge/skills/axiomantic/spellbook/branch-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,088 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00058 $0.01088
Opus 5.5 $0.00023 $0.00435
Sonnet 5.5 $0.00012 $0.00218
Haiku 4.5 $0.00006 $0.00109

Measured 1mo ago against content hash 0d050c0e4607, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

branch-context scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/branch-context/SKILL.md · 126 lines

How it starts

The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Branch Context

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 rules/55-diff-semantics.md; this skill covers usage details.

Invariant Principles

  1. Directory Determines Truth - Branch-context commands must run from the correct working directory; running from the wrong repo produces silently wrong results.
  2. Merge Base Is the Reference Point - All branch diffs, PR descriptions, and changelogs describe changes relative to the merge base, never absolute state.
  3. Stacked Branches Show Only Their Layer - In a stack, each branch's diff includes only what it added on top of its parent branch.

Script Usage

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 stat         # diffstat (merge base to working tree)
branch-context.sh stat-committed   # diffstat, committed only (merge base to HEAD)
branch-context.sh files        # changed file list (merge base to working tree)
branch-context.sh files-committed  # changed file list, committed only
branch-context.sh base         # the merge base SHA
branch-context.sh target       # the detected merge target
branch-context.sh resolution   # base provenance on stdout
branch-context.sh json         # machine-readable JSON

Read the full file on GitHub · 126 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 126 lines · 58 tokens per session scan A 0d050c0e4607

Subscribe to this mod's changes

branch-context is a skill published in the GitHub repository axiomantic/spellbook (10 stars, last pushed 2d ago), licensed MIT. It adds 58 tokens to every session and 1,088 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

repo-hygiene

Use when the scheduled repo-hygiene workflow runs from GitHub Actions (or an operator dry-run) to scan the repository for small, certain docs/test/code hygiene issues and fix them as one batched branch.

QwenLM/qwen-code · 48 tokens

create-issue

Draft and submit a GitHub issue from a user idea or bug description, with bilingual body and correct labels.

QwenLM/qwen-code · 26 tokens

docs-update-from-diff

Review local code changes with git diff and update the official docs under docs/ to match. Use when the user asks to document current uncommitted work, sync docs with local changes, update docs after a feature or refactor, or when phrases like "git diff", "local changes", "update docs", or "official docs" appear.

QwenLM/qwen-code · 75 tokens

prepare-pr

Prepare GitHub pull request title and body files from the current branch diff, especially for non-interactive CI/autofix flows that must follow the repository PR template without pushing or creating the PR.

QwenLM/qwen-code · 42 tokens

git-revert-safety

Apply when reverting commits, undoing merges, or recovering from branch contamination. Covers collateral damage verification (manifest, package.json, CHANGELOG, lockfiles), cherry-pick vs revert decision matrix, partial-revert detection, merge-parent handling, and post-revert CI verification. Prevents the most common…

ZaxbyHub/opencode-swarm · 79 tokens

safe-extraction

Apply when extracting code from a large monolith file into submodules. Covers barrel re-exports, internals DI seam proxy patterns, CI invariant allowlist updates, and cross-file test verification. Prevents CI failures, broken imports, and test regressions from code extraction.

ZaxbyHub/opencode-swarm · 60 tokens