## Workflow

Every governed CAD modification follows four stages in order:

Begin with Stage 1 — Target Discovery & Plan Update.

### Stage 1 — Target Discovery & Plan Update
Trigger: the user asks to change an existing governed model.
Action:
- If the governed target is already known, skip repository-wide discovery and shortlist confirmation.
- Discover plausible governed models inside current repository before guessing.
- Start with names, slugs, and file structure; only read additional artifacts when needed to clarify a shortlist.
- Present a short human-friendly shortlist and require explicit confirmation before editing any model.
- Use `npm:@juicesharp/rpiv-ask-user-question` for shortlist confirmation when structured UI is available; otherwise fall back to normal prose.
- If repo-only discovery finds no plausible governed model, stop safely, refuse to guess, and offer to start a new design workflow instead.
- Once the target is known, inspect `plans/<model_slug>/plan.md` plus the current `models/<model_slug>/` and affected `tests/<model_slug>/` artifacts before asking new questions.
- Ask only lean blocking questions needed to complete the change safely.
- Update the canonical `plans/<model_slug>/plan.md` in place before changing code.
Output: confirmed target model plus refreshed `plans/<model_slug>/plan.md`.

### Stage 2 — Research
Trigger: the target model is confirmed and the updated plan is ready for a research decision.
Action: invoke skill `build123d-research`.
- Skip Stage 2 entirely when the updated plan plus existing model/test artifacts already answer the change.
- Reuse research only when the requested change introduces real uncertainty.
- Keep any new research tightly scoped to the changed behavior and reuse existing repository context first.
Output: targeted research artifacts in `research/<model_slug>/` when research runs.

### Stage 3 — Script Authoring
Trigger: `build123d-research` has completed, whether it produced new artifacts or skipped research as unnecessary.
Action: invoke skill `cad-script-authoring`.
- Modify the existing model in place and update only affected tests.
Output: updated model script in `models/<model_slug>/` + focused test updates in `tests/<model_slug>/`.

### Stage 4 — Review Loop
Trigger: the updated model script exists, affected tests pass, and it has not been reviewed.
Action: invoke skill `cad-review-loop`.
- Final workflow completion requires one successful preview handoff after the reviewed delivery artifact is ready.
- Run the final preview handoff only after review fixes are committed and the delivery artifact is ready, not during exploratory spikes, scratch work, or intermediate runs.
- Use the live build123d result for that handoff via `primus preview models/<model_slug>/<name>.py`; the command attempts browser open, always prints the preview URL, and does not block on the viewer session after launch.
- Do not trigger the final preview handoff during exploratory spikes, scratch work, or intermediate runs.
- If preview launch fails, keep the final code and commit intact but report the workflow as incomplete until preview succeeds.
Output: reviewed, fixed, and committed updated script plus exactly one successful preview handoff for final delivery.
