worktree-historical-test-replay-missing-dirs

worktree-historical-test-replay-missing-dirs is a skill for Claude Code from wan-huiyan/agent-traffic-control. It costs 239 tokens per session (1,832 once invoked), scanned A, original, MIT.

A guide to running tests against old Git commits in temporary worktrees when the test directories named by the current command did not exist at those commits.

In plain words
What is it for?
It helps with incident replay, mutation testing, and Git bisect by checking test paths and interpreting pytest exit code 4 on older revisions.
Why use it?
It prevents a test command that stops before running any tests from being mistaken for a meaningful historical pass or failure.

Skill for Claude Code

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

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

Good fit It helps with incident replay, mutation testing, and Git bisect by checking test paths and interpreting pytest exit code 4 on older revisions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs
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-historical-test-replay-missing-dirs
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-historical-test-replay-missing-dirs

README.md
[![agentmods](https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs/github.svg)](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs)
Your own site
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs/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-historical-test-replay-missing-dirs

Your own site · 80×15
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/worktree-historical-test-replay-missing-dirs.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 239 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,832 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00239 $0.01832
Opus 5 $0.00120 $0.00916
Sonnet 5 $0.00048 $0.00366
Haiku 4.5 $0.00024 $0.00183

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

Security

Grade A, and why

worktree-historical-test-replay-missing-dirs scanned grade A with 1 finding 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 7d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

subprocess.run(["pytest", *existing, "--tb=no", "-q"], cwd=worktree_path)
plugins/agent-traffic-control/skills/worktree-historical-test-replay-missing-dirs/SKILL.md · 176 lines

How it starts

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

Worktree historical test replay — missing dirs

Problem

You're replaying historical bugs by checking out each pre-fix SHA in a temp worktree and running the project's canonical test command. At HEAD the command works (e.g. 159 tests collect). At older SHAs you get:

ERROR: file or directory not found: scripts/overnight/tests/

no tests ran in 0.01s

Exit code 4, duration 1-2 seconds. Pytest aborted before collection because one of the test directories you passed didn't exist yet at that commit.

This silently corrupts a historical-replay audit: you can't tell apart "the suite passed and missed the bug" from "the suite never ran." Both look like pytest failures from the outside.

Context / Trigger Conditions

  • You're running historical incident replay, mutation testing, git bisect, or any other "check out an old SHA and run the suite" workflow
  • The project's test layout grew over time (test dirs added, removed, reorganized in subsequent commits)
  • The test command embeds explicit directory paths: pytest scripts/overnight/tests/ <analytics_pkg>/tests/ ...
  • Pytest exits 4 (USAGE_ERROR) in <5 seconds with no test execution
  • The SAME test command works at HEAD but fails at pre-fix SHAs older than the test layout's current shape

Solution

Before invoking the test command at each SHA, filter the test directory list to only those that exist in the worktree at that SHA:

# Inside the worktree at the target SHA:
TEST_DIRS=()
for d in scripts/overnight/tests <analytics_pkg>/tests <analytics_pkg>/cloudrun/<dashboard_app>/tests; do
  [ -d "$d" ] && TEST_DIRS+=("$d")
done

if [ ${#TEST_DIRS[@]} -eq 0 ]; then
  # No test dirs existed at this SHA — classify as 'unrunnable', skip.
  echo "STATUS=unrunnable_no_test_dirs_at_sha"
  exit 0
fi

PYTHONPATH=. pytest "${TEST_DIRS[@]}" --tb=no -q

In Python:

test_dirs_at_head = ["scripts/overnight/tests", "<analytics_pkg>/tests"]
existing = [d for d in test_dirs_at_head if (worktree_path / d).is_dir()]
if not existing:
    return {"status": "unrunnable", "reason": "no test dirs existed at this SHA"}
subprocess.run(["pytest", *existing, "--tb=no", "-q"], cwd=worktree_path)

Read the full file on GitHub · 176 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. 7d ago First seen · 176 lines · 239 tokens per session scan A c29f20348320

Subscribe to this mod's changes

worktree-historical-test-replay-missing-dirs is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (3 stars, last pushed today), licensed MIT. It adds 239 tokens to every session and 1,832 once invoked, about $0.0012 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.