
Check a stale branch is not undoing newer main work
Checks a branch for stale-base changes that would silently undo newer main work
Check a stale branch is not undoing newer main work is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.
- Scripts
- None
- Platforms
- Claude Code, Codex, Cursor
- GitHub stars
- 5
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Check a stale branch is not undoing newer main work
This skill guides an agent through checking whether a branch, before it merges, would delete files or roll back values and shared ledger rows that landed on main after the branch was cut. It explains that a clean merge and passing CI do not rule this out, because the damage comes from a stale working tree committed under a current parent rather than from a conflict.
The workflow fetches origin/main and compares the branch with three-dot diffs for stats and deletions, then falsifies large diff counts against the commit's own stat and the PR's file list. For shared files it greps anchored values on both trees, and for hand-edited ledgers it ships a Python script that parses both sides and compares row ids and bodies. The skill also covers recovery steps such as restoring deleted paths, rebuilding a ledger from main, and targeted reverts, plus a post-merge audit.
It expects a git repository with a fetchable origin and the GitHub CLI for PR inspection. The ledger script assumes a specific JavaScript data file layout and needs its paths and session ids edited for each repository.
When your agent uses it
A branch built on an out-of-date main is about to merge, or has merged, and may undo work that landed since. Use when a green, conflict-free PR deletes files you never touched, newer values or a whole redesign vanish after a sibling PR merged, rows of a shared ledger (tracker, registry, CHANGELOG) disappear or revert, or when `git diff main...HEAD` or a reviewer says your small PR touches dozens of files you did not change.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 1 file (28 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the agent-traffic-control plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-controlOr copy only this skill to ~/.claude/skills/check-a-stale-branch-is-not-undoing-newer-main-work:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
cp -R "$tmp/plugins/agent-traffic-control/skills/check-a-stale-branch-is-not-undoing-newer-main-work" ~/.claude/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/check-a-stale-branch-is-not-undoing-newer-main-work inside it instead.
Copy the skill folder to ~/.agents/skills/check-a-stale-branch-is-not-undoing-newer-main-work to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
cp -R "$tmp/plugins/agent-traffic-control/skills/check-a-stale-branch-is-not-undoing-newer-main-work" ~/.agents/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/check-a-stale-branch-is-not-undoing-newer-main-work inside it instead.
Copy the skill folder to ~/.cursor/skills/check-a-stale-branch-is-not-undoing-newer-main-work to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
cp -R "$tmp/plugins/agent-traffic-control/skills/check-a-stale-branch-is-not-undoing-newer-main-work" ~/.cursor/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/check-a-stale-branch-is-not-undoing-newer-main-work inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/check-a-stale-branch-is-not-undoing-newer-main-workOr copy the folder to ~/.gemini/skills/check-a-stale-branch-is-not-undoing-newer-main-work yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/check-a-stale-branch-is-not-undoing-newer-main-work:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
cp -R "$tmp/plugins/agent-traffic-control/skills/check-a-stale-branch-is-not-undoing-newer-main-work" ~/.copilot/skills/check-a-stale-branch-is-not-undoing-newer-main-work &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/check-a-stale-branch-is-not-undoing-newer-main-work inside it instead.
Get the folder:
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.gitThen copy agent-traffic-control/plugins/agent-traffic-control/skills/check-a-stale-branch-is-not-undoing-newer-main-work into your agent's skills folder as check-a-stale-branch-is-not-undoing-newer-main-work. Agents that support SKILL.md read one folder per skill.
What it does
- Stale-base deletion check
- Uses three-dot diffs against fetched origin/main to list files a branch would delete or touch unexpectedly.
- Ledger row audit
- Compares row ids and bodies in a shared data file against main and flags removed or rolled-back rows.
- Anchored value grep
- Checks that newly changed values still appear in shared files on both the branch and main trees.
- Large diff falsification
- Compares git show stats with PR file lists to tell real over-scope from a misleading diff count.
- Recovery procedure
- Covers restoring deleted files, rebuilding a hand-edited ledger from main, and targeted reverts after a merge.
- Post-merge verification
- Provides commands to confirm files and needles survived on origin/main after a merge.
Good for
- Check my PR for files it accidentally deletes before merging
- Find out whether a squash merge reverted rows in our shared tracker file
- Confirm that updated numbers on the site survived a later merge
- Restore a file that a stale branch removed from main
- Diagnose why a pull request diff shows dozens of unrelated files
Check a stale branch is not undoing newer main work FAQ
Does Check a stale branch is not undoing newer main work need any scripts or tools to run?
It needs git and, for PR inspection, the GitHub CLI. The ledger audit is a Python script included in the skill, which reads a specific data file path that you must edit for your repository.
Is a merge conflict a sign that this problem is happening?
No. The skill says silent reverts usually produce no conflict and a green, mergeable PR, so conflicts are not the signal to watch.
Why is merging origin/main before a PR not enough?
The skill notes that against a stale tree a merge is a no-op, so it counts as hygiene rather than as the check that prevents a revert.
How do I install Check a stale branch is not undoing newer main work in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/check-a-stale-branch-is-not-undoing-newer-main-work to use it in all your projects, or to .claude/skills/check-a-stale-branch-is-not-undoing-newer-main-work in one project. Or install the agent-traffic-control plugin, which includes it: /plugin marketplace add wan-huiyan/agent-traffic-control, then /plugin install agent-traffic-control@wan-huiyan-agent-traffic-control.
Does Check a stale branch is not undoing newer main work run scripts?
No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Check a stale branch is not undoing newer main work?
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.
What are the best alternatives to Check a stale branch is not undoing newer main work?
The closest alternatives to Check a stale branch is not undoing newer main work are Git diff 2dot vs 3dot merge safety, Git branch cleanup, Fix merge conflicts, Git post merge cleanup and Git clean worktrees.
Where this comes from
- Description: from the skill's own SKILL.md.
More from wan-huiyan/agent-traffic-control

Teaches agents to refuse a flawed instruction only with measured evidence attached
- Open source
- 5 GitHub stars
- Developer tools

Catches silent deletions when a subagent edits large files with repeated blocks
- Open source
- 5 GitHub stars
- Developer tools

Holds a pull request from merging by stopping its agent, disarming auto-merge, then
- Open source
- 5 GitHub stars
- Developer tools

Checks that a batch of pull requests does not cite file paths that will never exist
- Open source
- 5 GitHub stars
- Developer tools

Checks whether a pull request truly landed by comparing file content, not commit subjects
- Open source
- 5 GitHub stars
- Developer tools

Checks whether a CI skip rule actually saves money or only moves job minutes
- Open source
- 5 GitHub stars
- Developer tools



