Worktree Rototill 实施计划
Section titled “Worktree Rototill 实施计划”对于 agentic workers: REQUIRED SUB-SKILL: 使用 superpowers:subagent-driven-development (推荐) or superpowers:executing-plans to implement this 计划 task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Make superpowers 延后处理 to 原生 harness worktree systems when 可用, fall back to 手动 git worktrees when not, and fix three known finishing bugs.
架构: Two skill files are rewritten (using-git-worktrees, finishing-a-development-branch), three files get one-line integration updates (executing-plans, subagent-driven-development, writing-plans). The core change is adding detection (GIT_DIR != GIT_COMMON) and a native-tool-first creation path. These are markdown skill instruction files, not application code — “tests” are agent behavior tests using the testing-skills-with-subagents TDD framework.
Tech Stack: Markdown (skill files), bash (test scripts), Claude Code CLI (claude -p for headless testing)
Spec: docs/superpowers/specs/2026-04-06-worktree-rototill-design.md
Task 1: GATE — TDD Validation of 步骤 1a (Native Tool Preference)
Section titled “Task 1: GATE — TDD Validation of 步骤 1a (Native Tool Preference)”步骤 1a is the load-bearing assumption of the entire design. 如果 agents don’t prefer 原生 worktree tools over git worktree add, the spec fails. Validate this FIRST, before touching any skill files.
文件:
- 创建:
tests/claude-code/test-worktree-native-preference.sh - Read:
skills/using-git-worktrees/SKILL.md(当前 version, for RED baseline) - Read:
tests/claude-code/test-helpers.sh(forrun_claude,assert_contains, etc.) - Read:
skills/writing-skills/testing-skills-with-subagents.md(TDD framework)
This 任务 is a gate. 如果 the GREEN 阶段 fails after 2 REFACTOR iterations, STOP. Do not proceed to Task 2. Report back — the creation approach needs redesign.
- 步骤 1: Write the RED baseline test script
创建 the test script that will run scenarios both WITHOUT and WITH the updated skill text. The RED 阶段 runs against the 当前 skill (which has no 步骤 1a).
#!/usr/bin/env bash# Test: Does the agent prefer native worktree tools (EnterWorktree) over git worktree add?# Framework: RED-GREEN-REFACTOR per testing-skills-with-subagents.md## RED: Current skill has no native tool preference. Agent should use git worktree add.# GREEN: Updated skill has Step 1a. Agent should use EnterWorktree on Claude Code.
set -euo pipefailSCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"source "$SCRIPT_DIR/test-helpers.sh"
# Pressure scenario: realistic implementation task where agent needs isolationSCENARIO='IMPORTANT: This is a real task. Choose and act.
You need to implement a small feature (add a "version" field to package.json).This should be done in an isolated workspace to protect the main branch.
You have the using-git-worktrees skill available. Set up the isolated workspace now.Do NOT actually implement the feature — just set up the workspace and report what you did.
Respond with EXACTLY what tool/command you used to create the workspace.'
echo "=== Worktree Native Preference Test ==="echo ""
# Phase selectionPHASE="${1:-red}"
if [ "$PHASE" = "red" ]; then echo "--- RED PHASE: Running WITHOUT Step 1a (current skill) ---" echo "Expected: Agent uses 'git worktree add' (no native tool awareness)" echo ""
test_dir=$(create_test_project) cd "$test_dir" git init && git commit --allow-empty -m "init" mkdir -p .worktrees
output=$(run_claude "$SCENARIO" 120)
echo "Agent output:" echo "$output" echo ""
# RED expectation: agent uses git worktree add (current behavior) if echo "$output" | grep -qi "EnterWorktree"; then echo "[UNEXPECTED] Agent used EnterWorktree WITHOUT Step 1a — skill may not be needed" echo "Investigate: is Claude Code's default behavior already correct?" else echo "[RED CONFIRMED] Agent did NOT use EnterWorktree" assert_contains "$output" "git worktree" "Agent used git worktree (expected in RED)" fi
cleanup_test_project "$test_dir"
elif [ "$PHASE" = "green" ]; then echo "--- GREEN PHASE: Running WITH Step 1a (updated skill) ---" echo "Expected: Agent uses EnterWorktree instead of git worktree add" echo ""
test_dir=$(create_test_project) cd "$test_dir" git init && git commit --allow-empty -m "init"
output=$(run_claude "$SCENARIO" 120)
echo "Agent output:" echo "$output" echo ""
# GREEN expectation: agent uses EnterWorktree assert_contains "$output" "EnterWorktree" "Agent used native EnterWorktree tool" assert_not_contains "$output" "git worktree add" "Agent did NOT fall back to git worktree add"
cleanup_test_project "$test_dir"
elif [ "$PHASE" = "pressure" ]; then echo "--- PRESSURE PHASE: Multiple pressures to skip native tools ---" echo ""
PRESSURE_SCENARIO='IMPORTANT: This is a real task. Choose and act.
You need to set up an isolated workspace URGENTLY. Production is impacted andthe fix needs to go in a worktree. You know git worktree add works reliably.The .worktrees/ directory already exists and is gitignored.
You have the using-git-worktrees skill. Set up the workspace NOW.Speed matters. Report EXACTLY what tool/command you used.'
test_dir=$(create_test_project) cd "$test_dir" git init && git commit --allow-empty -m "init" mkdir -p .worktrees echo ".worktrees/" >> .gitignore
output=$(run_claude "$PRESSURE_SCENARIO" 120)
echo "Agent output:" echo "$output" echo ""
# Should STILL use EnterWorktree even under pressure assert_contains "$output" "EnterWorktree" "Agent used native tool even under time pressure" assert_not_contains "$output" "git worktree add" "Agent resisted falling back to git despite pressure"
cleanup_test_project "$test_dir"fi
echo ""echo "=== Test Complete ==="- 步骤 2: 运行 RED 阶段 — confirm agent uses git worktree add today
运行: cd tests/claude-code && bash test-worktree-native-preference.sh red
预期: [RED CONFIRMED] Agent did NOT use EnterWorktree — agent uses git worktree add because 当前 skill has no 原生 tool preference.
Document the agent’s exact output and any rationalizations verbatim. This is the baseline 失败 the skill must fix.
- 步骤 3: 如果 RED confirmed, proceed. Write the 步骤 1a skill text.
创建 a 临时 test version of the skill with ONLY the 步骤 1a addition (minimal change to isolate the variable). 添加 this section to the top of the skill’s creation instructions, BEFORE the 现有 目录 selection process:
## Step 1: Create Isolated Workspace
**You have two mechanisms. Try them in this order.**
### 1a. Native Worktree Tools (preferred)
If your platform provides a worktree or workspace-isolation tool, use it. You know your own toolkit — the skill does not need to name specific tools. Native tools handle directory placement, branch creation, and cleanup automatically.
After using a native tool, skip to Step 3 (Project Setup).
### 1b. Git Worktree Fallback
If no native tool is available, create a worktree manually using git.- 步骤 4: 运行 GREEN 阶段 — confirm agent now uses EnterWorktree
运行: cd tests/claude-code && bash test-worktree-native-preference.sh green
预期: [PASS] Agent used native EnterWorktree tool
如果 FAIL: Document the agent’s exact output and rationalizations. This is a REFACTOR signal — the 步骤 1a text needs revision. Try up to 2 REFACTOR iterations. 如果 still failing after 2 iterations, STOP and 报告 back.
- 步骤 5: 运行 PRESSURE 阶段 — confirm agent resists 回退 under pressure
运行: cd tests/claude-code && bash test-worktree-native-preference.sh pressure
预期: [PASS] Agent used native tool even under time pressure
如果 FAIL: Document rationalizations verbatim. 添加 explicit counters to 步骤 1a text (e.g., a Red Flag entry: “Never use git worktree add when your 平台 提供 a 原生 worktree tool”). Re-run.
- 步骤 6: 提交 test script
git add tests/claude-code/test-worktree-native-preference.shgit commit -m "test: add RED/GREEN validation for native worktree preference (PRI-974)
Gate test for Step 1a — validates agents prefer EnterWorktree overgit worktree add on Claude Code. Must pass before skill rewrite."Task 2: Rewrite using-git-worktrees SKILL.md
Section titled “Task 2: Rewrite using-git-worktrees SKILL.md”Full rewrite of the creation skill. Replaces the 现有 file entirely.
文件:
- 修改:
skills/using-git-worktrees/SKILL.md(full rewrite, 219 lines → ~210 lines)
Depends on: Task 1 GREEN passing.
- 步骤 1: Write the complete 新 SKILL.md
替换 the entire contents of skills/using-git-worktrees/SKILL.md with:
---name: using-git-worktreesdescription: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback---
# Using Git Worktrees
## Overview
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.
**Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness.
**Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
## Step 0: Detect Existing Isolation
**Before creating anything, check if you are already in an isolated workspace.**
```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)BRANCH=$(git branch --show-current)Submodule guard: GIT_DIR != GIT_COMMON is also true inside git submodules. Before concluding “already in a worktree,” verify you are not in a submodule:
# 如果 this returns a path, you're in a submodule, not a worktree — proceed to 步骤 1git rev-parse --show-superproject-working-tree 2>/dev/nullIf GIT_DIR != GIT_COMMON (and not a submodule): You are already in a linked worktree. Skip to Step 3 (Project Setup). Do NOT create another worktree.
Report with branch state:
- On a branch: “Already in isolated workspace at
<path>on branch<name>.” - Detached HEAD: “Already in isolated workspace at
<path>(detached HEAD, externally managed). Branch creation needed at finish time.”
If GIT_DIR == GIT_COMMON (or in a submodule): You are in a normal repo checkout.
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:
“Would you like me to set up an isolated worktree? It protects your current branch from changes.”
Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 3.
Step 1: Create Isolated Workspace
Section titled “Step 1: Create Isolated Workspace”You have two mechanisms. Try them in this order.
1a. Native Worktree Tools (preferred)
Section titled “1a. Native Worktree Tools (preferred)”If your platform provides a worktree or workspace-isolation tool, use it. You know your own toolkit — the skill does not need to name specific tools. Native tools handle directory placement, branch creation, and cleanup automatically.
After using a native tool, skip to Step 3 (Project Setup).
1b. Git Worktree Fallback
Section titled “1b. Git Worktree Fallback”If no native tool is available, create a worktree manually using git.
Directory Selection
Section titled “Directory Selection”Follow this priority order:
-
Check your instructions for a worktree directory preference. If specified, use it without asking.
-
Check existing project-local directories:
Terminal window ls -d .worktrees 2>/dev/null # Preferred (hidden)ls -d worktrees 2>/dev/null # AlternativeIf found, use that directory. If both exist,
.worktreeswins. -
Default to
.worktrees/.
Safety Verification (project-local directories only)
Section titled “Safety Verification (project-local directories only)”MUST verify directory is ignored before creating worktree:
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/nullIf NOT ignored: Add to .gitignore, commit the change, then proceed.
Why critical: Prevents accidentally committing worktree contents to repository.
Create the Worktree
Section titled “Create the Worktree”# Determine path based on chosen locationpath="$LOCATION/$BRANCH_NAME"
git worktree add "$path" -b "$BRANCH_NAME"cd "$path"Hooks Awareness
Section titled “Hooks Awareness”Git worktrees do not inherit the parent repo’s hooks directory. After creating the worktree, symlink hooks from the main repo if they exist:
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)if [ -d "$MAIN_ROOT/.git/hooks" ]; then ln -sf "$MAIN_ROOT/.git/hooks" "$path/.git/hooks"fiThis prevents pre-commit checks, linters, and other hooks from silently stopping when work moves to a worktree.
Sandbox fallback: If git worktree add fails with a permission error (sandbox denial), treat this as a restricted environment. Skip creation, run setup and baseline tests in the current directory, report accordingly.
Step 3: Project Setup
Section titled “Step 3: Project Setup”Auto-detect and run appropriate setup:
# Node.jsif [ -f package.json ]; then npm install; fi
# Rustif [ -f Cargo.toml ]; then cargo build; fi
# Pythonif [ -f requirements.txt ]; then pip install -r requirements.txt; fiif [ -f pyproject.toml ]; then poetry install; fi
# Goif [ -f go.mod ]; then go mod download; fiStep 4: Verify Clean Baseline
Section titled “Step 4: Verify Clean Baseline”Run tests to ensure workspace starts clean:
# 使用 project-appropriate commandnpm test / cargo test / pytest / go test ./...If tests fail: Report failures, ask whether to proceed or investigate.
If tests pass: Report ready.
Report
Section titled “Report”Worktree ready at <full-path>Tests passing (<N> tests, 0 失败)Ready to implement <feature-name>Quick Reference
Section titled “Quick Reference”| Situation | Action |
|---|---|
| Already in linked worktree | Skip creation (Step 0) |
| In a submodule | Treat as normal repo (Step 0 guard) |
| Native worktree tool available | Use it (Step 1a) |
| No native tool | Git worktree fallback (Step 1b) |
.worktrees/ exists | Use it (verify ignored) |
worktrees/ exists | Use it (verify ignored) |
| Both exist | Use .worktrees/ |
| Neither exists | Check instruction file, then default .worktrees/ |
| Directory not ignored | Add to .gitignore + commit |
| Permission error on create | Sandbox fallback, work in place |
| Tests fail during baseline | Report failures + ask |
| No package.json/Cargo.toml | Skip dependency install |
Common Mistakes
Section titled “Common Mistakes”Fighting the harness
Section titled “Fighting the harness”- Problem: Using
git worktree addwhen the platform already provides isolation - Fix: Step 0 detects existing isolation. Step 1a defers to native tools.
Skipping detection
Section titled “Skipping detection”- Problem: Creating a nested worktree inside an existing one
- Fix: Always run Step 0 before creating anything
Skipping ignore verification
Section titled “Skipping ignore verification”- Problem: Worktree contents get tracked, pollute git status
- Fix: Always use
git check-ignorebefore creating project-local worktree
Assuming directory location
Section titled “Assuming directory location”- Problem: Creates inconsistency, violates project conventions
- Fix: Follow priority: existing > instruction file > default
Proceeding with failing tests
Section titled “Proceeding with failing tests”- Problem: Can’t distinguish new bugs from pre-existing issues
- Fix: Report failures, get explicit permission to proceed
Red Flags
Section titled “Red Flags”Never:
- Create a worktree when Step 0 detects existing isolation
- Use git commands when a native worktree tool is available
- Create worktree without verifying it’s ignored (project-local)
- Skip baseline test verification
- Proceed with failing tests without asking
Always:
- Run Step 0 detection first
- Prefer native tools over git fallback
- Follow directory priority: existing > instruction file > default
- Verify directory is ignored for project-local
- Auto-detect and run project setup
- Verify clean test baseline
- Symlink hooks after creating worktree via 1b
Integration
Section titled “Integration”Called by:
- subagent-driven-development - Ensures isolated workspace (creates one or verifies existing)
- executing-plans - Ensures isolated workspace (creates one or verifies existing)
- Any skill needing isolated workspace
Pairs with:
- finishing-a-development-branch - REQUIRED for cleanup after work complete
- [ ] **步骤 2: 验证 the file 读取 correctly**
运行: `wc -l skills/using-git-worktrees/SKILL.md`
预期: Approximately 200-220 lines. Scan for any markdown formatting issues.
- [ ] **步骤 3: 提交**
```bashgit add skills/using-git-worktrees/SKILL.mdgit commit -m "feat: rewrite using-git-worktrees with detect-and-defer (PRI-974)
Step 0: GIT_DIR != GIT_COMMON detection (skip if already isolated)Step 0 consent: opt-in prompt before creating worktree (#991)Step 1a: native tool preference (short, first, declarative)Step 1b: git worktree fallback with project-local directory policySubmodule guard prevents false detectionPlatform-neutral instruction file references (#1049)"Task 3: Rewrite finishing-a-development-branch SKILL.md
Section titled “Task 3: Rewrite finishing-a-development-branch SKILL.md”Full rewrite of the finishing skill. Adds environment detection, fixes three bugs, adds provenance-based cleanup.
文件:
-
修改:
skills/finishing-a-development-branch/SKILL.md(full rewrite, 201 lines → ~220 lines) -
步骤 1: Write the complete 新 SKILL.md
替换 the entire contents of skills/finishing-a-development-branch/SKILL.md with:
---name: finishing-a-development-branchdescription: Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup---
# Finishing a Development Branch
## Overview
Guide completion of development work by presenting clear options and handling chosen workflow.
**Core principle:** Verify tests → Detect environment → Present options → Execute choice → Clean up.
**Announce at start:** "I'm using the finishing-a-development-branch skill to complete this work."
## The Process
### Step 1: Verify Tests
**Before presenting options, verify tests pass:**
```bash# 运行 项目's test suitenpm test / cargo test / pytest / go test ./...If tests fail:
Tests failing (<N> 失败). Must fix 完成前:
[Show 失败]
Cannot proceed with merge/PR until tests pass.Stop. Don’t proceed to Step 2.
If tests pass: Continue to Step 2.
Step 2: Detect Environment
Section titled “Step 2: Detect Environment”Determine workspace state before presenting options:
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)This determines which menu to show and how cleanup works:
| State | Menu | Cleanup |
|---|---|---|
GIT_DIR == GIT_COMMON (normal repo) | Standard 4 options | No worktree to clean up |
GIT_DIR != GIT_COMMON, named branch | Standard 4 options | Provenance-based (see Step 6) |
GIT_DIR != GIT_COMMON, detached HEAD | Reduced 3 options (no merge) | No cleanup (externally managed) |
Step 3: Determine Base Branch
Section titled “Step 3: Determine Base Branch”# Try common base branchesgit merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/nullOr ask: “This branch split from main - is that correct?”
Step 4: Present Options
Section titled “Step 4: Present Options”Normal repo and named-branch worktree — present exactly these 4 options:
Implementation complete. What would you like to do?
1. Merge back to <base-branch> locally2. Push and create a Pull Request3. Keep the branch as-is (I'll handle it later)4. Discard this work
Which option?Detached HEAD — present exactly these 3 options:
Implementation complete. You're on a 分离 HEAD (外部管理 workspace).
1. Push as 新 branch and create a Pull Request2. Keep as-is (I'll handle it later)3. Discard this work
Which option?Don’t add explanation - keep options concise.
Step 5: Execute Choice
Section titled “Step 5: Execute Choice”Option 1: Merge Locally
Section titled “Option 1: Merge Locally”# Get main repo root for CWD safetyMAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)cd "$MAIN_ROOT"
# Merge first — verify 成功 before removing anythinggit checkout <base-branch>git pullgit merge <feature-branch>
# 验证 tests on merged result<test command>
# Only after merge succeeds: remove worktree, then delete branch# (See 步骤 6 for worktree 清理)git branch -d <feature-branch>Then: Cleanup worktree (Step 6)
Option 2: Push and Create PR
Section titled “Option 2: Push and Create PR”# Push branchgit push -u origin <feature-branch>
# 创建 PRgh pr create --title "<title>" --body "$(cat <<'EOF'## 总结<2-3 bullets of what changed>
## Test Plan- [ ] <验证 steps>EOF)"Do NOT clean up worktree — user needs it alive to iterate on PR feedback.
Option 3: Keep As-Is
Section titled “Option 3: Keep As-Is”Report: “Keeping branch <name>. Worktree preserved at <path>.”
Don’t cleanup worktree.
Option 4: Discard
Section titled “Option 4: Discard”Confirm first:
This will permanently delete:- Branch <name>- All commits: <commit-list>- Worktree at <path>
Type 'discard' to confirm.Wait for exact confirmation.
If confirmed:
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)cd "$MAIN_ROOT"Then: Cleanup worktree (Step 6), then force-delete branch:
git branch -D <feature-branch>Step 6: Cleanup Workspace
Section titled “Step 6: Cleanup Workspace”Only runs for Options 1 and 4. Options 2 and 3 always preserve the worktree.
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)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.
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 registrationsOtherwise: The host environment (harness) owns this workspace. Do NOT remove it. If your platform provides a workspace-exit tool, use it. Otherwise, leave the workspace in place.
Quick Reference
Section titled “Quick Reference”| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | yes | - | - | yes |
| 2. Create PR | - | yes | yes | - |
| 3. Keep as-is | - | - | yes | - |
| 4. Discard | - | - | - | yes (force) |
Common Mistakes
Section titled “Common Mistakes”Skipping test verification
- Problem: Merge broken code, create failing PR
- Fix: Always verify tests before offering options
Open-ended questions
- Problem: “What should I do next?” is ambiguous
- Fix: Present exactly 4 structured options (or 3 for detached HEAD)
Cleaning up worktree for Option 2
- Problem: Remove worktree user needs for PR iteration
- Fix: Only cleanup for Options 1 and 4
Deleting branch before removing worktree
- Problem:
git branch -dfails because worktree still references the branch - Fix: Merge first, remove worktree, then delete branch
Running git worktree remove from inside the worktree
- Problem: Command fails silently when CWD is inside the worktree being removed
- Fix: Always
cdto main repo root beforegit worktree remove
Cleaning up harness-owned worktrees
- Problem: Removing a worktree the harness created causes phantom state
- Fix: Only clean up worktrees under
.worktrees/orworktrees/
No confirmation for discard
- Problem: Accidentally delete work
- Fix: Require typed “discard” confirmation
Red Flags
Section titled “Red Flags”Never:
- Proceed with failing tests
- Merge without verifying tests on result
- Delete work without confirmation
- Force-push without explicit request
- Remove a worktree before confirming merge success
- Clean up worktrees you didn’t create (provenance check)
- Run
git worktree removefrom inside the worktree
Always:
- Verify tests before offering options
- Detect environment before presenting menu
- Present exactly 4 options (or 3 for detached HEAD)
- Get typed confirmation for Option 4
- Clean up worktree for Options 1 & 4 only
cdto main repo root before worktree removal- Run
git worktree pruneafter removal
Integration
Section titled “Integration”Called by:
- subagent-driven-development (Step 7) - After all tasks complete
- executing-plans (Step 5) - After all batches complete
Pairs with:
- using-git-worktrees - Cleans up worktree created by that skill
- [ ] **步骤 2: 验证 the file 读取 correctly**
运行: `wc -l skills/finishing-a-development-branch/SKILL.md`
预期: Approximately 210-230 lines.
- [ ] **步骤 3: 提交**
```bashgit add skills/finishing-a-development-branch/SKILL.mdgit commit -m "feat: rewrite finishing-a-development-branch with detect-and-defer (PRI-974)
Step 2: environment detection (GIT_DIR != GIT_COMMON) before presenting menuDetached HEAD: reduced 3-option menu (no merge from detached HEAD)Provenance-based cleanup: .worktrees/ = ours, anything else = hands offBug #940: Option 2 no longer cleans up worktreeBug #999: merge -> verify -> remove worktree -> delete branchBug #238: cd to main repo root before git worktree removeStale worktree pruning after removal (git worktree prune)"Task 4: Integration Updates
Section titled “Task 4: Integration Updates”One-line changes to three files that 引用 using-git-worktrees.
文件:
-
修改:
skills/executing-plans/SKILL.md:68 -
修改:
skills/subagent-driven-development/SKILL.md:268 -
修改:
skills/writing-plans/SKILL.md:16 -
步骤 1: 更新 executing-plans integration line
In skills/executing-plans/SKILL.md, change line 68 from:
- **superpowers:using-git-worktrees** - REQUIRED: Set up isolated workspace before starting到:
- **superpowers:using-git-worktrees** - Ensures isolated workspace (creates one or verifies existing)- 步骤 2: 更新 subagent-driven-development integration line
In skills/subagent-driven-development/SKILL.md, change line 268 from:
- **superpowers:using-git-worktrees** - REQUIRED: Set up isolated workspace before starting到:
- **superpowers:using-git-worktrees** - Ensures isolated workspace (creates one or verifies existing)- 步骤 3: 更新 writing-plans context line
In skills/writing-plans/SKILL.md, change line 16 from:
**Context:** This should be run in a dedicated worktree (created by brainstorming skill).到:
**Context:** If working in an isolated worktree, it should have been created via the using-git-worktrees skill at execution time.- 步骤 4: 提交 all three
git add skills/executing-plans/SKILL.md skills/subagent-driven-development/SKILL.md skills/writing-plans/SKILL.mdgit commit -m "fix: update worktree integration references across skills (PRI-974)
Remove REQUIRED language from executing-plans and subagent-driven-development.Consent and detection now live inside using-git-worktrees itself.Fix stale 'created by brainstorming' claim in writing-plans."Task 5: End-to-End Validation
Section titled “Task 5: End-to-End Validation”验证 the full rewritten skills work together. 运行 the 现有 test suite plus 手动 verification.
文件:
-
Read:
tests/claude-code/run-skill-tests.sh -
Read:
skills/using-git-worktrees/SKILL.md(verify final state) -
Read:
skills/finishing-a-development-branch/SKILL.md(verify final state) -
步骤 1: 运行 现有 test suite
运行: cd tests/claude-code && bash run-skill-tests.sh
预期: All 现有 tests pass. 如果 any fail, investigate — the integration changes (Task 4) may have broken a content assertion.
- 步骤 2: Re-run 步骤 1a GREEN test
运行: cd tests/claude-code && bash test-worktree-native-preference.sh green
预期: PASS — agent still uses EnterWorktree with the final skill text (not just the minimal 步骤 1a addition from Task 1).
- 步骤 3: Manual 验证 — read both rewritten skills end-to-end
Read skills/using-git-worktrees/SKILL.md and skills/finishing-a-development-branch/SKILL.md in their entirety. Check:
- No 引用 to 旧 behavior (hardcoded
CLAUDE.md, interactive 目录 提示词, “REQUIRED” language) - 步骤 numbering is consistent within each file
- Quick Reference tables match the prose
- Integration sections cross-reference correctly
- No markdown formatting issues
- 步骤 4: 验证 git status is clean
运行: git status
预期: Clean working tree. All changes committed across Tasks 1-4.
- 步骤 5: Final commit if any fixups needed
如果 手动 验证 found issues, fix them and commit:
git add -Agit commit -m "fix: address review findings in worktree skill rewrite (PRI-974)"如果 no issues found, 跳过 this step.