# design-check - Phase 0 pickers, feasibility gate, inventory and setup

Detail for Phase 0 steps 1-9. The binding rules (halt conditions, confirmation, coverage) stay in the command's SKILL.md; this file carries the call shapes and the mechanics.

## Steps 1-3 - pickers and platform

1. **Repo picker** - reuse `_repo-picker.md` from the refs tree. The account picker is skipped (the Figma token is user-supplied and no Jira/GitHub fetch happens) unless Confluence export is enabled, in which case resolve the Confluence token via `account-resolver.sh`.
2. **Module / dev-context picker** - reuse `_dev-context.md`. Auto-suggest submodules from `.gitmodules` (`submodule-detector.sh`); the user selects the module to audit (multi-module allowed - each is audited independently).
3. **Platform detect** - `.xcodeproj` / `Package.swift` → iOS; `build.gradle*` → Android (same markers as `phase-0-init.md`). Persist `state.designCheck.platform`.

## Step 4 - mock feasibility gate call

```
mcp__multi-agent-toolkit__design_mock_detect({ repo_path: "<module path>", platform: "<ios|android>",
  extra_keys: <design-check-config mock.keys, if any> })
```

On `true`, persist `state.designCheck.mock = <detect result>` (mechanism, activation, variantsHint, evidence).

`"debug-only"` means mocks are compiled into the Debug build via `#if DEBUG` DI, so variants cannot be toggled at launch - only the default Debug state is comparable. The warning picker offers (label + description in `outputLanguage`): option 1 semantically "Continue" - audit the single default Debug state only; option 2 semantically "Cancel" - stop.

Snapshot lane (where the command offers it): a screen renderable from its own view model (filled, flow-advanced, no backend) is auditable without a runtime mock switch. Persist `state.designCheck.captureLane = "snapshot"`. The trade to state: snapshots reach modules mocks cannot, and cannot flip an in-app variant, so the target set is whatever the view model can be built into.

## Step 5 - scenario inventory call

```
mcp__multi-agent-toolkit__design_scenario_inventory({ repo_path: "<module path>", platform,
  targets_file:      <config inventory.targetsFile, omitted when unset>,
  extra_launch_args: <config inventory.extraLaunchArgs>,
  extra_targets:     <config inventory.extraTargets>,
  ignore_targets:    <config inventory.ignoreTargets> })
```

Returns `targets[]` - each `{ id, kind, label, screen, driver, cost, evidence }` - plus `plan[]`, `relaunchCount`, `groups[]`, `byKind`, `byCost`, `ignored[]`, `truncated`, `scanStrategy`.

Kinds: `launch-arg`, `scenario-case`, **`prefix-code`** (a mock repository branching on the prefix of the reference the user types - usually the LARGEST group, and the one a selector-only search misses entirely), `code-scenario`, `fixture`, `deep-link`.

Persist the result verbatim to `state.designCheck.inventory`.

## Step 6 - scope resolve

Intersect `$ARGUMENTS` (grammar in SKILL.md) with `inventory.targets`. Persist `state.designCheck.scope = { argument, targetIds[] }`. Print the resolved set grouped by screen with `<n> targets · <relaunchCount> relaunches`. Read the cost from `plan`, not from the target count - one relaunch serves every in-app target on that screen, so a 50-target module is typically a dozen relaunches.

## Step 7 - `--resume`

Read the most recent `~/DesignChecks/{repo}__{module}/*/run-state.json`; the scope becomes that run's targets minus its `covered` and minus its `skipped` entries. Skips carry a reason and are honoured, so a resume covers the genuinely unaudited remainder.

## Step 8 - report dir

Create `~/DesignChecks/{repo}__{module}/{UTC-timestamp}/` (and `assets/` inside it) and persist it as `state.designCheck.reportDir`. Phase 3 writes captures, comparison images and `run-state.json` into it, so it exists before driving starts, not at export time. This is report output, not a worktree; `$HOME` is intended here.

## Step 9 - worktree

Follow the `phase-0-init.md` Step 6 worktree location convention exactly: `{projectRoot}/.worktrees/{taskId}` with `taskId` = `DC-<shortId>`, never under `$HOME` (the `.worktrees` segment is fixed, not a preference). Stale-lock heal (`git worktree prune`) and residue guard (`.worktrees/` in `.git/info/exclude`) first. Local mode is not offered - the audit always uses a worktree checkout of the current branch's HEAD (no fetch/push).

Then persist `agent-state.json` with `taskId`, `mode: "design-check"`, `projectRoot`, `worktreePath` and `designCheck` (which carries `module` and `platform`).
