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.
npx skills add wan-huiyan/agent-traffic-control --skill gh-pr-merge-worktree-checkout-trapgit clone --depth 1 https://github.com/wan-huiyan/agent-traffic-controlWrote 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.
[](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/gh-pr-merge-worktree-checkout-trap)<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/gh-pr-merge-worktree-checkout-trap"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/gh-pr-merge-worktree-checkout-trap/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.
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/gh-pr-merge-worktree-checkout-trap"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/gh-pr-merge-worktree-checkout-trap.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00497 | $0.03765 |
| Opus 5.5 | $0.00199 | $0.01506 |
| Sonnet 5.5 | $0.00099 | $0.00753 |
| Haiku 4.5 | $0.00050 | $0.00377 |
Grade A, and why
gh-pr-merge-worktree-checkout-trap 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 3mo 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.
How it starts
The opening of the file, as written. The whole thing — 305 lines — stays where its author put it; the contents beside it link to each section on GitHub.
gh pr merge Worktree-on-Main Checkout Trap
Problem
gh pr merge --squash --delete-branch (and similar commands) fail with:
failed to run git: fatal: 'main' is already used by worktree at '/path/to/another/worktree'
even when the user has every right to merge the PR. The error makes it look like the merge failed, prompting the user to retry or panic.
The merge actually succeeded on GitHub. Only gh's post-merge local
side-effect — switching the local working tree to main so it's "ready"
after the merge — failed because git refuses to check out a branch that's
already checked out in another worktree.
Context / Trigger Conditions
You are in the right place if all of these are true:
- You ran
gh pr merge <number>(any merge mode:--squash/--merge/--rebase). - The exact error includes
fatal: 'main' is already used by worktree at. - The repo has multiple
git worktreeentries (rungit worktree listto confirm). - One of those worktrees is on
main(or whichever branch the PR merged into).
The command's first action is the GitHub merge API call; the local checkout is downstream of that. Failures in the local step do NOT roll back the merge.
Solution
Step 1: Verify the merge actually happened
gh pr view <number> --json state,mergedAt
# {"state":"MERGED","mergedAt":"YYYY-MM-DDTHH:MM:SSZ"}
If state is MERGED: the PR is merged. The error was a local cleanup
side-effect, not a merge failure. You can stop here. Optionally clean up
local artifacts:
# delete the remote branch (gh's --delete-branch flag also failed silently)
git push origin --delete <feature-branch-name>
# delete the local feature branch (it's already orphaned by the merge)
git branch -D <feature-branch-name>
# remove the worktree you used to develop the feature
git worktree remove .claude/worktrees/<your-feature-worktree>
# prune stale worktree refs
git worktree prune
If state is OPEN or CLOSED (without merge): something else went wrong.
The worktree error is masking a real failure. Re-run the merge with --admin
or check branch protection / required checks.
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.
- 3mo ago First seen · 305 lines · 497 tokens per session scan A e11bdf74a304
gh-pr-merge-worktree-checkout-trap is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (5 stars, last pushed yesterday), licensed MIT. It adds 497 tokens to every session and 3,765 once invoked, about $0.0020 per session on Opus 5.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.
gh-pr-merge-worktree-checkout-trap compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| gh-pr-merge-worktree-checkout-trapwan-huiyan/agent-traffic-control | Skill | 5 | yesterday | MIT | A | 497 | Claude Code |
| ql-housekeepandyzengmath/quantum-loop | Skill | 24 | 5mo ago | MIT | A | 57 | Claude Code |
| nazgul:doctorOrodruinLabs/nazgul | Skill | 7 | 3mo ago | none | A | 151 | Claude Code |
| hotfixIdoCohen560/claude-unity-game-studio | Skill | 30 | 4mo ago | MIT | A | 35 | Claude Code |
| cloudflare-workers-ci-cdsecondsky/claude-skills | Skill | 257 | 3d ago | MIT | A | 50 | Claude Code |
| cloudflare-workers-observabilitysecondsky/claude-skills | Skill | 257 | 3d ago | MIT | A | 47 | Claude Code |
| cloudflare-workers-dev-experiencesecondsky/claude-skills | Skill | 257 | 3d ago | MIT | A | 47 | Claude Code |