---
name: multi-agent-manual-test
description: "Switch to the active task's branch and prepare it for manual testing in Xcode. Phase 3 user-test step, standalone (the UI Bug Hunter lives at multi-agent-test). Use when a finished change needs trying by hand on a device or simulator."
user-invocable: true
argument-hint: "[#id]  -  optional: task ID. Defaults to the latest task if omitted"
metadata:
  language: en
---

# multi-agent manual-test  -  Phase 3 Manual Test Mode

**Input**: $ARGUMENTS

Lets you switch to the task branch for manual testing in Xcode before the PR is opened.

## Steps

1. **Find the task**  -  parse `#N` from the argument or find the most recent task

2. **Check the state**  -  the task must have completed Phase 2 (Dev) or later
   - Phase < 2 → "No code has been written yet, run `resume #N` first"

3. **Hand the branch over**. Make the WIP commit yourself (Standard path item 3 of Phase 4 Step 2 folds it back), then let the script hold the run artefacts and the project root's current branch, remove the worktree and check the branch out. `{worktree-path}` and `{jiraId}` come from the task's state (`worktreePath`, `jiraId`):
   ```bash
   git -C "{worktree-path}" add -A
   git -C "{worktree-path}" diff --cached --quiet || git -C "{worktree-path}" commit -m "WIP: {jiraId}  -  changes for user test"
   bash $HOME/.claude/scripts/user-test-handoff.sh checkout --task "{jiraId}" --worktree "{worktree-path}" --root "{project-root}" --branch "{branch-name}"
   ```
   A refused commit stops here with nothing moved. Script exits: 3 the project root has uncommitted changes; 5 the worktree or a submodule holds uncommitted, unpushed or stashed work (a submodule with no remote needs one added); both move nothing. 6 a handoff is already held, or git refused part way: run `restore` below (if it answers 7, nothing had moved). 1 the worktree is not on the branch.

4. **Give test instructions**:
   ```
   🧪 Switched to branch: {branch-name}

   To test:
     • SourceTree → review the commits and the diff
     • Xcode → open .xcworkspace → Cmd+B → Cmd+U
     • Manual test in the Simulator

   Result:
     ✅ "ok" → proceeds to Phase 4 (commit)
     ❌ "fix: ..." → the worktree is recreated and the fix is applied
   ```

5. **Wait for the user's response**, then hand the branch back before acting on it:
   ```bash
   bash $HOME/.claude/scripts/user-test-handoff.sh restore --task "{jiraId}" --worktree "{worktree-path}" --root "{project-root}" --branch "{branch-name}"
   ```
   Exit 3: the user edited files on the branch in the project root. Ask them to `git stash`, run `restore` again, then `git -C "{worktree-path}" stash pop`; a commit made there instead would stop Phase 4 from folding the checkpoints. Exit 6: the project root could not leave the branch (an untracked file in the way) or the worktree could not be re-added; the message names the cause, the hold is kept, and `restore` runs again once it is cleared. Exit 7: nothing was held, so the worktree was never removed.

6. **Based on the result**:
   - **OK** → an "ok" is a claim, and the pass has to be substantiated before it is recorded. First write `$WORKTREE/.pipeline/manual-test.json`, one entry per acceptance criterion taken from the analysis doc test plan, the plan tasks, or the user's own words:
     ```json
     {"criteria":[{"spec":"<quote>","source":"analysis 15.2 | plan task 3 | user","observed":"<what was seen>","verdict":"pass|fail|not-tested","reason":"<required when not-tested>","screenshot":"<path or null>"}],"verdict":"passed|failed"}
     ```
     then run the gate, adding `--require-screenshot` when `state.visualEvidence.required` is true:
     ```bash
     node $HOME/.claude/scripts/evidence-gate.mjs --claim manual --status passed \
       --evidence "$WORKTREE/.pipeline/manual-test.json"
     ```
     Exit 1 means the "ok" is not accepted: name the criterion that lacks evidence and wait for the next reply. Exit 0 → proceed to Phase 4. Full contract: `$HOME/.claude/multi-agent-refs/phases/phase-3-review.md` step 5.
   - **Fix needed** → apply the fix in the restored worktree
