Skip to content

fix: close sibling-worktree loophole in already-inside path - #1153

Closed
arittr wants to merge 1 commit into
add-worktree-consent-stepfrom
fix-sibling-worktree-loophole
Closed

arittr wants to merge 1 commit into
add-worktree-consent-stepfrom
fix-sibling-worktree-loophole

Conversation

@arittr

@arittr arittr commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

What problem are you trying to solve?

The using-git-worktrees skill's "already in a linked worktree" detection branch had a subtle loophole: agents would correctly refuse to nest a new worktree, but would then offer alternatives to the user — including "exit to the main repo and create a sibling worktree for signup there" — and execute the sibling option when the user accepted.

Drill scenario worktree-already-inside-spec-aware intermittently surfaced this (1 failure in 5 recent runs). Session log from the failing run:

Agent (turn 3): "GIT_DIR != GIT_COMMON and not a submodule — I'm already in a linked worktree. Per the skill, I must skip worktree creation and not nest another one. [...] You have three options: 1. Build signup here on existing-feature, 2. Build signup here on a new branch, 3. Create a sibling worktree — exit to the main repo and create a separate worktree for signup there. Which do you want?"

Agent (turn 4): executes option 3 — git -C "$MAIN" worktree add .worktrees/signup -b signup. Reports "Worktree ready at .worktrees/signup on branch signup."

The original directive "Do NOT create another worktree" was being read as "don't NEST another worktree." A sibling worktree created from the main repo is technically not nesting, so the agent considered itself compliant with the directive.

What does this PR change?

Tightens the already-inside-worktree block in using-git-worktrees/SKILL.md to be unambiguous about creation:

  • Current workspace is your working environment — use it for whatever the user asked about
  • No alternatives, no creation: not as nested, not as sibling, not anywhere else
  • If the user does insist on different isolation for unrelated work, the agent must stop and ask the user to exit this workspace and re-invoke the skill from the main repo themselves — not create siblings on their behalf

Is this change appropriate for the core library?

Yes. This is a correctness fix to a core workflow skill. The loophole exists in the original using-git-worktrees text and persists through the add-worktree-consent-step (#1124) rewrite, so it applies regardless of which design iteration ships.

What alternatives did you consider?

  1. A softer rewrite allowing sibling creation with explicit consent — rejected. Allowing siblings creates the loophole again in a different form.
  2. Fixing this on enhance worktree consent during implementation (PRI-974) #1124 as a 4th commit — rejected because it would muddy enhance worktree consent during implementation (PRI-974) #1124's "consent inversion" review narrative. This fix is a separate concern stacked above enhance worktree consent during implementation (PRI-974) #1124.
  3. Filing as an issue and deferring — rejected because the fix is small, targeted, and the evidence was fresh.

Does this PR contain multiple unrelated changes?

No. Single-paragraph edit to one block in one file, +5/-1.

Existing PRs

Environment tested

Harness Harness version Model Model version/ID
Claude Code latest Claude Opus 4.6 claude-opus-4-6

Evaluation

Drill harness validation on the two already-inside scenarios, 3 runs each:

Scenario Pre-fix Post-fix
worktree-already-inside baseline PASS ✅ 3/3 PASS
worktree-already-inside-spec-aware 4/5 (80% — loophole triggered 1 time) ✅ 3/3 PASS

6 runs, 18/18 criteria passed. One post-fix run observed the agent still offering options, but the sibling-worktree option was gone — replaced by "exit and re-invoke from main repo" (the correct behavior per the new wording). Scenario passed because no worktree was created.

Rigor

  • If this is a skills change: I used superpowers:writing-skills and completed adversarial pressure testing (drill harness)
  • This change was tested adversarially, not just on the happy path
  • I did not modify carefully-tuned content (Red Flags table, rationalizations, "human partner" language) without extensive evals showing the change is an improvement

Human review

  • A human has reviewed the COMPLETE proposed diff before submission

@arittr

arittr commented Apr 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Drill scenario worktree-already-inside-spec-aware revealed a latent
skill loophole: agents detecting existing isolation would correctly
refuse to nest a worktree, but then offer options — including exiting
to the main repo and creating a sibling worktree from there — and
execute the sibling option when the actor accepted.

The prior wording "Do NOT create another worktree" got read as
"don't NEST another worktree," leaving sibling creation as an
apparently-legal workaround that satisfied the agent's interpretation
of the directive while violating the skill's actual intent (use the
current workspace, period).

Fix: tighten the already-inside block to be explicit:
- Current workspace is the working environment, use it
- No alternatives, no creation — not nested, not sibling, not anywhere
- If the user genuinely needs different isolation for unrelated work,
  they have to exit the current workspace themselves

Validation pending via drill reruns of worktree-already-inside and
worktree-already-inside-spec-aware on this branch state.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant