An agentic skills framework & software development methodology that works.
fix(skills): capture worktree path before Step 5 changes directory
Jesse Vincent0b47219ac864
diff --git a/skills/finishing-a-development-branch/SKILL.md b/skills/finishing-a-development-branch/SKILL.mdindex 7f6e4ec79..21a439ac3 100644--- a/skills/finishing-a-development-branch/SKILL.md+++ b/skills/finishing-a-development-branch/SKILL.md@@ -30,6 +30,9 @@ Tests failing (<N> failures). Must fix before completing:```bashGIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)+# Capture now, while still inside the workspace — Step 5 changes directory+# before cleanup (Step 6) needs this value+WORKTREE_PATH=$(git rev-parse --show-toplevel)```This determines which menu to show and how cleanup works:@@ -111,6 +114,8 @@ git branch -d <feature-branch>```bashgit push -u origin <feature-branch>+# From a detached HEAD, name the new branch on the remote:+# git push origin HEAD:refs/heads/<new-branch>```Then create the pull/merge request against <base-branch> with the forge's@@ -154,23 +159,17 @@ git branch -D <feature-branch>## Step 6: Cleanup Workspace**Runs for Option 1 and confirmed discards.** Options 2 and 3 always-preserve the worktree.--```bash-GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)-GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)-WORKTREE_PATH=$(git rev-parse --show-toplevel)-```+preserve the worktree. Both callers have already changed directory to the+main repo root — worktree removal must run from outside the worktree —+and use the `GIT_DIR`/`GIT_COMMON`/`WORKTREE_PATH` values captured in+Step 2, from before that directory change.**If `GIT_DIR == GIT_COMMON`:** Normal repo, no worktree to clean up. Done.-**If worktree path is under `.worktrees/` or `worktrees/`:** Superpowers-created this worktree — we own cleanup. Run it from the main repo root-(removal fails from inside the worktree being removed):+**If `WORKTREE_PATH` is under `.worktrees/` or `worktrees/`:** Superpowers+created this worktree — we own cleanup:```bash-MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)-cd "$MAIN_ROOT"git worktree remove "$WORKTREE_PATH"git worktree prune # Self-healing: clean up any stale registrations```@@ -191,7 +190,7 @@ place. If your platform provides a workspace-exit tool, use it.| Excuse | Reality ||--------|---------|-| "Tests passed earlier this session" | Run the suite now. The tree changed since the last green run. |+| "Tests passed earlier this session" | Run the suite on the tree you are about to integrate. A green run only proves the tree it ran on. || "They obviously want it merged" | Integration is your human partner's decision. Present the menu and wait. || "They seem done with this feature — I'll offer to discard it" | The menu is complete as written. Discard happens only when your human partner asks for it in so many words. || "'Yeah, get rid of it' counts as confirmation" | Only the typed word `discard` authorizes deletion. |