/agent-traffic-control:shell-pinned-to-deleted-worktree-cwd-blocks-gitfrom agent-traffic-control
Diagnoses + recovers the "every shell command now fails `fatal: Unable to read current working directory: Operation not permitted`" trap, which appears AFTER a git worktree you were running commands in gets removed/pruned mid-session (you merged + deleted its branch, ran `git worktree remove`, or the Claude Code harness auto-cleaned a merged/unchanged worktree). Use when: (1) git AND python both error `Operation not permitted` / `PermissionError: [Errno 1] Operation not permitted` on startup; (2) `cd /valid/abs/path && pwd` PRINTS the valid path but the very next `git`/`python` in the SAME command still fails (pwd lies); (3) the harness prints "Shell cwd was reset to <some-.claude/worktrees/...>" after each Bash call; (4) `git -C /repo`, recreating the dir with `mkdir`, `python3 -c "import os; os.chdir(...)"`, and even `dangerouslyDisableSandbox` all still fail. Core fact: the shell's kernel cwd is a DELETED directory the OS won't resolve, and zsh `cd` updates `$PWD` without a real `chdir()`, so no subprocess can escape it. The Write/Edit tools still work (absolute paths, no cwd) — so you can finish authoring files; only git/subprocess work is blocked, and must move to a fresh shell. Prevention: don't delete/auto-clean the worktree you're shell-active in until its git work is done.
Trending skills
7-day visitors to each skill page
Ships in agent-traffic-control. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Mid-session, a git worktree that your Bash shell is running inside gets removed — you squash-merged
git worktree remove, or (most insidiously) the Claude Code harness
auto-cleaned the worktree after the branch merged. From that point, every Bash command's git
or python invocation fails:fatal: Unable to read current working directory: Operation not permitted
or, from Python:
PermissionError: [Errno 1] Operation not permitted
The shell's kernel working directory is now a deleted directory the OS (macOS especially)
refuses to resolve via getcwd(). Every subprocess inherits that broken cwd at startup and dies
before doing any work.
Unable to read current working directory: Operation not permitted on git, and
PermissionError: [Errno 1] Operation not permitted on python — at startup, before any real work.pwd lies. cd /valid/absolute/path && pwd prints the valid path, but a git/python in the
same && chain still fails. This is the diagnostic fingerprint: zsh's cd updated its internal
$PWD variable (so the builtin pwd reports the new path) but did not perform a successful
chdir() syscall — it getcwd()'d the dead dir first (for $OLDPWD tracking) and aborted the real
chdir. So child processes still inherit the dead kernel cwd..claude/worktrees/<x>, the PR merged, the branch
was deleted, and the worktree got pruned — pulling the rug out from under your own shell.You cannot recover git/subprocess use from this shell. Stop trying — these all FAIL (verified):
cd /valid && git … — cd updates $PWD only, no real chdir.git -C /repo … — git still getcwd()'s its own process cwd at startup, fails.mkdir -p <the-deleted-path> then cd — recreates the path with a NEW inode; the shell holds a
handle to the OLD deleted inode, so getcwd() still fails (pwd then prints .).python3 -c "import os; os.chdir('/valid'); import subprocess; …" — Python's import machinery
getcwd()'s the dead cwd (path-importer cache) and raises PermissionError before/around your chdir.dangerouslyDisableSandbox: true — it's a kernel cwd problem, not a sandbox-policy problem.What still works: the Write / Edit tools use absolute paths and do NOT touch the shell cwd. So:
cd /abs/repo && git … recipe to run in a new terminal (a fresh
shell spawns with a valid cwd), or to type it with the ! prefix in Claude Code (that runs in
their interactive session, often at a valid cwd), orgh also needs cwd, so use the user's terminal or a prior gh pr view
result) rather than local git.cd /valid/abs/path && pwd && git status — pwd prints the valid path,
git status errors Operation not permitted. That combination = this trap (not a real repo/perm
problem).pwd returns a real absolute path AND git status runs — recovered.S264d (2026-06-20): built the Explorer redesign in .claude/worktrees/explorer-redesign, squash-
merged PR #1265, the branch was deleted, and the harness pruned the worktree. Every subsequent Bash
command failed Unable to read current working directory. Tried (all failed): cd primary && git,
git -C primary, mkdir -p the dead path + cd, python3 -c "import os; os.chdir(...)",
dangerouslyDisableSandbox. The merged code was safe on main (0dd47e77, verified via an earlier
gh pr view). Wrote the two handoff docs with the Write tool (absolute paths — worked), and
handed the git checkout -b … && git add … && git commit && git push && gh pr create step to the
user for a fresh terminal.
pwd-lies symptom — without it you'd assume a permissions/sandbox bug
and waste attempts on chmod/sandbox flags. The real cause is a deleted cwd, full stop.safe-bulk-worktree-branch-cleanup, recover-killed-session-from-transcript-and-worktree
(sibling worktree-lifecycle skills; this one is specifically the deleted-cwd-blocks-subprocess trap).What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control118 skills in this plugin
/agent-refusal-with-evidence-beats-literal-complianceA dispatched agent that does exactly what you asked can ship a defect you would
have stopped yourself, because it can see something at the worksite that you
could not see when you wrote the brief. Use when: (1) you are writing a brief
that prescribes a specific fix, threshold, wording or value rather than the
outcome you want; (2) an agent reports that it did not do what you asked and
you are deciding whether that is insubordination or judgement; (3) an agent
asserts "this is fine" or "not needed" with no measurement behind it; (4) you
are reviewing overnight output and want to know which decisions were checked
and which were assumed. Two halves, and both are needed: give the agent
explicit permission to satisfy the INTENT of an instruction while refusing its
letter, and REQUIRE the evidence with the refusal — what it built or measured,
what that showed, what it did instead. Evidence is the whole difference between
a refusal you can bank and one you have to re-litigate. Four agents correctly
declined an instruction in a single run; one built the suggested fix, measured
that it turned a silent safe refusal into a permanently red pipeline, and
reverted it unpushed.
/auto-merge-rearms-while-agent-live-kill-then-disarm-verifyDisarming auto-merge on a PR whose agent is still running does not hold it —
the agent re-arms within minutes and the PR merges, because arming is a step in
the agent's brief and disarming is not an instruction to the agent at all. Use
when: (1) you want to STOP a pull request from merging that an agent opened and
armed, for review, for a rethink, or because it is landing into a queue you are
trying to drain; (2) a PR you disarmed merged anyway; (3) you are telling agents
which PRs are on hold and want the hold to be enforced rather than announced;
(4) you are about to run `gh pr merge --disable-auto` and have not decided what
to do about the agent. The order is KILL THE AGENT FIRST, THEN DISARM, THEN
VERIFY the disarm by reading `autoMergeRequest` back — a disarm you did not read
back is not a hold. The stronger form needs no ordering at all: convert the PR
to a draft with `gh pr ready --undo`. A draft cannot merge whatever any agent
does to it, so the hold survives an agent you missed, an agent that restarts,
and an agent you did not know about.
/batch-member-cites-a-path-only-a-non-member-addsYou wrote something correct that the default reader cannot reach: a batch member citing a
path only a NON-member adds, or a rule, ruling or ledger sitting on an unlanded branch.
/batch-merge-subject-is-not-evidence-a-member-landedYou are about to close, delete the branch of, or mark as landed a pull
request because a batch, roll-up or merge-train commit on the target branch
names it in the subject line, and because the member's own commits all
predate that merge by wall clock. Neither of those is evidence. A batch
branch is assembled at some moment BEFORE it merges, so anything the member
pushed after assembly is outside it, and the subject records INTENT at
assembly time rather than CONTENT at merge time. Use before closing a
member, when an ancestry check against a squashed batch says no, or when a
member's branch still shows commits ahead of the target. Compare file
content against the target branch instead, expecting exactly one legitimate
difference: the shared aggregate file every member appends to.
/check-a-stale-branch-is-not-undoing-newer-main-workA branch built on an out-of-date main is about to merge, or has merged, and may undo work
that landed since. Use when a green, conflict-free PR deletes files you never touched,
newer values or a whole redesign vanish after a sibling PR merged, rows of a shared ledger
(tracker, registry, CHANGELOG) disappear or revert, or when `git diff main...HEAD` or a
reviewer says your small PR touches dozens of files you did not change.
/ci-leg-skipping-moves-minutes-it-does-not-remove-themYou are about to propose, price or approve a CI cost saving that works by
making a job or matrix leg SKIP on pull requests — a path filter, a safe
list, a changed-files gate, an exemption list. Check first whether the
pipeline runs a complement or backstop on merge, on push, or nightly:
many do, and then the legs a pull request skipped are exactly the legs some
later run executes, so a branch that goes green once and merges bills the
same total either way and the wall clock does not move at all. Use when
pricing a filter change, when a percentage saving is quoted with no basis,
or when choosing between filtering legs and batching pull requests. The
question that separates money from bookkeeping is whether the change
removes RUNS or merely moves LEGS.