--- name: figma-driven-flutter-mvp description: Use when implementing a Flutter MVP from Figma designs. version: 1.0.0 author: HamaratLabs license: MIT --- # Figma-Driven Flutter MVP Use this skill when a Flutter product must be implemented from existing Figma screens rather than inferred from generic product notes. ## Always-on rules - **Phone viewport first.** Develop and visually verify at roughly 390×844 (Pixel 5), never at desktop width. Capture evidence screenshots at that size. - **Real Figma frames are the source of truth.** Do not continue visual implementation from assumptions; if design access is missing, stop and obtain it rather than inventing UI. Run the UX/design, architecture and QA checkpoints, and revise the plan whenever a checkpoint finds a mismatch instead of polishing past it. - Treat the actual Figma file and selected frame links as the visual source of truth; when the user explicitly supplies a screen screenshot as the current design contract, use that screenshot for the named screen, record inferred values as provisional, and do not replace it with generic Material UI. - The user can explicitly demote Figma to UX/flow-only and designate a different artifact (a generated promo video, a storyboard, a mockup) as the sole source for all visual decisions (color, texture, motion feel, typography, iconography). When this happens, stop deriving colors/styling from Figma tokens already extracted and re-derive them from the new source instead; keep using Figma only to decide which screens exist and how they flow. Confirm the scope with the user in one clarifying question before a large-scale re-skin (e.g. "colors only" vs "full illustration style on every screen") — the two are very different amounts of work. - Establish Figma access before making visual implementation decisions. If the user says the implementation does not resemble their designs, stop UI polishing, reopen the design checkpoint, and inspect real frames first. - Prefer Figma Remote MCP for normal accounts and unattended work. Use the Desktop MCP only when the Figma account actually exposes the desktop-server toggle; do not instruct the user to search for a UI control that is not visible in their account. - Do not enable or authorize every third-party agent by default. Connect only the agent that will inspect or implement the design, then verify its tools before proceeding. - Keep a provisional branding/UI document explicitly provisional until it has been reconciled with real Figma frames. - Separate design evaluation from implementation: the design agent produces tokens, states, component rules, and frame mappings; the coding agent integrates them into Flutter; QA verifies visual and behavioral acceptance. - Use checkpoint gates. Do not mark a visual checkpoint complete until frame inventory, tokens, responsive behavior, accessibility, and implementation deltas are recorded. - When the product's design language rejects stock Material widgets, treat it as a standing, non-negotiable constraint, not a one-screen note. Never leave `AlertDialog`, `showDialog`, `DropdownButtonFormField`, bare `TextField`/`TextFormField`, `SnackBar`/`ScaffoldMessenger`, `Card`, `ListTile`, `ElevatedButton`, `TextButton`, `OutlinedButton`, `FilledButton`, or `CircularProgressIndicator` in a screen you touch, even ones outside the immediate task — grep the whole `lib/` tree for these identifiers before calling a design-language pass done. Build one small shared organic component set early (a themed button, text field, and dialog wrapper reusing the project's existing organic visual primitives — blob paths, brand fonts, brand colors) and reuse it everywhere instead of hand-styling each screen; this both satisfies the constraint and keeps the result visually consistent. Native pickers with no reasonable custom replacement (e.g. `showDatePicker`) may stay, but only the picker itself — the button/row that triggers it must still be organic. - A bare numeric `TextField` for a duration/count value (work minutes, break minutes, pomodoro block count, daily goal) is a UX defect even once it is visually organic: The user cannot see what the number means until they stop and calculate. Replace every such field with a stepper widget ("− value unit +") and, whenever the value composes into a larger total (work × blocks + breaks), show a live derived summary line under it (e.g. "≈ 1h 25m total incl. breaks") that recomputes on every tap — build this once as a shared component and reuse it for every duration/count input in the app rather than hand-rolling per screen. Give the increment/decrement buttons distinct `Semantics(label: '$label artır/azalt', button: true)` wraps (field name baked into the label) so widget tests can target one specific stepper's buttons by label instead of counting `find.byType` indices, which breaks the moment another numeric field is added or removed anywhere on the screen. - Preserve the product's functional semantics while matching the design. For a timer where pausing means an unplanned break, the UI must label and visually represent that state: the inner ring becomes fully red and starts at zero elapsed break time, the red outer segment grows as the break continues, and the total end time moves later; do not silently reinterpret it as a generic pause. - Keep timer ring scopes separate: the inner ring represents only the active Pomodoro duration (for example, 25 minutes or a custom 1-hour duration); the outer ring represents the selected Pomodoro plan, not an accidental count of historical sessions. A generic Pomodoro starts with 3 work blocks and 2 planned breaks; a Pomodoro launched with a daily target uses that target's work-block count and one fewer planned break. Store the selected plan with the session so reloads and state changes preserve the same ring. - Verify actual artifacts and commands. A successful MCP install is not proof of OAuth authorization, and an agent's design report is not proof that the Flutter UI matches the file. - Run every MVP slice through the explicit loop **Test → Analyse → Plan → Action → re-test**. Write the failing acceptance/regression test before production changes, use analysis and agent audits to expose gaps, write the bounded plan and exit condition, then implement and re-run the gate; do not call the MVP complete while any named gate remains open. - Ask the user before resolving any product, scope, data-model, language, or visual decision that changes behavior. Record the answer in the plan/design contract; do not turn a temporary assumption into a final UI rule. - In status reports, distinguish completed work from paused work and background execution: do not imply that work continued between messages unless a verified background job actually ran. Report concise status in the user's language with exact verification output and explicit remaining blockers. - Route planning and high-stakes implementation to the strongest available Claude coding model with high reasoning when configured; use GPT/Luna as orchestrator or fallback rather than silently treating one model as universally best. Record the actual model/provider used for each active agent and verify the setting before claiming the route changed. - When the user rejects a screen as generic or rushed, treat the screenshot as a failed visual gate: stop calling the MVP complete, extract concrete deltas, revise the shared design system, and re-capture the affected 390×844 screen before moving to another feature. - Keep timer controls out of the permanent composition when the visual contract calls for an immersive timer: reveal them as a tap-triggered translucent/Liquid-Glass overlay, show only state-valid actions (for example, start break, resume, stop), and test both reveal and auto-hide behavior. - Render one primary countdown only. Do not repeat the same time as minutes, a second minutes value, and `mm:ss`; phase/block metadata must be a separately labeled secondary value. - Give outer-ring segments a mathematically explicit angular gap and non-overlapping stroke geometry; rounded caps at adjacent segment boundaries are not a substitute for spacing and must be screenshot-checked at the top join and every segment boundary. Concretely: use `StrokeCap.butt` (not `.round`) on segment paints and carve a real gap (~4-5% of the ring's path length per segment) out of `PathMetrics.extractPath` before drawing each segment — round caps on adjacent short segments visually blob together into a solid ring even when the underlying angles are technically separate. - Perform web QA at a phone viewport around 390×844, click each named MVP screen, capture evidence, and verify navigation state, persistence, keyboard/form behavior, and console/runtime cleanliness before closing the UI gate. - For a user-testable link, serve the completed `build/web` release output with a static HTTP server (for example `python3 -m http.server 8090 --bind 127.0.0.1 --directory build/web`) after `flutter build web`. To reach it from a phone, bind only to a trusted private network address (e.g. your overlay/VPN IP), never `0.0.0.0` on a shared network, and stop the server when testing ends; do not hand the user a debug `flutter run -d web-server` URL while its Dart bundle is still compiling. - Before declaring any screen done, diff its actual chrome (nav bars, tab bars, extra buttons, dialogs) against the real Figma frame inventory element-by-element. A prior coding session can silently invent navigation (e.g. an extra bottom tab bar) that has no basis in any frame or user request; this passes analyze/test/build cleanly because it is functionally harmless, so only a frame-by-frame visual diff catches it. Remove anything not traceable to a frame or an explicit user ask. - If a project has no design/context MD file (branding, UI standards, or design-source doc) when a design-capable agent starts work on it, the agent must create one first — by inspecting the real Figma frames or, if none are available, by asking the user — never by inferring branding from a generic screenshot or Material defaults. ## Procedure 1. **Confirm the source and boundary** - Read the project Figma link from the project's source notes. - Ask for or use a file/frame/selection URL with a node ID when possible; a whole-file link is a fallback. - Record the source in a repo design-source document. 2. **Choose the MCP path** - For Figma Remote MCP, install/configure the supported agent integration and complete OAuth in the user's own browser session. - For Hermes, `hermes mcp install figma` installs the remote endpoint; the user completes `hermes mcp login figma --flow browser` interactively. - Test the connection after authentication; never claim access from installation output alone. - Use the local endpoint `http://127.0.0.1:3845/mcp` only after the Figma Desktop app visibly exposes and confirms the Desktop MCP server. Local mode requires Figma Desktop to remain open. 3. **Run the design checkpoint before coding UI** - Have the UX/artist agent inspect the real frames and return: screen inventory, user flows, semantic color tokens, typography, spacing, radii, components, state variants, responsive rules, accessibility constraints, and exact deviations from the current Flutter UI. - Have the technical agent map each frame to Flutter surfaces and identify constraints that affect the domain/state model. - Keep reports non-destructive until the orchestrator resolves conflicts and updates the plan. 4. **Write the design contract** - Update `BRANDING.md` and `UI_STANDARDS.md` with frame-derived values and rationale. - Mark unknown values as open decisions instead of filling them with Material defaults. - Add the design checkpoint and its acceptance criteria to `CHECKPOINTS.md` and `TECHNICAL_PLAN.md`. 5. **Implement in vertical slices** - Build the shared theme/tokens first. - Implement the primary screen and its empty, active, break, completed, and error states. For ring-based timer designs, model the inner ring from the active session's planned duration and model the outer ring from the session's selected plan: generic = 3 work + 2 breaks, daily target = target work + target-minus-one breaks. Keep the visual state derived from the domain clock rather than hardcoded display values. - Then implement persistence, reports, and secondary screens without changing the approved visual language. - Keep domain/state logic independent from Flutter widgets and test timer semantics with an injected clock. - To manually exercise a multi-minute timer/session flow in a live browser without waiting real minutes, add one named constant (e.g. `kMinuteToSecondFactor`, normally 60) that all minute-to-duration conversions multiply through, temporarily set it to 1 for the test session, and set it back to 60 before finishing — grep for any other literal `* 60` conversions that bypass the constant so the speed-up is actually total, and rerun `flutter test` after reverting since tests assert against the real 60x timing. 6. **Review and revise at gates** - After each slice, run the relevant design agent, technical agent, and QA agent, each with a bounded read-only audit. - Apply plan revisions centrally; agents do not edit the same source files concurrently. - Re-run the affected checkpoint after every material design or state-machine change. - When a slice replaces a stock widget with a custom one (dropdown → chips, `FilledButton` → a custom `Material`/`InkWell`), grep the test tree for finders that target the old widget type or its default text (`find.widgetWithText(FilledButton, ...)`, a label that lived only in a `DropdownMenuItem`) before calling the slice done — hand-authored widget tests reference the concrete widget type and silently fail on the next `flutter test` run otherwise. Update finders to the new structure (`find.text`, `find.bySemanticsLabel`) in the same commit as the widget change, not as an afterthought. 7. **Verify the release candidate** - Run `flutter analyze`, `flutter test`, and `flutter build web`. - Run a Chrome smoke flow covering the real frame's primary path, refresh/reload persistence, responsive widths, keyboard navigation, and the timer's break semantics. - Before trusting a `flutter run -d chrome --web-port=N` screenshot as reflecting the latest code edit, confirm the PID actually listening on that port (`lsof -i :N`) matches the process you just launched. A plain `pkill -f "flutter run"` can fail to kill an already-detached dartvm that still holds the port; the new launch then silently coexists or fails, and every subsequent screenshot keeps showing the pre-edit build even after a full page reload. Use `kill -9` on the old PID (or `pkill -9`) and re-verify the port owner before re-screenshotting. - Parse the downloaded export artifact, then instantiate a fresh controller after reset to verify the persisted store is empty; a download event or in-memory clear alone is not sufficient. - Separate Flutter Web debug-engine viewport/keyboard assertions from application failures by rerunning the same flow against the static release build and recording the exact environment. - Record what was actually verified and keep unverified browser or device checks open rather than calling the MVP finished. - Flutter Web hides its real DOM `` elements behind the semantics layer, so a generic DOM-based typing helper silently does nothing; after clicking into the field, type with `cdp('Input.dispatchKeyEvent', type='char', text=ch)` one character at a time instead. - `cdp('Emulation.setDeviceMetricsOverride', ...)` for a phone-sized (390x844) viewport is reset by any navigation through `about:blank` (including some tab-reset helpers); re-apply the override after every navigation, not just once at the start of a browser session, or later screenshots silently revert to desktop width. - After a large delegated refactor/migration pass (design-language rewrite, widget-library swap), grep the touched directory for classes/screens that are defined but never referenced before extending or trusting the pass as complete — an agent doing a sweeping rewrite can leave an old, unreferenced implementation of a screen or dialog behind instead of deleting it, and it will not show up in `flutter analyze`/`flutter test` since dead code compiles cleanly. - Never add a continuously repeating `AnimationController` (`..repeat()`, a breathing/idle-pulse loop) to a screen's build tree just for ambient motion — `tester.pumpAndSettle()` waits for animations to stop and hangs/times out on any widget test that pumps that screen, even tests unrelated to the animation. Drop the ambient loop or drive it only from a real, boundable event (a single play-once controller) so widget tests settle. - When the user has already rejected one delegated agent's design-language pass on a screen as not matching the source (video/mockup) closely enough and explicitly asks for a specific model/agent (e.g. Claude directly) to redo it, treat that as a routing override for this screen: do the redo yourself/with the named agent rather than re-delegating to the same agent that already missed the mark, even though delegation is otherwise the default for large visual-migration passes. See `references/figma-mcp-and-checkpoints.md` for the connection decision table and checkpoint report template.