Phase selection
PHASE="${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 and the 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 ===" ``` - [ ] **Step 2: Run RED phase — confirm agent uses git worktree add today** Run: `cd tests/claude-code && bash test-worktree-native-preference.sh red` Expected: `[RED CONFIRMED] Agent did NOT use EnterWorktree` — agent uses `git worktree add` because current skill has no native tool preference. Document the agent's exact output and any rationalizations verbatim. This is the baseline failure the skill must fix. - [ ] **Step 3: If RED confirmed, proceed. Write the Step 1a skill text.** Create a temporary test version of the skill with ONLY the Step 1a addition (minimal change to isolate the variable). Add this section to the top of the skill's creation instructions, BEFORE the existing directory selection process: ```markdown