
Injected claude md is the worktrees copy not mains
Checks whether an injected CLAUDE.md is a stale worktree copy before claiming it is wrong
Injected claude md is the worktrees copy not mains is an open-source agent skill for developer tools. It is available on Claude Code.
- Scripts
- None
- Platforms
- Claude Code
- GitHub stars
- 5
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Injected claude md is the worktrees copy not mains
This skill tells an agent how to verify which version of a project instruction file it is actually reasoning from. Instruction files such as CLAUDE.md, AGENTS.md or GEMINI.md are loaded from the checkout a session started in, so a long-lived worktree can hold a copy weeks behind the default branch. The guidance covers why an old copy can look more complete than the current one and why compaction can re-read a different version mid-session.
The workflow is a short set of git commands: fetch the remote default branch, compare file sizes and the last commit that changed the file, and search the live file before making any claim about it. It also covers how to phrase a report so it cites the exact commit and copy it relies on, and how to use a marker sentence to check what a session's context contains, since byte counts cannot measure that.
It expects a git repository with a remote and the git command line available. The steps are shell commands and the skill is written for Claude Code sessions working in worktrees.
When your agent uses it
The CLAUDE.md (or AGENTS.md / GEMINI.md) your session quotes is the copy in the checkout the session STARTED in, not the one on the default branch — and a long-lived worktree's copy can be weeks behind, so every house rule in context may be retired. Use when: (1) you are about to write or say "CLAUDE.md says X", "the house rule is X", or "the project file is stale about X"; (2) your session runs in a worktree that was created days or weeks ago; (3) a SessionStart hook or banner mentions the instruction file differing from the default branch; (4) you are about to file an issue, correct a document, or tell a peer that a shared instruction file contradicts the code. The failure inverts: the file on the default branch is usually RIGHT and your injected copy is the stale thing, so the bug report points at the wrong artefact. A retired copy is often LONGER than the current file — superseded correction notes accumulate until a rewrite deletes them — so the stale version reads as the more complete one. The copy carri
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 (14 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/injected-claude-md-is-the-worktrees-copy-not-mains:
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/injected-claude-md-is-the-worktrees-copy-not-mains &&
cp -R "$tmp/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains" ~/.claude/skills/injected-claude-md-is-the-worktrees-copy-not-mains &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/injected-claude-md-is-the-worktrees-copy-not-mains inside it instead.
Copy the skill folder to ~/.agents/skills/injected-claude-md-is-the-worktrees-copy-not-mains 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/injected-claude-md-is-the-worktrees-copy-not-mains &&
cp -R "$tmp/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains" ~/.agents/skills/injected-claude-md-is-the-worktrees-copy-not-mains &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/injected-claude-md-is-the-worktrees-copy-not-mains inside it instead.
Copy the skill folder to ~/.cursor/skills/injected-claude-md-is-the-worktrees-copy-not-mains 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/injected-claude-md-is-the-worktrees-copy-not-mains &&
cp -R "$tmp/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains" ~/.cursor/skills/injected-claude-md-is-the-worktrees-copy-not-mains &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/injected-claude-md-is-the-worktrees-copy-not-mains 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/injected-claude-md-is-the-worktrees-copy-not-mainsOr copy the folder to ~/.gemini/skills/injected-claude-md-is-the-worktrees-copy-not-mains yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/injected-claude-md-is-the-worktrees-copy-not-mains:
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/injected-claude-md-is-the-worktrees-copy-not-mains &&
cp -R "$tmp/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains" ~/.copilot/skills/injected-claude-md-is-the-worktrees-copy-not-mains &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/injected-claude-md-is-the-worktrees-copy-not-mains 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/injected-claude-md-is-the-worktrees-copy-not-mains into your agent's skills folder as injected-claude-md-is-the-worktrees-copy-not-mains. Agents that support SKILL.md read one folder per skill.
What it does
- Stale copy detection
- Explains how an injected instruction file can differ from the default branch without any visible sign.
- Remote default branch check
- Uses git show against the fetched remote branch to read the live instruction file.
- Size and history comparison
- Compares byte counts and the last commit that changed the file in each copy.
- Marker sentence test
- Finds a sentence present in one version and absent in the other to identify which copy a session holds.
- Claim provenance wording
- Shows how to word a report so it names the copy and commit it was checked against.
- Control check in fresh worktree
- Runs the same comparison in a clean worktree of the default branch to confirm the check works.
Good for
- Check whether CLAUDE.md in my worktree matches the main branch before I file an issue
- Find out if the house rules my session loaded are still current
- Compare my worktree's instruction file against origin/main after a SessionStart warning
- Write a message to another session that cites which copy of the rules it is reading
Injected claude md is the worktrees copy not mains FAQ
When does Injected claude md is the worktrees copy not mains trigger?
It applies when an agent is about to say that CLAUDE.md or a similar file is stale or contradicts the code, when the session runs in a worktree created days or weeks earlier, or when a hook mentions the instruction file differing from the default branch.
What does Injected claude md is the worktrees copy not mains need to run?
It relies on git, a remote named origin with the default branch fetched, and shell commands such as wc and grep. The skill is written for Claude Code sessions working in worktrees.
Does Injected claude md is the worktrees copy not mains change any files?
Its steps read files with git show and compare sizes. The one suggested cleanup merges the default branch into a worktree or removes a finished worktree, and only after a clean status check.
Why not compare file sizes alone?
The skill explains that size is not a reliable signal: a retired copy is often longer than the current file, and compaction can re-read a different version, so the marker sentence test is recommended for judging what a session's context holds.
How do I install Injected claude md is the worktrees copy not mains in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/injected-claude-md-is-the-worktrees-copy-not-mains to use it in all your projects, or to .claude/skills/injected-claude-md-is-the-worktrees-copy-not-mains 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 Injected claude md is the worktrees copy not mains 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 Injected claude md is the worktrees copy not mains?
Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.
What are the best alternatives to Injected claude md is the worktrees copy not mains?
The closest alternatives to Injected claude md is the worktrees copy not mains are Harness read write base repo path in worktree stale tree, Concurrent session checkout clobbers shared worktree, Claude md refactor, Git worktree and Claude code projects jsonl worktree fanout.
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 a branch for stale-base changes that would silently undo newer main work
- Open source
- 5 GitHub stars
- Developer tools


