---
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."
description-tr: "Aktif görevin branch'ine geçer ve Xcode'da manuel test için hazırlar. Faz 3 kullanıcı-test adımının bağımsız hali (UI Bug Hunter /multi-agent:test'te)."
argument-hint: "[#id]  -  optional: task ID (e.g. #3); the most recent task when omitted"
parameters: [{"name":"task","kind":"run-id"}]
gui: button
destructive: false
confirm: none
---

# 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 pick the most recent task

2. **Check state**  -  the task must have completed Phase 2 (Dev) or later
   - Phase < 3 → "No code 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 main repo'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 main repo 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.

   Then mark the tracker as waiting (this CONTINUES the task's existing `tracker-state.json`; never `init` here - see `$HOME/.claude/multi-agent-refs/tracker-contract.md` "Continuation runs"). On Claude Code in a fresh session, first rebuild the TaskList from state per the same contract:
   ```bash
   bash $HOME/.claude/scripts/phase-tracker.sh update 3 in_progress
   bash $HOME/.claude/scripts/phase-tracker.sh now 3 "awaiting local test (user)"
   bash $HOME/.claude/scripts/phase-tracker.sh render
   ```

4. **Tell the user how to test**:
   ```
   🧪 Switched to branch: {branch-name}

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

   Reply:
     ✅ "ok" → continue to Phase 4 (commit)
     ❌ "fix: ..." → recreate the worktree and apply the fix
   ```

5. **Wait for the user's reply**, 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 main repo. 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 main repo 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. **Branch on the answer**:
   - **OK** → first write `$WORKTREE/.pipeline/manual-test.json` (one entry per acceptance criterion 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 `node $HOME/.claude/scripts/evidence-gate.mjs --claim manual --status passed --evidence "$WORKTREE/.pipeline/manual-test.json"`, adding `--require-screenshot` when `state.visualEvidence.required` is true (a passing criterion then has to name a screenshot that is actually on disk). Exit 1 means the "ok" is not accepted: name the criterion that is missing evidence and wait for the next reply. Exit 0 → `phase-tracker.sh update 3 completed` + `phase-tracker.sh meta 3 Result "local test passed (user)"`, continue to Phase 4. Full contract: `$HOME/.claude/multi-agent-refs/phases/phase-3-review.md` step 5. The UI flow video rule in `$HOME/.claude/multi-agent-refs/audit-guide.md` "Phase 3 evidence flows" applies here too: invoked standalone, this command is the only phase that ran, so if `visualEvidence.required` is set and `visualEvidence.video.file` is empty, the recording has to happen here or nowhere.
   - **Fix needed** → `phase-tracker.sh now 3 "applying fix: <summary>"`, apply the fix in the restored worktree
