---
name: multi-agent-design-check
description: "Audits a screen's mock-mode build against its Figma design (iOS / Android, local-only). Picks the repo and module, gates on mock support, enumerates every state driver into a countable target set, builds Debug in a worktree, launches in mock mode, fetches the Figma variants, compares each on pixels, px-spacing, typography and color, and exports a side-by-side annotated report (HTML + PDF + Confluence) to ~/DesignChecks. A coverage gate fails the run when a target is neither audited nor skipped with a reason. Use when checking that an implemented screen matches its Figma design, after a UI change or before a design review."
user-invocable: true
argument-hint: '[scope]  -  empty = whole module; screen name; screen@variant; Figma URL(s); --resume'
metadata:
  language: en
---

# multi-agent-design-check - Mock-mode vs Figma design audit

**Access check, before anything else.** This command can write outside this machine, so a login the site closed is stopped here, before any question or write.

```bash
ACCESS_LINE=$(node "$HOME/.copilot/scripts/usage-access.mjs"); ACCESS_RC=$?
```

`ACCESS_RC` 3: print `$ACCESS_LINE` as written and stop: no question, no write, attended or unattended. Any other exit continues (the check fails open). Contract: `$HOME/.claude/multi-agent-refs/features/usage-reporting.md` "The access check".

Runs the app in **mock mode** on a simulator / emulator and compares each screen and mock variant against Figma at the **pixel + geometry + typography + color** level. **Local-only**: no CI, no commits, no PR; the report goes to `~/DesignChecks/`, the worktree only isolates the Debug build.

> **Language**: this spec stays English. `outputLanguage` covers conversational lines and the report (`multi-agent:design_report` `report.lang`); `ask_choice` `header` chips, paths, identifiers and logs stay English. Contract: `$HOME/.claude/multi-agent-refs/rules.md` "Language Application".

## Gotchas

- A scope that matches no inventory target is an error, not an empty run; print the closest ids and stop.
- The coverage gate fails the run when a target was neither audited nor skipped with a reason. "Not reached" is not "passed".
- A Figma variant with no matching mock state is a finding about the mock, not a pass for the screen.

## Scope, requirements, tracker

Before Phase 0, read `$HOME/.claude/multi-agent-refs/design-check/scope-and-ledger.md`: the scope grammar (empty, screen, `screen@variant`, target id, Figma URL, `--resume`), the requirements, the tracker detail and the ledger rules. Whole-module is the default and is meant to finish; scope is for resuming or re-checking, never for trimming. No mock mode and no snapshot capture: halt.

Tracker: `bash $HOME/.copilot/scripts/phase-tracker.sh init` + `add` for `0:Init & Gate`, `1:Build & Launch`, `2:Figma`, `3:Drive & Compare`, `4:Report`; there is no TaskList widget, so call `phase-tracker.sh render` after every state change and never TaskCreate.

Every Phase 0 / Phase 2 decision uses the `ask_choice` picker (`$HOME/.copilot/lib/ask-choice.sh`) with a `Step <i>/<n>` breadcrumb; confirm even a single option; never inherit state from a previous run.

## Phase 0 - Init, feasibility gate, inventory

Read `$HOME/.claude/multi-agent-refs/design-check/mcp-currency-gate.md` for step 0 and `$HOME/.claude/multi-agent-refs/design-check/init-inventory.md` for steps 1-9.

0. **MCP currency gate** before anything expensive: session stale or disk stale: **HALT** (reconnect, or update the checkout). Never substitute a local `node` call for a missing tool.
1-3. Repo picker, module picker, platform detect.
4. **Mock feasibility** (`multi-agent:design_mock_detect`): `false`: offer the **snapshot lane** (`captureLane = "snapshot"`, no in-app flips), declined or not renderable: **HALT** with `reason`, never fabricate a comparison. `"debug-only"`: warn, Continue / Cancel. `true`: persist `state.designCheck.mock`.
5. **Scenario inventory** (`multi-agent:design_scenario_inventory`) is the target set; persist verbatim. `truncated: true`: say so and pass `coverage.truncatedInventory: true` in Phase 4. `targetCount: 0`: only the default launch state is auditable. List `ignored[]`.
6-7. Scope resolve, `--resume`; confirm only above `coverage.confirmAbove` relaunches, as a cost estimate, never offering a smaller scope.
8-9. Report dir now; worktree `{projectRoot}/.worktrees/DC-<shortId>`, never under $HOME.

## Phase 1 - Build & launch

Debug build in the worktree, launch via `multi-agent:design_mock_launch`; Phase 3 relaunches, never rebuilds. Read `$HOME/.claude/multi-agent-refs/design-check/build-launch.md` for Phase 1.

## Phase 2 - Figma mapping

The only Figma discovery; later only a node the user hands over in 3.3. **Ambiguous or unmatched: defer to 3.3, never guess.** Read `$HOME/.claude/multi-agent-refs/design-check/figma-mapping.md` for Phase 2.

## Phase 3 - Drive, capture, match, compare

Iterate `scope.targetIds`; done when every id is resolved, not when taps run out. Before the first compare, read `$HOME/.claude/multi-agent-refs/features/design-conformance.md`.

- **3.1** Drive `inventory.plan` batch by batch; persist `state` and `run-state.json` after every capture. Unreachable: skip with a concrete reason. Read `$HOME/.claude/multi-agent-refs/design-check/drive-capture.md`.
- **3.2-3.4** Confident matches only; batch-ask everything unmatched ONCE, showing each live screenshot; compare all pairs (`tolerance_px: 2, color_tolerance: 3, max_diff_pct: 1.0`), sheets and modals with region alignment. **Edge insets are defects**: never raise `tolerance_px` to hide one. Read `$HOME/.claude/multi-agent-refs/design-check/compare.md`.
- **3.5** Every id ends covered or skipped; `covered + skipped` must equal `targetIds` before Phase 4.

## Phase 4 - Report and coverage gate

Use `state.designCheck.reportDir`. Pass ids, not counts; each variant carries `walk` with `didNotConverge` and `notVerified`. Export with `multi-agent:design_report` (Confluence only when enabled, via the `multi-agent-channels` adapter). Read `$HOME/.claude/multi-agent-refs/design-check/export.md` for Phase 4.

**Coverage gate (blocking)**: `pass`: report results and paths. `fail`: the run is **INCOMPLETE**; print `coverageError`, `unaccountedIds` and `/multi-agent-design-check --resume`. Never pad the covered list. Remove the worktree unless asked to keep it; never the report dir.
