# Injected claude md is the worktrees copy not mains

> Injected claude md is the worktrees copy not mains is an open-source agent skill for developer tools. Checks whether an injected CLAUDE.md is a stale worktree copy before claiming it is wrong. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains
- **Repository:** https://github.com/wan-huiyan/agent-traffic-control
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** injected-claude-md-is-the-worktrees-copy-not-mains
- **Collection:** https://github.com/wan-huiyan/agent-traffic-control
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

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

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains)
- [License: MIT](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/injected-claude-md-is-the-worktrees-copy-not-mains)

## Features

- **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

## Install

### Claude Code

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):

```sh
/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-control
```

Or copy only this skill to `~/.claude/skills/injected-claude-md-is-the-worktrees-copy-not-mains`:

```sh
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.

### Codex

Copy the skill folder to `~/.agents/skills/injected-claude-md-is-the-worktrees-copy-not-mains` to use it in every repository:

```sh
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.

### Cursor

Copy the skill folder to `~/.cursor/skills/injected-claude-md-is-the-worktrees-copy-not-mains` to use it in every project:

```sh
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.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
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-mains
```

Or copy the folder to `~/.gemini/skills/injected-claude-md-is-the-worktrees-copy-not-mains` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/injected-claude-md-is-the-worktrees-copy-not-mains`:

```sh
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.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git
```

Then 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.

## 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.

## Alternatives

- [Harness read write base repo path in worktree stale tree](https://ai-powered.com/skills/harness-read-write-base-repo-path-in-worktree-stale-tree): Harness read write base repo path in worktree stale tree is an open-source agent skill for developer tools.
- [Concurrent session checkout clobbers shared worktree](https://ai-powered.com/skills/concurrent-session-checkout-clobbers-shared-worktree): Concurrent session checkout clobbers shared worktree is an open-source agent skill for developer tools.
- [Claude md refactor](https://ai-powered.com/skills/claude-md-refactor): Claude md refactor is an open-source agent skill for developer tools.
- [Git worktree](https://ai-powered.com/skills/git-worktree): Git worktree is an open-source agent skill for developer tools.
- [Claude code projects jsonl worktree fanout](https://ai-powered.com/skills/claude-code-projects-jsonl-worktree-fanout): Claude code projects jsonl worktree fanout is an open-source agent skill for developer tools.
- [Check a stale branch is not undoing newer main work](https://ai-powered.com/skills/check-a-stale-branch-is-not-undoing-newer-main-work): Check a stale branch is not undoing newer main work is an open-source agent skill for developer tools.
- [Cross worktree spec handoff via checkout paths](https://ai-powered.com/skills/cross-worktree-spec-handoff-via-checkout-paths): Cross worktree spec handoff via checkout paths is an open-source agent skill for developer tools.
- [Main bash cwd persists nested worktree](https://ai-powered.com/skills/main-bash-cwd-persists-nested-worktree): Main bash cwd persists nested worktree is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/injected-claude-md-is-the-worktrees-copy-not-mains
