worktree-stale-local-main-ref-inflates-pr-diff

worktree-stale-local-main-ref-inflates-pr-diff is a skill for Claude Code from wan-huiyan/agent-traffic-control. It costs 398 tokens per session (2,545 once invoked), scanned A, original, MIT.

A Git worktree troubleshooting guide for misleading pull request diffs. It explains why a local `main` reference can be out of date and make `git diff main...HEAD` show many unrelated files.

In plain words
What is it for?
Use it when working in multiple Git worktrees and the three-dot diff is much larger than the files in your commit.
Why use it?
It prevents you from mistaking an outdated local reference for a pull request that reverts upstream work. This avoids unnecessary panic, rebases, or blocked merges.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions subagents; mentions Claude Code.

Part of the agent-traffic-control plugin — 105 skills shipped together

Good fit Use it when working in multiple Git worktrees and the three-dot diff is much larger than the files in your commit.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff
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 wan-huiyan/agent-traffic-control --skill worktree-stale-local-main-ref-inflates-pr-diff
Clone the repo
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control

Made for: Claude Code.

Or install agent-traffic-control, the plugin that ships this one along with the rest of its 105 skills.

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 worktree-stale-local-main-ref-inflates-pr-diff

README.md
[![agentmods](https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff/github.svg)](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff)
Your own site
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff/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 worktree-stale-local-main-ref-inflates-pr-diff

Your own site · 80×15
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/worktree-stale-local-main-ref-inflates-pr-diff.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 398 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,545 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.
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.00398 $0.02545
Opus 5 $0.00199 $0.01273
Sonnet 5 $0.00080 $0.00509
Haiku 4.5 $0.00040 $0.00254

Measured 5d ago against content hash 2fa875911896, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

worktree-stale-local-main-ref-inflates-pr-diff 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 5d 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.

plugins/agent-traffic-control/skills/worktree-stale-local-main-ref-inflates-pr-diff/SKILL.md · 171 lines

How it starts

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

Worktree: a stale local main ref inflates git diff main...branch

Problem

In a multi-worktree repo, git diff main...<your-branch> (or --stat) reports far more files and lines than your commit actually changed — e.g. 92 files / 8,000+ insertions when your one commit touched 6 files. The instinct is to panic that your PR is silently reverting or re-touching a pile of upstream work (the stale-base-pr-silently-reverts-upstream-content trap) and to block your own merge or demand a rebase. Almost always, nothing is wrong with the PR — the local main ref is stale.

Context / Trigger Conditions

All of:

  • You're working inside a git worktree (git rev-parse --is-inside-work-tree; path contains .claude/worktrees/<name>/ or git worktree list shows 2+ paths).
  • git diff main...HEAD --stat (3-dot) shows tens/hundreds of files, but git show --stat HEAD (your actual commit) shows only a few.
  • You branched off what you thought was current main, and gh pr view <N> reports the PR as mergeable: MERGEABLE / mergeStateStatus: CLEAN.

Why it happens: main...branch (3-dot) diffs from the merge-base of the two refs. The merge-base uses your LOCAL main ref. In a multi-worktree setup the local main ref is whatever the primary worktree last checked out / pulled — frequently many commits behind origin/main because sibling sessions merge via GitHub (squash) and nobody runs git pull on the parked primary checkout. So the merge-base is ancient, and the 3-dot diff includes every file that landed on origin/main since that old point — none of which your branch is actually reverting. (This is the REF being stale, distinct from git-diff-2dot-vs-3dot-merge-safety, which is about 2-dot-vs-3-dot operator semantics against a correct origin/main.)

Solution

Diff against the remote ref, not the local main ref:

git fetch origin main -q

# The TRUE PR diff (what GitHub will merge):
git diff origin/main...HEAD --stat

# Confirm divergence is small:
git rev-list --count HEAD..origin/main   # commits origin/main has, your branch doesn't
git rev-list --count origin/main..HEAD   # YOUR commits

# Is your branch's base actually on origin/main's history? (necessary, NOT sufficient
# — see the Verification note below; this does not rule out a revert on its own)
git merge-base --is-ancestor <your-branch-base-sha> origin/main && echo "clean base"

# The check that DOES rule out a revert — deletions, from the merge-base:
git diff --diff-filter=D --name-only origin/main...HEAD   # empty ⇒ deletes nothing

# Ground truth from GitHub — the actual file list the PR will change:
gh pr view <N> --json files -q '.files[].path'
gh pr view <N> --json mergeable,mergeStateStatus

Read the full file on GitHub · 171 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. 5d ago First seen · 171 lines · 398 tokens per session scan A 2fa875911896

Subscribe to this mod's changes

worktree-stale-local-main-ref-inflates-pr-diff is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (3 stars, last pushed 5d ago), licensed MIT. It adds 398 tokens to every session and 2,545 once invoked, about $0.0020 per session on Opus 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-05.

Related

Other skills, from other repositories

ql-housekeep

Detect repo-hygiene issues that accumulate during long-running autonomous development (merge-conflict markers, orphan worktrees, CPC-variant duplicates, stale branches, version-manifest drift). Detection-only by default — reports findings, never deletes or modifies without explicit user confirmation.

andyzengmath/quantum-loop · 57 tokens

nazgul:doctor

Run the Nazgul read-only preflight diagnostic — checks jq/gh presence and auth, git-hooks drift, cache-vs-repo plugin version, the bash-vs-zsh hazard, the NAZGULDIR footgun, config-schema staleness, either install mode's .gitignore Nazgul-block drift (stamp and flush-left region), cross-session messaging and Remote…

OrodruinLabs/nazgul · 151 tokens

hotfix

Emergency fix workflow that bypasses normal sprint processes with a full audit trail. Creates hotfix branch, tracks approvals, and ensures the fix is backported correctly.

IdoCohen560/claude-unity-game-studio · 35 tokens

cloudflare-workers-ci-cd

Complete CI/CD guide for Cloudflare Workers using GitHub Actions and GitLab CI. Use for automated testing, deployment pipelines, preview environments, secrets management, or encountering deployment failures, workflow errors, environment configuration issues.

secondsky/claude-skills · 50 tokens

cloudflare-workers-observability

Cloudflare Workers observability with logging, Analytics Engine, Tail Workers, metrics, and alerting. Use for monitoring, debugging, tracing, or encountering log parsing, metric aggregation, alert configuration errors.

secondsky/claude-skills · 47 tokens

cloudflare-workers-dev-experience

Cloudflare Workers local development with Wrangler, Miniflare, hot reload, debugging. Use for project setup, wrangler.jsonc configuration, or encountering local dev, HMR, binding simulation errors.

secondsky/claude-skills · 47 tokens