/useful-loops:prototype-from-mockup MOCKUP_DIR APP_DIRfrom useful-loops
This command should be used when the user asks to 'build prototype from mockup', 'implement mockup in the app', 'compare prototype against mockup', or 'close prototype gaps'. Runs one iteration: compares a real app prototype against an HTML/CSS/JS mockup, identifies gaps, and fixes them.
Ships in useful-loops. Installing the plugin adds it to Claude Code.
You are performing one complete prototype-from-mockup iteration. The mockup is the source of truth. You will deeply read both artifacts, perform a thorough gap analysis, and fix what's missing in the prototype. Report progress at each phase.
Parse the arguments: extract the MOCKUP_DIR path (a directory containing .html, .css, and .js files — the spec) and the APP_DIR path (the directory of the prototype app). Both are required.
Mockup directory: <MOCKUP_DIR>
App directory: <APP_DIR>
Prerequisite check: If either the mockup directory or the app directory does not exist, stop immediately and tell the user: "Both the mockup directory and the app prototype must already exist before running this skill. Please set up both first, then re-run." Do not create either artifact.
Build upon what exists: Do not impose a particular tech stack or architecture. Deeply understand the app's existing structure, conventions, dependencies, and patterns, then build upon them. If the app uses Supabase, use Supabase. If it uses plain React with local state, use that. Follow the app's lead.
Run Phases 1-5 once. If Phase 3 finds zero gaps, output the completion promise and stop.
Read docs/plans/prototype-from-mockup-tracking.md to find the last iteration number. Your iteration is N+1. If no iterations exist yet, you are iteration 1. If the tracking file does not exist, create it (run mkdir -p docs/plans first if the directory does not exist):
# Prototype from Mockup — Tracking
**Mockup directory:** <path>
**App directory:** <path>
**Stack:** <detected from app>
---
## Iteration Log
If this is iteration 2 or later, review the prior iteration entries in the tracking file. Understand what was already built so you do not re-tread the same ground or revert prior work.
Deep-read the mockup. Use an explorer agent to thoroughly read and understand the mockup directory. The agent should:
<MOCKUP_DIR>Deep-read the prototype. Use a second explorer agent (in parallel with step 3) to thoroughly read and understand the current prototype app. The agent should:
package.json to understand dependencies, scripts, and stackBoth agents should return detailed, structured inventories — not summaries. The gap analysis in Phase 3 depends on having complete information from both sides. If an agent hits context limits, it should return its partial inventory and note where it stopped so a follow-up agent can continue.
With both inventories in hand, create a reconciliation matrix. For each element the mockup contains, determine whether the prototype has it, partially has it, or is missing it entirely. Organize this by dimension:
| Mockup Element | Prototype Status | Gap? |
|---|---|---|
| ... | Present / Partial / Missing | YES / NO |
This matrix is your working document for Phase 3. It ensures nothing from the mockup is overlooked.
Walk through the reconciliation matrix and identify all gaps across six dimensions.
Does the prototype have routes for all pages/screens in the mockup? Look for:
/settings route)Are all UI components from the mockup implemented? Look for:
Does each page's structure match the mockup? Look for:
Does the prototype visually match the mockup? Look for:
Do interactive elements in the prototype match the mockup's behavior? Look for:
If the mockup displays data, is it properly represented in the prototype? Look for:
For each gap found, classify its severity:
If zero gaps are found across all six dimensions, skip to Phase 6 (signal).
If gaps were found, proceed to Phase 4.
Some mockup elements may have multiple valid implementations in the app's stack. Use AskUserQuestion for decisions that affect architecture:
AskUserQuestion:
question: "The mockup shows <element>. How should this work in the prototype?"
header: "Approach"
options:
- label: "<approach A> (Recommended)"
description: "<tradeoff explanation>"
- label: "<approach B>"
description: "<tradeoff explanation>"
- label: "Skip this for now"
description: "Defer to a later iteration"
Common decision points:
Only ask about genuinely ambiguous items — if the mockup clearly shows a simple interaction, just implement it.
Order the work for this iteration:
Cap at ~12 files changed per iteration. If more are needed, defer the lowest-priority remaining items.
Implement the prioritized gaps in the prototype:
Follow the app's conventions — use its existing component patterns, CSS approach, file organization, naming conventions, and data layer. Do not introduce new patterns or dependencies unless absolutely necessary. If the app uses Tailwind, translate mockup CSS to Tailwind classes. If the app uses CSS modules, create scoped stylesheets. Match what's already there.
Translate, don't copy-paste — the mockup uses vanilla HTML/CSS/JS. The prototype should use the app's stack idioms:
Preserve visual fidelity — the mockup is the spec. Colors, spacing, typography, and layout should match. Extract exact values from the mockup's CSS.
Wire up interactions — if the mockup has a working modal, the prototype's modal should work the same way. If the mockup has form validation, the prototype needs equivalent validation.
Build upon the existing data layer — use whatever data approach the app already has. If it has Supabase, use Supabase. If it has local JSON, use that. Do not introduce a new data layer.
After building, verify the prototype runs without errors:
cd <APP_DIR> && npm run build 2>&1 || true
cd <APP_DIR> && npm run lint 2>&1 || true
If build or lint fails, fix the issues. Max 3 fix attempts. If still failing, revert the problematic change and note it as deferred.
Append an iteration entry to docs/plans/prototype-from-mockup-tracking.md:
### Iteration N (YYYY-MM-DD)
**Gaps found:** X (Y HIGH, Z MEDIUM, W LOW)
**Gaps fixed:** A
**Deferred:** B
**User clarifications:** C
#### Dimensions Covered
- Pages & Routes: [summary]
- Components: [summary]
- Layout & Structure: [summary]
- Styling & Visual Fidelity: [summary]
- Interactions & State: [summary]
- Data & Backend: [summary]
#### Changes Applied
- [HIGH] Description of change (files: ...)
- [MEDIUM] Description of change (files: ...)
- [LOW] Description of change (files: ...)
#### Deferred
- [ ] Description (reason)
#### User Decisions
- "<question>" → "<user's choice>"
If gaps were found and fixed: exit normally. If running in a Ralph Loop, the loop will re-invoke for the next iteration.
If NO gaps were found across all six dimensions: output exactly:
<promise>PROTOTYPE_MATCHES_MOCKUP</promise>
Only output this promise if you genuinely compared every dimension and found nothing actionable.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
24 commands in this plugin
/beta-auditThis command should be used when the user asks to 'run a beta audit', 'check beta readiness', 'is the app ready for beta', or 'find beta-readiness gaps'. Runs one iteration: explores the app holistically for beta-readiness gaps, fixes code issues, collects manual to-dos, validates, PRs, runs CI, and merges./beta-audit-loopThis command should be used when the user asks to 'loop beta audit', 'keep auditing for beta readiness', or 'fix all beta issues'. Loops beta audit iterations until no HIGH/MEDIUM code findings remain. Requires ralph-loop plugin./ci-auditThis command should be used when the user asks to 'optimize CI', 'audit CI pipeline', 'speed up GitHub Actions', 'reduce CI time', 'make CI faster', or 'harden CI permissions'. Runs one iteration: analyzes 1-2 CI dimensions across multiple measurement axes (timing, billable minutes, hygiene, flakiness), applies fixes, re-measures, and merges./ci-loopThis command should be used when the user asks to 'loop CI audit', 'fully optimize CI', 'audit all CI dimensions', or 'do a full CI optimization sweep'. Loops CI audit iterations until all 9 dimensions are covered and no issues remain. Requires ralph-loop plugin./doc-refineThis command should be used when the user asks to 'refine a document', 'improve this doc', 'polish documentation', or 'apply a prompt to a document'. Runs one iteration: applies a prompt-driven analysis to a document, identifies improvements, and applies them./doc-refine-loopThis command should be used when the user asks to 'loop doc refine', 'keep refining a document', or 'iteratively improve documentation'. Loops doc-refine iterations until no further improvements are found. Requires ralph-loop plugin.npx claudepluginhub neonwatty/useful-loops --plugin useful-loops