harness-read-write-base-repo-path-in-worktree-stale-tree

harness-read-write-base-repo-path-in-worktree-stale-tree is a skill for Claude Code from wan-huiyan/agent-traffic-control. It costs 308 tokens per session (1,445 once invoked), scanned A, original, MIT.

A guide for avoiding file-editing mistakes when working in a Git worktree, which is a separate working copy of a repository. It explains how an absolute path can accidentally target the original repository instead of the active worktree.

In plain words
What is it for?
Use it when file contents, line numbers, or Git status disagree between tools, or when edits seem to disappear in a worktree-based development session.
Why use it?
It helps prevent reading stale code or writing changes into the wrong checkout, where the change may not appear in the branch being worked on.

Skill for Claude Code

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

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /Users/me/repo/…/bq_queries.py.

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

Good fit Use it when file contents, line numbers, or Git status disagree between tools, or when edits seem to disappear in a worktree-based development session.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add wan-huiyan/agent-traffic-control
Claude Code
/plugin install 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 harness-read-write-base-repo-path-in-worktree-stale-tree

README.md
[![agentmods](https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/harness-read-write-base-repo-path-in-worktree-stale-tree/github.svg)](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/harness-read-write-base-repo-path-in-worktree-stale-tree)
Your own site
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/harness-read-write-base-repo-path-in-worktree-stale-tree"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/harness-read-write-base-repo-path-in-worktree-stale-tree/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 harness-read-write-base-repo-path-in-worktree-stale-tree

Your own site · 80×15
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/harness-read-write-base-repo-path-in-worktree-stale-tree"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/harness-read-write-base-repo-path-in-worktree-stale-tree.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 308 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,445 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.00308 $0.01445
Opus 5 $0.00154 $0.00723
Sonnet 5 $0.00062 $0.00289
Haiku 4.5 $0.00031 $0.00145

Measured 12d ago against content hash c854fa172156, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

harness-read-write-base-repo-path-in-worktree-stale-tree 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 12d 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/harness-read-write-base-repo-path-in-worktree-stale-tree/SKILL.md · 80 lines

How it starts

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

Read/Write/Edit with a base-repo path silently hits the stale base tree in a worktree session

Problem

You're working in a worktree (<repo>/.claude/worktrees/<name>/). Your Bash tool runs with cwd = the worktree, so grep/git/wc see the worktree's branch. But Read/Write/Edit take absolute paths verbatim — if you write /…/<repo>/path (the BASE repo path, missing the .claude/worktrees/<name>/ segment) you operate on the base repo's working tree, a different checkout that shares the same .git and is usually parked on an unrelated, often month-stale branch. The two trees diverge silently and you don't get an error.

Context / Trigger Conditions

  • A Read's line numbers or the functions it shows disagree with a grep/wc you ran in the worktree cwd (e.g. def get_top_drivers at L2926 via Read vs L3795 via grep).
  • A Write reports success but the new file is absent from git status -sb in the worktree (it was created in the base repo, untracked there).
  • A Write to an existing file's path "works" but later edits to "the same file" via worktree-relative paths don't see your change.
  • A review panel / dispatched subagent / fresh git checkout reports a file you KNOW you wrote as "absent from the working tree" / "doesn't exist on any ref" (it's sitting untracked in the base repo).
  • A file looks much smaller/older than the current branch should have.

Solution

  1. Always prefix file paths with the worktree root — the value the environment prints as "Primary working directory" (/…/<repo>/.claude/worktrees/<name>/…), never the bare /…/<repo>/…. Bash is fine with worktree-relative paths (cwd is already the worktree); Read/Write/Edit need the full worktree-prefixed absolute path.
  2. Cross-check on first Read of any file: if its line numbers don't match a grep -n you ran in the worktree cwd, you read the wrong tree — re-read via the worktree path.
  3. After any Write/new file: confirm it shows in the worktree's git status -sb before relying on it (and before dispatching a review that needs it).
  4. Confirm the divergence when suspicious: git -C <base-repo> rev-parse --abbrev-ref HEAD vs the worktree's branch — if they differ, base-path reads/writes are operating on that other branch's content.

Read the full file on GitHub · 80 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. 12d ago First seen · 80 lines · 308 tokens per session scan A c854fa172156

Subscribe to this mod's changes

harness-read-write-base-repo-path-in-worktree-stale-tree is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (3 stars, last pushed today), licensed MIT. It adds 308 tokens to every session and 1,445 once invoked, about $0.0015 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-08-31.

Related

Other skills, from other repositories

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

claude-code-bash-patterns

Claude Code Bash tool patterns with hooks, automation, git workflows. Use for PreToolUse hooks, command chaining, CLI orchestration, custom commands, or encountering bash permissions, command failures, security guards, hook configurations.

secondsky/claude-skills · 52 tokens

bump-sdk-version

Bump the FutureSearch SDK version across all files. Use when releasing a new SDK version, updating version numbers, or the user says bump version, release, version bump.

futuresearch/futuresearch-python · 40 tokens

pr-check

PR review compliance: fetch review comments from an open PR, categorize as resolved/unresolved/dismissed, critically evaluate fixable items, implement approved fixes, and reply inline. Pass --unattended to halt on human-judgment items (emitted as Pending-Human) instead of prompting via AskUserQuestion.

rube-de/cc-skills · 67 tokens

babysit

PR babysitter: monitors CI status, auto-rebases when behind, auto-fixes CI where possible, delegates review comment handling to dlc:pr-check, and re-requests review after fixes. Designed for /loop usage with Remote Control.

rube-de/cc-skills · 53 tokens

git-ops

Git hygiene: clean up merged branches, prune stale remotes, and verify repository state.

rube-de/cc-skills · 22 tokens