Skip to content

fix(worktrees): guard worktree creation, branch finishing, and executor workspace lifecycle - #2736

Open
arittr wants to merge 28 commits into
devfrom
fix/wave1-worktree-finish-safety
Open

arittr wants to merge 28 commits into
devfrom
fix/wave1-worktree-finish-safety

Conversation

@arittr

@arittr arittr commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Who is submitting this PR? (required)

Field Value
Your model + version Gemini 4 Carbon (High)
Harness + version Antigravity CLI 1.5.16 (via Paseo)
All plugins installed superpowers, dealerboard, toolsmith
Human partner who reviewed this diff Drew Ritter (@arittr)

What your human partner asked you to do, in their words:

Land the settled worktree, branch-finishing, and executor workspace/finish safety bug fixes onto dev as a focused PR with deterministic git-mechanics tests, preserving all guard tables and option menus.

Human-authored summary (required, under 200 words)

Several of our nastiest open bug reports are data-loss bugs around worktree setup and branch cleanup, and the existing community PRs each only touch one piece of the lifecycle in isolation. Right now, finishing a branch can treat a worktree with .env.local, brainstorm mockups, or an aborted SDD run as "clean" and wipe those files on removal, MAIN_ROOT breaks on bare repos and submodules because of $(git rev-parse --git-common-dir)/.., and checkout/merge can overwrite ignored local files in the main checkout. Meanwhile, both plan executors delete .superpowers/sdd/<plan>/ at Finish before finishing-a-development-branch ever runs, throwing away rulings and deferred findings that git log doesn't record.

This PR fixes that lifecycle end-to-end: using-git-worktrees verifies native worktree base commits and uses a self-ignoring <dir>/.gitignore instead of making unrequested commits, executors keep completed workspaces and mark progress.md with finish after reporting all rulings, and finishing-a-development-branch inventories unique/ignored files and guards merges with --no-overwrite-ignore.

What problem are you trying to solve?

Fixes #1108, fixes #2207, fixes #2397, fixes #2515, fixes #2706.
Addresses part of #2177, #2245, #2253, #2344.

finishing-a-development-branch:

executing-plans and subagent-driven-development:

using-git-worktrees:

What does this PR change?

  • skills/finishing-a-development-branch/SKILL.md:
    • Adds Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's section "Never-committed files are not yours to delete", its Step 2 listing (git status --porcelain -uall when GIT_DIR != GIT_COMMON), its edits to Step 6's refusal recipe (stop cleanup, a new prompt, four options, "No answer means option 4"), and its five rationalization rows, verbatim.
    • After Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's Step 2 listing, a paragraph lists ignored files from the top of the worktree with git status --porcelain --ignored=matching -unormal and git ls-files --others --ignored --exclude-standard -- .superpowers. Each !! entry counts as a listed file; under .superpowers/ the second command decides. It leaves out only .superpowers/sdd/.gitignore, the brainstorm .last-port and .last-token files, and dependency and build caches such as node_modules/ and .venv/. A plan workspace still present stays listed.
    • Option 2: if a plan executor's final message listed deferred minors or parked findings, copy them into the PR description under "Deferred items".
    • Step 6: the worktree directory your instructions declare counts as owned, here and in the "This other worktree looks stale" rationalization row. A sentence above the removal block says to run it only when both Step 2 listings, run again, list no files. After Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's menu, a paragraph says an ignored file is never committed or force-added, so only options 2, 3 and 4 apply to it, and that the listings run again after options 1 to 3.
  • skills/executing-plans/SKILL.md: adds Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's "Never on main" paragraph, its "Branch before your first edit" paragraph after dev's two Setup sentences, and its rationalization row, verbatim. Two sentences replace the todo instructions: "Track progress in a ledger file. If you have a todo tool, also keep a todo per task as a live view; the ledger is the record." The lines that said to create a todo per task and mark it in progress or complete are removed, and the process graph's task-done label no longer says "mark todo complete". The git clean -fdx note now reads "recover the completed tasks from git log. Rulings and deferred minors are not in git: they are lost."
  • skills/subagent-driven-development/SKILL.md: Setup gains "Before you dispatch Task 1, read references/branch-guard.md and follow it." The same todo sentences, todo-line removals, graph-label change and git clean -fdx note as executing-plans. The file is 19,869 bytes; Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's paragraph inline would take it past the 20,000-byte limit that tests/skill-size/test-skill-size.sh enforces.
  • skills/subagent-driven-development/references/branch-guard.md (new): a heading and a two-line opening paragraph, then Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's SDD paragraph and rationalization row, verbatim.
  • skills/subagent-driven-development/references/final-review.md: Finish also lists every minor (deferred) ledger line under "Deferred minors", in executing-plans' words. The workspace is still deleted afterwards, as on dev.
  • skills/using-superpowers/references/claude-code-tools.md: the nested orchestrator's final message carries the "Rulings I made" and "Deferred minors" lists verbatim, and the parent relays both.
  • skills/using-git-worktrees/SKILL.md:
    • Step 0 also records START_HEAD (or unborn), prints the four values, and says to keep the printed START_HEAD and BRANCH visible. The false submodule sentence is deleted; the rest of that line stays.
    • Step 1a names EnterWorktree or create_worktree as examples, says to pass <START_HEAD> as the base when the tool accepts one, says to work in the new worktree's path (Codex create_worktree returns a path and needs get_worktree_creation_status polling), and adds a base check, skipped when START_HEAD is unborn, with four outcomes: at the start commit, continue; behind it, git merge --ff-only <START_HEAD>; ahead of it with origin/HEAD at origin/<START_BRANCH>, continue; anything else, stop and ask, and if the answer is <START_HEAD>, switch the worktree to it.
    • Safety Verification runs : "${LOCATION:?set LOCATION to the directory you selected above}" and then git check-ignore -q "${LOCATION%/}/".
    • The creation snippet's path variable is renamed worktree_path.
    • Step 2 runs poetry install only when poetry.lock exists or pyproject.toml has a [tool.poetry] table.
  • tests/claude-code/test-worktree-finishing-mechanics.sh (new, registered in the fast list in tests/claude-code/run-skill-tests.sh): eight cases. Each extracts a fenced block from using-git-worktrees or finishing-a-development-branch and runs it in a throwaway repository: ignore_check_uses_selected_dir, ignore_check_needs_location, base_check_states, creation_snippet_keeps_path_under_zsh (skipped when zsh is absent), poetry_install_only_for_poetry_projects, listing_shows_ignored_and_untracked, removal_waits_for_ignored_files, removal_refuses_untracked.
  • tests/claude-code/test-subagent-driven-development-integration.sh: Test 3 (task-tracking tool used) prints [INFO] instead of failing when no such tool was used, and its count no longer produces 0\n0. The header comment that listed that assertion is removed.

Is this change appropriate for the core library?

Yes — these four skills form the core workspace-isolation, plan-execution, and branch-integration lifecycle used across every Superpowers project and harness, with zero third-party dependencies.

What alternatives did you consider?

  1. Keeping this PR's first version and fixing the review's findings on top: rejected. That version rewrote large parts of finishing-a-development-branch and using-git-worktrees (primary checkout from git worktree list, --no-overwrite-ignore, fetch and fast-forward instead of git pull, .claude/worktrees/ ownership with ExitWorktree, a self-ignoring .gitignore inside the worktrees directory instead of a root .gitignore commit, --no-track, a one-sentence dependency setup). No cited issue asks for those changes, so they returned to dev's text, and the review findings about them went with them.
  2. Keeping the plan workspace after Finish and marking it with a finish line (this PR's first version): rejected. dev's lifecycle stays: the workspace is deleted at Finish, and the export is completed instead (SDD's final message lists deferred minors, and Option 2 copies deferred items into the PR description).
  3. Listing only the deferred minors the final fix wave did not fix: rejected. SDD's ledger does not record which minors the fix wave fixed, so after compaction the filter would rest on the controller's memory. Finish lists every minor (deferred) line, as executing-plans does.
  4. Editing Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's Step 2 command and menu to cover ignored files: rejected, so that Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's measured text stays checkable character for character. The ignored-file handling sits in separate paragraphs beside it.
  5. Taking Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's worktree-guard hook: not taken. It needs python3, and the plugin has no dependencies. Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707 reports that the hook never fired in its fixed runs.
  6. Putting Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's SDD paragraph inline in subagent-driven-development/SKILL.md: not possible under the 20,000-byte limit, so it moved whole to references/branch-guard.md, the way Setup already points to references/preflight.md and references/resuming.md.
  7. Taking fix: detect Python package manager before poetry install in worktrees #2204's whole Python block (uv sync first, then Poetry, then pip): not taken. Only its Poetry condition is needed for fix: using-git-worktrees skill runs for all pyproject.toml projects, breaking non-Poetry setups #1108; the other lines of dev's setup block are unchanged.

Does this PR contain multiple unrelated changes?

Partly. Most of it is one lifecycle: creating a worktree (using-git-worktrees), starting a plan on a branch rather than main and exporting what the plan left undone (both executors), and finishing without deleting files that exist nowhere else (finishing-a-development-branch). The finishing and executor changes for #2706 come from one measured fix, #2707, and the #2253 changes span SDD's Finish, the Claude Code relay rule and finishing's Option 2. Three changes do not depend on the rest and could be reviewed separately: the conditional todo sentence (#2177), the Poetry condition (#1108), and the zsh path rename.

Existing PRs

Environments tested

Harness (e.g. Claude Code, Cursor) Harness version Model Model version/ID
Antigravity CLI 1.5.16 (via Paseo) Gemini 4 Carbon Gemini 4 Carbon (High)
Claude Code 2.1.325 Claude Opus 5.5 (changes), Claude Fable 5.2 (review) claude-opus-5-5, claude-fable-5-2

New harness support (required if this PR adds a new harness)

N/A — does not add support for a new harness.

Evaluation

  • Initial prompt: Audited and fixed confirmed data-loss and cleanup bugs across the worktree, executor Finish, and branch-finishing lifecycle against dev.
  • Eval sessions after the change: none. No coding-agent session has exercised the changed skill text on this branch.
  • Checks run at the final head, 4008e63, on macOS with /bin/bash 3.2.57, git 2.54.0, zsh 5.9 and shellcheck 0.11.0:
    • bash tests/claude-code/test-worktree-finishing-mechanics.sh: exit 0, 37 PASS, 0 FAIL, STATUS: PASSED.
    • bash tests/claude-code/test-worktree-path-policy.sh: exit 0, 9 PASS. It also prints two grep: .../docs/superpowers/plans/2026-04-06-worktree-rototill.md: No such file or directory lines, as it does on dev; that file does not exist on dev, and this PR changes neither the test nor docs/.
    • bash tests/claude-code/test-sdd-workspace.sh: PASS, exit 0.
    • bash tests/claude-code/test-executing-plans-scripts.sh: PASS, exit 0.
    • bash tests/sdd-helper-paths/test-sdd-helper-paths.sh: "PASS: all 14 relative helper references under skills/ say to run them by absolute path", exit 0.
    • bash tests/skill-size/test-skill-size.sh: "PASS: every SKILL.md is under 20000 bytes", exit 0.
    • bash scripts/lint-shell.sh --strict tests/claude-code/test-worktree-finishing-mechanics.sh: exit 0.
    • git diff --check df2e996a HEAD: no output, exit 0.
    • bash scripts/lint-shell.sh --strict tests/claude-code/test-subagent-driven-development-integration.sh: exit 1, SC2064 at line 39 (trap "cleanup_test_project $TEST_PROJECT" EXIT) and SC2320 at line 169 (echo "EXECUTION FAILED (exit code: $?)"). Both lines are as on dev, and dev's copy of the file fails the same way. No line this PR changes draws a warning.
    • bash -n tests/claude-code/test-subagent-driven-development-integration.sh: exit 0.
    • bash tests/skill-layout/test-no-dev-files-in-skills.sh: "PASS: no skill ships pressure scenarios or creation logs", exit 0.
  • Not run: tests/claude-code/test-subagent-driven-development-integration.sh, tests/claude-code/run-skill-tests.sh and test-worktree-native-preference.sh, because they start agent sessions.
  • Planned before merge: the five finishing-branch-* scenarios in superpowers-evals with dev as the control, and finishing-a-development-branch deletes never-committed worktree files during "merge and clean up" (24/24 runs); executing-plans commits to main without consent (21/21). Fix attached, 0/21 after. #2706's fixtures run against both executors.
  • Before/after outcome: at the level of the snippets the tests run. On dev, the using-git-worktrees ignore check passes when only the unselected directory is ignored and fails for an ignored .worktrees/ that does not exist yet; on this branch it gets both right, and it stops with a message when LOCATION is unset. On dev, Step 1a has no base check; on this branch the check's output tells apart a worktree at, behind, ahead of, and diverged from the start commit. On dev, nothing in finishing-a-development-branch lists a linked worktree's ignored files (.env.local, an SDD workspace, brainstorm mockups), and Step 6's git worktree remove deletes them with exit 0; on this branch its Step 2 lists them and Step 6 says not to run the removal while anything is listed. The using-git-worktrees Step 2 setup no longer calls poetry install for a pyproject.toml with no [tool.poetry] table and no poetry.lock. The creation snippet no longer breaks PATH under zsh. Whether agents follow the new prose (branching off main, asking before deleting files, listing deferred minors) has not been measured on this branch. Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707 reports, on Cursor CLI with composer-2.5, 0 of 21 runs deleting the files (with its hook installed, which never fired; 0 of 9 with the skill text alone) and 0 of 21 runs committing to main.

Rigor

  • If this is a skills change: I used superpowers:writing-skills and
    completed adversarial pressure testing (paste results below)
  • 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

This PR changes skill text, and no pressure testing with agents was done. The adversarial testing is of the shell snippets the skills contain, in throwaway repositories (status.showUntrackedFiles=no, a root .gitignore that ignores .superpowers/, an unset LOCATION, a diverged base, zsh), not of agent behavior.

This PR changes rationalization tables and "your human partner" wording; it changes no Red Flags table:

#2707's rows and Step 6 text come with #2707's measurements of finishing-a-development-branch and executing-plans; its subagent-driven-development text was not measured. The stale-worktree row edit and the relay-rule edit have no eval.

The original diff had an independent review by several reviewers. A hunk-by-hunk ledger then compared every hunk with dev and kept it only where a cited issue, a confirmed review finding, a statement verified false, or Drew's decision (the zsh path rename) required it; the rest returned to dev's text. Separate reviewers checked the rebuilt branch against that ledger in three parts and re-ran the tests: using-git-worktrees at 5ce518f, the executors at a4bace3, and finishing-a-development-branch at d46d5e3. The four commits after d46d5e3 (the LOCATION guard, the Poetry test, SDD's "Before you dispatch Task 1" trigger, and the "Deferred minors" wording) came after that review; the tests listed above were run after them. Each new or changed test was checked to fail without its fix:

  • ignore_check_uses_selected_dir: fails with dev's check on both using-git-worktrees: ignore check passes when only the non-selected directory is ignored #2515 cases (exit 0 where only worktrees/ is ignored, exit 1 for an ignored .worktrees/ not yet created), and the second case fails with the trailing slash dropped.
  • ignore_check_needs_location: fails before the LOCATION guard (exit 128, fatal: /: '/' is outside repository).
  • base_check_states: fails with Step 1a as on dev (no base-check fence) and with only the two added Step 0 lines removed; swapping the start-ahead operands fails its "behind" and "ahead" assertions.
  • creation_snippet_keeps_path_under_zsh: fails with dev's path= (exit 127, zsh:4: command not found: git); prints [SKIP] when zsh is not installed.
  • poetry_install_only_for_poetry_projects: fails with dev's if [ -f pyproject.toml ]; then poetry install; fi on a pyproject.toml with only a [project] table.
  • listing_shows_ignored_and_untracked: fails with dev's skill (16 failures), with Keep never-committed worktree files during cleanup; branch before executing a plan on main #2707's text but before the ignored-file paragraphs (9), without the git ls-files ... -- .superpowers line (4, the plan workspace in each fixture and the mockup when the root .gitignore ignores .superpowers/), and without -unormal (1, fatal: Unsupported combination of ignored and untracked-files arguments).
  • removal_waits_for_ignored_files: its listing assertion fails without the ignored-file paragraph. Its removal assertion pins git's own behavior (plain git worktree remove deletes an ignored .env.local with exit 0), so no skill revert can fail it.
  • removal_refuses_untracked: pins git's refusal on an untracked file; it fails when Step 6's block is changed to git worktree remove --force.
  • Integration test, Test 3: not run, because it starts an agent session. Its lines alone, run on a one-line transcript with no todo tool call, give integer expression expected and [FAIL] in dev's form, and [INFO] with clean output in this PR's form.

Human review

  • A human has reviewed the COMPLETE proposed diff before submission

@arittr
arittr force-pushed the fix/wave1-worktree-finish-safety branch from 0d958ee to b8b21f9 Compare November 24, 2026 22:58
@arittr
arittr added this pull request to stack #2747 November 24, 2026 23:29
arittr and others added 13 commits November 25, 2026 00:39
…ue requires a change

Every hunk of this PR in using-git-worktrees/SKILL.md goes back to dev's
text: the sandbox paragraph and its Quick Reference row, the placeholder
rewrite of the creation snippet and --no-track, the self-ignoring
.gitignore, the one-sentence replacement of the setup block, the reworded
rationalization row, and the rewritten Step 0 lines. No cited issue needs
them. The edits that #2515, #2245 and #1108 do need, and the correction of
the false submodule sentence, are made on dev's text in the commits that
follow.

The 1,213-line mechanics test pinned about 180 strings of the rewritten
prose. It is removed here and replaced, at the same path, by a short test
that extracts the skill's snippets and runs them in throwaway repositories.
Its line in run-skill-tests.sh stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… with a trailing slash

Safety Verification passed when either `.worktrees` or `worktrees` was
ignored, so with both present and only `worktrees/` ignored, the worktree
went into an unignored `.worktrees/` (#2515). The check now covers only the
directory Directory Selection chose, using the same `$LOCATION` as the
creation snippet. The trailing slash lets a directory-only pattern such as
`.worktrees/` match before the directory exists, which the reporter's
follow-up showed fails without it.

The mechanics test starts with this case: it extracts the fence under
Safety Verification and runs it on both reported repositories. Against
dev's check, both fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nst the starting commit

A native tool may create the worktree from origin's default branch, not
from the commit the work started on, so an unpushed plan is missing from
the new worktree (#2245, item 1). Step 0 now records and prints the
starting commit as START_HEAD, with the branch, so the values survive a
shell that does not keep variables between commands.

Step 1a takes the base check from the review (finding F1, which also
carries F2 and F9). After the tool runs, the agent works in the path the
tool returned, and runs four commands there. Their output picks one of
four actions: continue when the worktree is at the start commit;
fast-forward when the start commit is ahead, on any branch; continue when
only the remote was ahead; otherwise stop and ask which commit to build
on. The check is skipped when START_HEAD is `unborn`. Dev's paragraph on
what native tools handle stays as it is.

The tool-name examples lose `WorktreeCreate`, which is a settings hook
name, not a tool, and gain Codex's `create_worktree`.

The mechanics test gains base_check_states. It takes START_HEAD and the
branch from the Step 0 snippet's output, creates worktrees at, behind,
ahead of and diverged from the start commit, and checks what the Step 1a
commands print in each. Against dev's text it fails: Step 1a has no check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom GIT_COMMON in a submodule

Inside a submodule, `git rev-parse --git-dir` and `--git-common-dir`
resolve to the same directory (git 2.54: absorbed and embedded submodules,
and a submodule in a linked worktree of the superproject). Only that
sentence goes. The guard and its command stay as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Step 2 ran `poetry install` for any pyproject.toml, which fails for uv,
hatch, pdm and setuptools projects, and on machines without Poetry
(#1108). The line now runs it only when the project has a poetry.lock or a
[tool.poetry] table, the condition from #2204. The rest of the setup block
stays as it is.

Co-authored-by: y$un_ <forrest.sun527@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to worktree_path

In zsh, the `path` array is tied to PATH, so running the snippet as
written set PATH to the new worktree's directory: `git worktree add`
itself failed with "command not found: git", and so did every later
command in that shell. The variable is renamed in its three places, and
nothing else in the snippet changes.

The mechanics test gains creation_snippet_keeps_path_under_zsh. It runs
the snippet under `zsh -f`, then `git --version` in the same shell, and
checks that the worktree exists. Against dev's snippet it fails with
"command not found: git". Without zsh, the case reports a skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mechanics test's fence extractor used `[[:space:]]`, which older mawk
releases do not support. task-brief, the repository's other awk code that
reads fences, spells whitespace `[ \t]`. The extractor now does the same,
and still finds indented fences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first #2515 fixture needs `.worktrees/` to be unignored. On a machine
whose global excludes file lists `.worktrees/` (through core.excludesFile,
or the default ~/.config/git/ignore), it is ignored there too, so the
skill's check correctly exits 0 and the case reports a failure. The
fixture's repository now sets core.excludesFile to /dev/null, which
overrides both. The second fixture expects the directory to be ignored,
which a global excludes file cannot change.

Reproduced with GIT_CONFIG_GLOBAL pointing at a config whose excludes
file lists `.worktrees/`, and with an XDG_CONFIG_HOME whose git/ignore
lists it: the case failed before this change and passes after it.
Against dev's skill text, and with 8881e52's check reverted, it still
fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… text where no issue requires a change

These parts of the PR go back to dev's text in executing-plans and
subagent-driven-development: the `finish` ledger marker and the kept
workspace, so Finish deletes the plan's workspace as on dev and both
process graphs keep that step; the three-list Finish restructure; the
resume rewrite in executing-plans' Setup and in references/resuming.md;
the paraphrased main/master guard in both Setups; and `git log --oneline`
in SDD's no-bash review fallback. references/final-review.md and
references/resuming.md read as on dev.

In the SDD integration test, the trap quoting, `claude_rc` and Test 2's
count line go back to dev. Only the todo check keeps its change: it
reports instead of failing.

The PR's removal of the scattered todo steps stays. The conditional todo
sentence for #2177 and the edits that #2706, #2253 and #2344 need are made
on dev's text in the commits that follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Current Claude Code models have no task-tracking tool (#2177), so the
executors' unconditional todo steps could not be followed. This PR already
drops the scattered steps: create a todo per task, mark it in progress,
mark it complete, and the graph labels that named them. Each Setup now
says it once, conditionally: "Track progress in a ledger file. If you have
a todo tool, also keep a todo per task as a live view; the ledger is the
record." A harness with a todo tool keeps its live view; the ledger stays
the record everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both executors said that if `git clean -fdx` destroys the workspace, the
agent can "recover from `git log`" (#2344). git log holds the completed
tasks' commits, but not the rulings or deferred minors: those live only in
the git-ignored ledger. The note keeps its recovery instruction, narrowed
to the completed tasks, and says the rulings and deferred minors are lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Asked to execute a plan in a repo sitting on main, executing-plans
committed the work to main in 21 of 21 runs (#2706): Setup's "Never start
implementation on a main/master branch without your human partner's
explicit consent" did not stop it. The reporter's fix in #2707 measured 0
of 21. Its text is taken verbatim, and Jesse's two Setup sentences stay
as they are above it.

- executing-plans, inline at #2707's positions: the "Never on main"
  paragraph, "Branch before your first edit", and the rationalization row.
- subagent-driven-development: the same paragraph and row go to the new
  references/branch-guard.md, and Setup points to it the way it points to
  resuming.md and preflight.md. Inline, the paragraph alone would take
  SKILL.md to 20,354 bytes, past the 20,000-byte cap.

#2707's worktree-guard hook is not taken: it needs python3, and the
plugin has no dependencies.

Co-authored-by: Vignesh M <202531752+vigneshm1995personal@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d-orchestrator relay

SDD's Finish collected only "Rulings I made" into the final message, so
the deferred minors that task reviews logged reached the human partner
nowhere before the workspace was deleted (#2253). executing-plans already
lists them. references/final-review.md now does too, in executing-plans'
words: every `minor (deferred)` ledger line under "Deferred minors". A
minor that the final fix wave fixed is left out, because the append-only
ledger still holds its line. Finish goes on to delete the workspace as
before.

The nested-orchestrator rule in using-superpowers'
references/claude-code-tools.md tells the parent session to relay the
orchestrator's lists verbatim. It names "Deferred minors" as well as
"Rulings I made", so a parent relays both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@danishkumar26 danishkumar26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review (comment).

What this change does: Reworks the workspace lifecycle across using-git-worktrees, finishing-a-development-branch, executing-plans, and subagent-driven-development: never delete a plan's workspace on finish (append an exact finish line to /progress.md and report Rulings/Parked/Deferred instead); require a feature branch before the first edit on main/master after consent; worktree creation verifies the base commit (fast-forward clean trunk, stop-and-ask otherwise), uses --no-track and a self-ignoring /.gitignore instead of editing root .gitignore; finishing runs a Unique-File Check scoped to this worktree, never deletes uncommitted files, and removes the worktree with single --force only after typed discard. Adds tests/claude-code/test-worktree-finishing-mechanics.sh.

Nice to have:

  1. Unique-file inventory misparses renamed files (tests/claude-code/test-worktree-finishing-mechanics.sh, classify_unique_inventory)
    • What this is: Before finishing, files that exist only in the worktree are listed from git status --porcelain -uall --ignored=matching.
    • Problem: path="${line#???}" strips exactly three characters, so a rename line R old -> new becomes old -> new — a path that does not exist — and the human is asked about a phantom file.
    • Fix: after stripping the prefix, handle * -> * by keeping the destination: path="${path##* -> }".
    • If we skip it: a renamed file in the worktree produces a confusing, nonexistent "unique file" prompt at finish time.

Verdict: Ship.

Verified: read the full diff across all five skill files and references, then ran tests/claude-code/test-worktree-finishing-mechanics.sh against this branch: STATUS PASSED — all static contracts and real-git mechanics (worktree add/remove/lock, --force semantics, fast-forward base checks, diverged-upstream abort, ignored-file overwrite protection, both ignore layouts). zsh sub-cases skipped: zsh is not installed here. This repo has no CI workflows.

arittr and others added 9 commits November 26, 2026 00:35
…ue requires a change

The PR rewrote most of finishing-a-development-branch. No issue it
cites asks for the bulk of that rewrite: the compressed Steps 1-4, the
Unique-File Check and Resolve Primary Checkout sections, the
fetch-and-fast-forward merge with --no-overwrite-ignore, the
ExitWorktree step and .claude/worktrees/ ownership, the rewritten
discard path, the in-place SDD sweep, and the one-line refusal rule.

Return the whole file to dev's text. The changes the cited issues need
(#2706, #2207, #2397, #2253) follow in separate commits, each written
against dev's lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…partner decides, in #2707's words

In #2706, agents asked to merge and clean up a worktree deleted its
never-committed files in 24 of 24 runs. With PR #2707's skill text,
none did (0 of 21 with its optional hook, which never fired; 0 of 9
with the text alone).

Take #2707's four hunks for this file verbatim: the section
"Never-committed files are not yours to delete", the Step 2 listing of
files that exist only in this worktree, its edits to the refusal recipe
(stop cleanup, a fourth option, "No answer means option 4"), and five
rationalization rows. The file now matches #2707's version of it byte
for byte (blob 1585733).

Co-authored-by: Vignesh M <202531752+vigneshm1995personal@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e as owned

using-git-worktrees creates a worktree in the directory the user's
instructions declare, ahead of its defaults, but Step 6 owned only
worktrees under .worktrees/ or worktrees/. A worktree Superpowers made
in the declared directory was treated as the host's and never cleaned
up (#2397).

Step 6's ownership condition and the "This other worktree looks stale"
rationalization row each gain the declared directory, so they agree.
Claude Code's .claude/worktrees/ stays the host's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cription

A plan executor's final message lists the findings it deferred, and it
then deletes its workspace. Chat scrollback was the only copy left, so
those findings were lost once the session ended (#2253).

Option 2 gains one paragraph: copy those lines into the PR description
under "Deferred items", where your human partner reviews and where they
outlive the session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Step 2 listing from #2707, `git status --porcelain -uall`, does not
show ignored files, and Step 6's plain `git worktree remove` deletes
them without refusing. An ignored .env.local, or a plan workspace that
SDD's self-ignoring .gitignore hides, was lost at cleanup (#2207).

A separate paragraph after #2707's listing runs
`git status --porcelain --ignored=matching` and counts each `!!` entry
as a listed file, leaving out .superpowers/sdd/.gitignore,
brainstorming's port and token files, and dependency and build caches.
A plan workspace still present stays listed: it is an unfinished run.

Where the root .gitignore ignores .superpowers/, as the visual
companion asks users to do, git status shows it as one entry: the
exclusions cannot apply, and the plan workspace is named only as
.superpowers/. A second command,
`git ls-files --others --ignored --exclude-standard -- .superpowers`,
names the files inside it.

The new mechanics case runs both listings from the skill's own fences
on a worktree in each layout. Before this paragraph it failed: #2707's
listing alone named only NOTES.md and build/out.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e empty

Plain `git worktree remove` refuses for untracked files but deletes
ignored ones without refusing. Step 6 ran it before reaching the stop
for listed files, so a worktree holding only ignored files, or one left
after its untracked files were committed, lost them (#2207).

Above the removal block, one sentence: run it only when both Step 2
listings, run again in the worktree, list no files. After #2707's
refusal recipe, one paragraph: an ignored file is never committed or
force-added, so only options 2 to 4 apply to it; after options 1 to 3,
both listings run again, anything still listed is asked about, and the
worktree goes once they list nothing. #2707's "No answer means option 4"
covers an unanswered question. None of #2707's lines move or change.

Two mechanics cases pin the git behavior this depends on: with
NOTES.md committed, the listings still name an ignored .env.local, and
Step 6's block exits 0 and deletes it; with an untracked file present,
the block refuses with the message Step 6 quotes and leaves the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nership phrase

The previous commit turned "`.worktrees/` or `worktrees/`" into a
three-item list in Step 6's ownership condition and in the "This other
worktree looks stale" row. That reworded both of Jesse's lines more
than #2397 needs, and removed the phrase that
tests/claude-code/test-worktree-path-policy.sh checks for, so that test
failed.

Both lines keep dev's words and gain only ", or under the worktree
directory your instructions declare". The path-policy test passes
again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…owUntrackedFiles=no

With status.showUntrackedFiles=no in a user's config,
`git status --porcelain --ignored=matching` stops with "fatal:
Unsupported combination of ignored and untracked-files arguments" and
lists nothing. An agent could read that as no ignored files, and the
removal that follows would delete them. #2707's listing is not
affected, because its -uall overrides the setting.

Pass -unormal, which is what the command uses when nothing is
configured. A mechanics fixture with the setting failed on .env.local
before this change and passes after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in the skill's prose sets LOCATION, and a shell variable set in
one tool call is gone in the next. Run as written, the Safety
Verification check became `git check-ignore -q "/"`, which exits 128 with
git's "outside repository" message in every layout, including one where
`.worktrees/` is ignored. An agent can read that non-zero exit as "not
ignored", add a duplicate .gitignore entry and commit it. The fence now
starts with a `${LOCATION:?}` guard, so the check stops with a message
that says to set LOCATION to the directory selected above.

The mechanics test gains ignore_check_needs_location: it runs the fence
with LOCATION unset in a repository whose `.worktrees/` is ignored and
expects a non-zero exit with that message. Against the one-line fence it
fails with exit 128 and git's message. The two existing ignore-check
cases still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
arittr and others added 3 commits November 26, 2026 02:21
…try project

The `pyproject.toml` line in using-git-worktrees' Step 2 runs `poetry
install` only beside a poetry.lock or for a [tool.poetry] table (#1108),
and no test ran it. poetry_install_only_for_poetry_projects extracts
Step 2's setup fence and runs it in three directories with a stub poetry
first on PATH that records each call: a pyproject.toml with neither the
table nor a lock does not call it; one with the table does; a
poetry.lock beside a pyproject.toml without the table does. Each
directory holds only those files, so no other installer line runs.

In a throwaway copy of the skill with dev's line put back,
  if [ -f pyproject.toml ]; then poetry install; fi
the first check fails: the stub is called as `poetry install`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD's Setup pointed at references/branch-guard.md "Before your first
edit", but the controller in this skill never edits files: its
implementers do, and they commit on whatever branch the controller is
on. A controller that took the trigger literally could dispatch Task 1
on main without ever reading the guard. The pointer now names a step the
controller takes, "Before you dispatch Task 1", and the reference file's
opening paragraph says the same and why: implementers commit on the
branch you are on. #2707's paragraph and row below that opening are
unchanged.

SKILL.md is 19,869 bytes, under the 20,000-byte cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng-plans' words

SDD's Finish listed each `minor (deferred)` line "the final fix wave did
not fix". Nothing in the ledger records which deferred minors the fix
wave fixed, so that filter rested on the controller's memory, which does
not survive compaction, and a guess could drop an unfixed minor. Finish
now takes every `minor (deferred)` line under "Deferred minors", as
executing-plans' Finish says it. The lines that follow are byte-identical
to dev again: the earlier hunk had rewrapped them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants