worktree-isolation-guard-refuses-complex-bash
In a Claude worktree-isolated session a guard (e.g. worktree isolation) refuses Bash calls it cannot prove stay inside the worktree ('redirects git to the shared checkout via -C', 'too complex to verify', 'runs a string through .', 'command whose name is computed at runtime'), including heredoc appends and a sqlite3 call inside a construct too complex to verify. Use when a Bash call is refused in a worktree session or when writing commands for a session that runs in .claude/worktrees.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- worktree-isolation-guard-refuses-complex-bash
- description
- In a Claude worktree-isolated session a guard (e.g. worktree isolation) refuses Bash calls it cannot prove stay inside the worktree ('redirects git to the shared checkout via -C', 'too complex to verify', 'runs a string through .', 'command whose name is computed at runtime'), including heredoc appends and a sqlite3 call inside a construct too complex to verify. Use when a Bash call is refused in a worktree session or when writing commands for a session that runs in .claude/worktrees.
03 SKILL.md 正文
Worktree isolation guard: write commands it can verify
Symptom
Refusals that end Refusing to run it:
this command redirects git to the shared checkout via -Cthis command is too complex to verify that it stays inside the worktreeruns a string through ., which can't be verified to stay inside the worktree- a command whose name is computed at runtime (
$cmd ...)
Triggers seen: git -C <main checkout>, && chains, eval, source,
heredoc appends (a KNOWN_ISSUES.md append), and a sqlite3 call wrapped
in a construct too complex to verify. A user's own ! command also failed
with The command failed and the error text was withheld.
Later variants:
- a path or
cdinto a directory namedeval(runs a string through eval) - a
$VAR/computed path as a node/python argument - a
cat > f <<EOF … && python3 …heredoc chain (too complex to verify that it stays inside the worktree) - a
forloop whose arguments contain "git" (names git in a form too complex to verify)
Root cause
A worktree isolation hook statically parses each Bash command and rejects anything
it cannot prove touches only the worktree. Agents reach for habitual
compound forms; advice also conflicted across sessions (some said use
git -C, which is exactly what the guard forbids).
Fix
- One plain command per call, run from the worktree cwd, literal command
names. No pipes,
&&chains,eval,sourceor heredocs. - Never
git -C <other path>and never touch the shared checkout. - File content goes through Write/Edit, not shell appends or heredocs.
- To act on the main checkout, ask the user to run single commands (one
per
!line), or to use a separate Terminal window. Acd … && git …chain failed in practice and contradicts rule 1. - A
!command that fails with withheld output: have it write a log file inside the worktree, then Read the log.some-command > .scratch/out.log 2>&1 - Use literal absolute paths (no
$VAR/computed paths as arguments) and nocd. Write scripts with the Write tool and run the file. If the guard false-positives on a literal directory namedeval, a glob avoids the text match while still naming the same directory:node --test "/abs/path/to/worktree/plugins/<pkg>/ev[a]l/…". The quoted glob is expanded bynode --testitself (Node 21+), not by the shell. For other commands, use the unquoted form so the shell expands it:ls /abs/path/to/worktree/plugins/<pkg>/ev[a]l/. - The guard's pattern match is text-based and inconsistent: the same command can pass in one session and be refused in another. Treat a refusal as a signal to simplify, not as proof the command was unsafe.
- After a refusal, retry the simple form. Do not reword the same compound command to slip past the guard; the only exception is the literal-name false positive in item 6.
Evidence
Mined from session digests; about 6 sessions across 3 projects found
independently: a private-project worktree e9097288 (the -C refusal), a
private document-scanner app ea9bc432 (string through .), a
private-bot worktree bb35f1a6 (too complex to verify), a private bot
c2a681f5 (withheld error text).
Related skills
superpowers:using-git-worktrees— how worktree sessions are set up.core-workflow:xcode-license-blocks-git-exit-69— another git failure that is environmental, not a code problem.core-workflow:blast-radius-rm-hold-unattended-subagent-stall— the sibling hook that holdsrm.
04 同仓库更多 Skills
second-wind
Orchestrate long unattended Claude Code runs across multiple repos with the wind CLI. Use when the user wants to run Claude Code overnight, resume sessions after the 5-hour usage limit, run Claude in many repos at once via tmux, or says "set up second wind", "wind up", "overnight run", "resume after limit", "usage limit orchestrator".
structured-output-adaptive-thinking-token-bloat
A Claude API call using output_config.format (json_schema structured outputs) with thinking:{type:"adaptive"} burns most of its output budget on thinking (observed ~21k of ~24k tokens) without improving JSON quality, making the run up to ~5x more expensive than the same call with thinking omitted — use when calling the Messages API with a json_schema output format for extraction, ranking, classification, or summarization tasks, or when a schema-constrained call's usage.output_tokens is far larger than the returned JSON.
review
Apply a code-review lens to a diff, branch, or file — find correctness bugs, security issues, and quality problems, ranked by severity, with a concrete fix for each. Use when the user says "review this", "review my diff", "check this PR", "look this over before I commit", or "is this safe". Skip when the user wants the code written, not reviewed.
refresh
Rebuild the prompt-craft command registry and usage profile, and print a summary of installed commands and your personalized recommendations. Use when you install or update plugins and want the advisor to pick them up immediately, or say "refresh prompt-craft", "rebuild the command registry".
refactor
Apply a refactoring lens — restructure code without changing behavior, guarded by tests that pass before and after. Use when the user says "refactor", "clean this up", "extract this", "simplify this", "reduce duplication", or "make this readable" on existing working code. Skip when the change is meant to alter behavior (that's a feature or a fix).
plan
Decompose a non-trivial task into an explicit, tracked plan with goals and per-step acceptance criteria before writing code. Use when the user says "plan this", "break this down", "what's the plan", or asks for a multi-step feature/refactor that touches more than one file. Pairs with plan mode. Skip for single-edit changes that need no decomposition.