|
1 | 1 | --- |
2 | 2 | name: design-system-review |
3 | | -description: AI-augmented design review with a 2-iteration guard, sequential memory, and KI persistence. |
| 3 | +description: > |
| 4 | + AI-augmented design review with a strict 2-iteration guard, sequential memory |
| 5 | + persistence, and KI creation. Enforces Shadcn/Radix token alignment, layout |
| 6 | + fidelity against the Figma frame, and coordinates designer quality gates. |
| 7 | +cost: ~1400 tokens |
| 8 | +modes: [read-only, write, mcp] |
| 9 | +surface: public |
4 | 10 | --- |
5 | 11 |
|
6 | | -// turbo-all |
| 12 | +# Design System Review (Iteration Guard) |
7 | 13 |
|
8 | | -**CRITICAL: PHASE 0 - SKILL ACQUISITION IS NON-NEGOTIABLE.** |
9 | | -**YOU MUST CALL THE GET_SKILLS TOOL EVEN IF YOU ALREADY HAVE THE CONTEXT. FAILURE TO DO SO BYPASSES MISSION TELEMETRY.** |
| 14 | +## Runtime modes |
10 | 15 |
|
11 | | -1. **Phase 0: Skill Acquisition**: Call the `get_skills` tool (which may be prefixed as `mcp_tech-lead-stack_get_skills` or `tech-lead-stack_get_skills` depending on client prefixing): |
12 | | - - skillName: "" |
13 | | - - projectName: "<YOUR_CURRENT_PROJECT_NAME>" |
14 | | - - model: "<YOUR_MODEL_NAME>" |
15 | | - - agent: "<YOUR_AGENT_NAME>"<YOUR_AGENT_NAME>"` |
| 16 | +Produces a verifiable design blueprint in read-only chat, and executes + |
| 17 | +verifies the audit phase in an IDE/MCP agent. |
16 | 18 |
|
17 | | ---- |
| 19 | +> [!IMPORTANT] **Iteration Discipline**: This skill enforces a hard |
| 20 | +> **2-iteration limit**. Iteration 1 produces feedback. Iteration 2 verifies |
| 21 | +> fixes. If alignment is not reached by Iteration 2, the component is escalated |
| 22 | +> — NOT reviewed a 3rd time. Context must be persisted to a scratch file at the |
| 23 | +> start of every session so iteration count survives chat resets. |
| 24 | +> |
| 25 | +> [!IMPORTANT] **Credential Protocol**: If an external tool (Chromatic, Figma) |
| 26 | +> is required during the audit, PAUSE execution, prompt the user for |
| 27 | +> credentials, wait for their response, then resume. Never assume credentials |
| 28 | +> are available. Never hard-code or log credential values. |
| 29 | +> |
| 30 | +> **Methodology Alignment**: This skill strictly adheres to the four core |
| 31 | +> pillars: **G-Stack Ethos**, **MinimumCD**, **Agent Skills**, and **Modern Web |
| 32 | +> Guidance**. |
18 | 33 |
|
19 | | -## Phase 1: Sequential Memory Init |
| 34 | +## 🎯 Verification Gates |
20 | 35 |
|
21 | | -Before any analysis, use the `sequential-thinking` tool to initialize your |
22 | | -session context: |
| 36 | +### Phase 0: Tech-Stack Discovery (MANDATORY) |
23 | 37 |
|
24 | | -1. **Thought 1** — Identify the `sessionId` from the user message. |
25 | | -2. **Thought 2** — Fetch the current session state via the local API: |
26 | | - `curl http://localhost:3000/api/design-review/session/<sessionId>` |
27 | | - - Restore iteration count, current status, and check if a `figmaUrl` was provided. |
28 | | -3. **Thought 3** — Confirm: "Session initialized. Iteration N. Status: X." |
| 38 | +- **Skill Usage Enforcement (NON-NEGOTIABLE):** |
| 39 | + - **FORBIDDEN:** Direct file access via `view_file` or `run_command` is |
| 40 | + strictly prohibited without first calling the skill tool. |
| 41 | + - **IDE / MCP-enabled Agent:** You MUST call the MCP `get_skills` tool (which |
| 42 | + may be prefixed as `mcp_tech-lead-stack_get_skills` or |
| 43 | + `tech-lead-stack_get_skills` depending on client prefixing). |
| 44 | + - **Chat UI (/chat):** You MUST call the internal `get_skill` tool. |
29 | 45 |
|
30 | | ---- |
| 46 | +- **Action:** Identify the project's UI foundation. |
| 47 | +- **Target Files:** Inspect `package.json`, `components.json` (Shadcn config), |
| 48 | + `tailwind.config.*`, and `globals.css`. |
| 49 | +- **Confirm:** Which Shadcn/Radix primitives are installed? What Tailwind token |
| 50 | + namespace is in use (`--color-*`, `--spacing-*`, etc.)? |
| 51 | +- **MANDATORY Guardrail:** Focus ONLY on UI/design configuration. Ignore |
| 52 | + unrelated logic, auth, and infrastructure files. Avoid Goal Drift. |
31 | 53 |
|
32 | | -## Phase 2: Existing KI Check |
| 54 | +### Phase 0.5: Session Memory Init (MANDATORY — runs before Phase 1) |
33 | 55 |
|
34 | | -Before auditing, search for past design decisions on this component: |
| 56 | +Before doing ANY analysis: |
35 | 57 |
|
36 | | -1. Call `list_knowledge_items` with the current project name. |
37 | | -2. Look for any slug matching `design-decision-<component-name>-*`. |
38 | | -3. If found: call `read_knowledge_item` and incorporate the past decision |
39 | | - into your audit context so you don't contradict approved deviations. |
| 58 | +1. **Check for existing session file:** |
| 59 | + - Path pattern: |
| 60 | + `scratch/design-review/<project-name>/session-<YYYY-MM-DD>.md` |
| 61 | + - If a file for today exists, READ it to restore iteration count and |
| 62 | + component state. |
| 63 | + - If no file exists, CREATE it with this template: |
40 | 64 |
|
41 | | ---- |
| 65 | +```markdown |
| 66 | +# Design Review Session |
42 | 67 |
|
43 | | -## Phase 3: Run the Audit (Follow Skill Gates) |
| 68 | +- project: <project-name> |
| 69 | +- component: <component-being-reviewed> |
| 70 | +- started: <ISO timestamp> |
| 71 | +- iteration: 1 |
| 72 | +- status: IN_PROGRESS |
| 73 | +- figma_url: (not provided) |
| 74 | +- chromatic_build: (not provided) |
44 | 75 |
|
45 | | -Execute the full skill workflow (Phase 0 → Gate 5): |
| 76 | +## Iteration 1 — Findings |
46 | 77 |
|
47 | | -- Use `sequential-thinking` to track each gate result as a separate thought. |
48 | | -- After each gate: record PASS / FAIL and the specific evidence. |
49 | | -- After Gate 4 (Storybook/Figma): If a `figmaUrl` exists in the session, verify against it. If NO Figma URL exists, evaluate the component purely based on base Shadcn/Radix foundations and the project's brand tokens. |
50 | | -- After Gate 5 (Chromatic): pause if credentials are needed, wait for user. |
51 | | -- Update the session state via the API (using `PATCH /api/design-review/session/<sessionId>`) after all gates are complete. |
| 78 | +(populate after audit) |
52 | 79 |
|
53 | | ---- |
| 80 | +## Iteration 2 — Verification |
| 81 | + |
| 82 | +(populate after fix) |
| 83 | + |
| 84 | +## Decision |
| 85 | + |
| 86 | +(populate on completion) |
| 87 | +``` |
| 88 | + |
| 89 | +1. **Report to user:** "Session file created/restored. Currently at Iteration |
| 90 | + **N**. Resuming from: `<status>`." |
| 91 | + |
| 92 | +### Gate 1: Token Alignment |
| 93 | + |
| 94 | +- **Positive (Pass):** Colors, spacing, radius, and typography use the project's |
| 95 | + defined Tailwind variables or CSS custom properties. No arbitrary values like |
| 96 | + `text-[#3a3a3a]` or `p-[13px]`. |
| 97 | +- **Negative (Fail):** Hard-coded hex values, magic pixel values, or inline |
| 98 | + styles that bypass the token system. |
| 99 | +- **Action on Fail:** List every violation with the file + line reference. |
| 100 | + Propose the correct token replacement. |
| 101 | + |
| 102 | +### Gate 2: Shadcn/Radix Primitive Alignment |
| 103 | + |
| 104 | +- **Positive (Pass):** Component uses the appropriate `@gilly-ui` primitive |
| 105 | + (Button, Dialog, Select, etc.) as its base. Radix accessibility attributes |
| 106 | + (`aria-*`, `data-state`, keyboard handlers) are present. |
| 107 | +- **Negative (Fail):** Custom HTML elements used where a Shadcn primitive |
| 108 | + exists; missing focus management or keyboard navigation. |
| 109 | +- **Action on Fail:** Identify the correct primitive and provide a migration |
| 110 | + snippet. |
| 111 | + |
| 112 | +### Gate 3: Logic Consistency |
54 | 113 |
|
55 | | -## Phase 4: Iteration Decision |
| 114 | +- **Positive (Pass):** Component follows Early Returns, no mixed UI/data logic, |
| 115 | + Zod validation on inputs, no `any` types. |
| 116 | +- **Negative (Fail):** Nested conditionals instead of early returns, inline |
| 117 | + fetch calls, missing error boundaries. |
56 | 118 |
|
57 | | -**When the audit is complete (Score < 90%):** |
| 119 | +### Gate 4: Layout Fidelity (MANDATORY for any UI-facing change — BLOCKING) |
58 | 120 |
|
59 | | -- Present the "Must Fix" list (🔴 Critical / 🟡 Recommended / 🟢 Advisory). |
60 | | -- Instruct the user: "Apply these fixes, then reply `/design-system-review iterate` to trigger the next iteration." |
61 | | -- **STOP here.** Do not proceed until the user responds. |
| 121 | +This gate exists because token alignment and primitive alignment do NOT prove the |
| 122 | +built UI matches the design. A component can use every correct token and Shadcn |
| 123 | +primitive and still be the wrong width, the wrong proportions, or reflow its |
| 124 | +sub-elements incorrectly. Layout requirements stated in prose ("side by side", |
| 125 | +"wider", "stacked") are CONSEQUENCES of building to the frame, never the |
| 126 | +instruction. Build to the frame; the prose is a hint, the frame is the spec. |
62 | 127 |
|
63 | | -**On subsequent iterations (`/design-system-review iterate`):** |
| 128 | +- **Fetch the design source at review time (NON-NEGOTIABLE):** Retrieve the |
| 129 | + specific Figma node for this component via the Figma MCP `get_figma_data` tool |
| 130 | + — the actual frame, not a prose summary or a Phase-0 recollection. The frame's |
| 131 | + measurements ARE the acceptance criteria. Follow the **Credential Protocol** in |
| 132 | + the header if the Figma MCP is not yet authenticated. |
| 133 | + - If no Figma node/URL is available for this component, do NOT silently pass. |
| 134 | + Mark this gate `BLOCKED — no design source` and escalate per Gate 5 |
| 135 | + (Design Debt); a UI change with no design source cannot be verified as |
| 136 | + matching the design. |
| 137 | +- **Render the built result:** Capture the implemented component (delegate to |
| 138 | + `visual-verifier` for the actual capture at the mandatory Desktop/Tablet/Mobile |
| 139 | + resolutions). For interactive screens, exercise the relevant states |
| 140 | + (default, focus, error, loading). |
| 141 | +- **Produce an itemised Layout Deviation Report** comparing built vs frame. Each |
| 142 | + line is **MATCH** or **DEVIATION** with the specific difference: |
| 143 | + - Container / card width and max-width at each breakpoint. |
| 144 | + - Column widths and gaps for multi-column areas (e.g. side-by-side fields). |
| 145 | + - Element placement and vertical rhythm (label → input → helper/error spacing). |
| 146 | + - Responsive reflow: how sub-elements (helper text, requirement lists, labels) |
| 147 | + rearrange across breakpoints — a single list must not fragment across columns |
| 148 | + unless the frame shows it that way. |
| 149 | + - Button width, alignment, and inline-link placement. |
| 150 | +- **Positive (Pass):** Every line in the Layout Deviation Report is MATCH across |
| 151 | + Desktop, Tablet, and Mobile. |
| 152 | +- **Negative (Fail):** Any DEVIATION line. A DEVIATION is a 🔴 **Critical** |
| 153 | + finding — it BLOCKS completion. The component returns to the developer with the |
| 154 | + report until it is all-MATCH, or a specific deviation is explicitly waived by |
| 155 | + the Tech-Lead at a gate (record the waiver in the session file). |
| 156 | +- **Action on Fail:** List each DEVIATION with the frame's target value vs the |
| 157 | + built value (e.g. "card max-width: frame 1100px, built ~720px"), and the |
| 158 | + concrete fix. Paste the final all-MATCH report as the gate's evidence. |
64 | 159 |
|
65 | | -- Re-fetch the session state to confirm the current iteration count. |
66 | | -- Re-run only failed gates. |
67 | | -- Calculate the new alignment score. |
68 | | -- *Note:* There is a minimum of 2 iterations required, but you may scale upwards as needed to reach UI parity. |
69 | | -- Branch: |
70 | | - - **≥ 90%** → Call `create_knowledge_item` → `PATCH` status to `READY_FOR_DESIGNER_GATE` |
71 | | - - **Still failing after multiple attempts & stuck** → `PATCH` status to `ESCALATED` and write to `docs/design-debt.md` |
| 160 | +> [!CAUTION] **Test-pass is not design-pass.** `check-types` and unit tests |
| 161 | +> passing say nothing about visual fidelity. A UI-facing change is NOT complete |
| 162 | +> until this gate's Layout Deviation Report is all-MATCH (or an explicit |
| 163 | +> Tech-Lead waiver is recorded). Never mark a UI slice complete on tests alone. |
| 164 | +
|
| 165 | +### Gate 5: Storybook Figma Link Validation |
| 166 | + |
| 167 | +- **Action:** Check if the component has a Storybook story file |
| 168 | + (`*.stories.tsx`). If yes, verify it has `addon-designs` parameters with a |
| 169 | + Figma URL. |
| 170 | +- **If Figma URL is missing:** |
| 171 | + - Ask: "Do you have a Figma frame URL for this component? (Paste it here or |
| 172 | + press Enter to skip)" |
| 173 | + - If provided: update the session file with `figma_url` and include it in |
| 174 | + audit output. |
| 175 | + - If skipped: flag as "Design Debt — No Figma link" in the session file. |
| 176 | + |
| 177 | +### Gate 6: Chromatic / Visual Regression (Optional, credentials required) |
| 178 | + |
| 179 | +- **Trigger:** Only runs if the user has connected a Chromatic build. |
| 180 | +- **Credential Protocol:** |
| 181 | + 1. Prompt: "To run Chromatic validation, I need your |
| 182 | + `CHROMATIC_PROJECT_TOKEN`. Please paste it here (it will only be used for |
| 183 | + this session and not stored)." |
| 184 | + 2. **PAUSE** — do not proceed until user responds. |
| 185 | + 3. On receipt: use the token to reference the build; report the build URL and |
| 186 | + whether all stories passed visual review. |
| 187 | + 4. If user declines: mark Chromatic gate as "SKIPPED — manual review |
| 188 | + required." |
72 | 189 |
|
73 | 190 | --- |
74 | 191 |
|
75 | | -## Phase 5: Persistence |
| 192 | +## 🔄 Iteration Management |
76 | 193 |
|
77 | | -On **any** session completion (pass or escalation): |
| 194 | +### Iteration 1 — Full Audit |
78 | 195 |
|
79 | | -- Final `sequential-thinking` thought: summarize the full session outcome. |
80 | | -- Update the session state using: |
81 | | - `curl -X PATCH http://localhost:3000/api/design-review/session/<sessionId> -H "Content-Type: application/json" -d '{"status": "<STATUS>", "alignmentScore": <SCORE>, "gateResults": [...]}'` |
82 | | -- If `READY_FOR_DESIGNER_GATE`: call `create_knowledge_item` with the KI |
83 | | - schema from the skill. |
84 | | -- If `ESCALATED`: append a new entry to `docs/design-debt.md`: |
| 196 | +1. Run Gates 1–6 (in order). Gate 4 (Layout Fidelity) is BLOCKING for any |
| 197 | + UI-facing change. |
| 198 | +2. Produce a **"Must Fix"** list sorted by severity: |
| 199 | + - 🔴 **Critical** — Accessibility failure or token violation blocking release |
| 200 | + - 🟡 **Recommended** — Code consistency and design alignment |
| 201 | + - 🟢 **Advisory** — Nice-to-have improvements |
| 202 | +3. Update session file `Iteration 1 — Findings` section. |
| 203 | +4. Ask: "I've completed Iteration 1. Apply these fixes, then reply |
| 204 | + `/design-system-review iterate` to trigger Iteration 2 verification." |
85 | 205 |
|
86 | | -```markdown |
87 | | -## [YYYY-MM-DD] <Component Name> |
| 206 | +### Iteration 2 — Fix Verification |
| 207 | + |
| 208 | +1. Re-read session file to confirm we're at Iteration 2. |
| 209 | +2. Re-run only the **failed** gates from Iteration 1. |
| 210 | +3. Calculate alignment score: `(gates_passed / total_gates) * 100`. |
| 211 | +4. **Decision branch:** |
| 212 | + - **Score ≥ 90%** → Mark as `READY_FOR_DESIGNER_GATE`: |
| 213 | + - Update session file `status: READY_FOR_DESIGNER_GATE` |
| 214 | + - Call `create_knowledge_item` with the decision summary (see KI schema |
| 215 | + below) |
| 216 | + - Notify: "✅ Component is ready for designer gate review." |
| 217 | + - **Score < 90%** → Mark as `ESCALATED`: |
| 218 | + - Update session file `status: ESCALATED` |
| 219 | + - Create a `DESIGN_DEBT` entry in `docs/design-debt.md` |
| 220 | + - Notify: "⚠️ 2 iterations reached without 90% alignment. Escalated to |
| 221 | + manual designer review queue. A Design Debt record has been created." |
| 222 | + |
| 223 | +--- |
88 | 224 |
|
89 | | -- **Status**: ESCALATED |
90 | | -- **Alignment Score**: N% |
91 | | -- **Unresolved Gates**: <list> |
92 | | -- **Session ID**: `<sessionId>` |
93 | | -- **Action Required**: Manual designer review |
| 225 | +## 📦 Knowledge Item Schema |
| 226 | + |
| 227 | +When a review reaches `READY_FOR_DESIGNER_GATE`, call `create_knowledge_item` |
| 228 | +with this structure: |
| 229 | + |
| 230 | +```json |
| 231 | +{ |
| 232 | + "slug": "design-decision-<component-name>-<YYYY-MM-DD>", |
| 233 | + "summary": "One-line summary of what was approved or what deviation was accepted.", |
| 234 | + "projectName": "<detected-project-name>", |
| 235 | + "tags": ["design-system", "ui-review", "shadcn"], |
| 236 | + "artifacts": [ |
| 237 | + { |
| 238 | + "name": "decision-details.md", |
| 239 | + "content": "## Component\n<component-name>\n\n## Decision\n<approved/deviated>\n\n## Rationale\n<why>\n\n## Figma URL\n<url or N/A>\n\n## Chromatic Build\n<url or SKIPPED>\n\n## Gates Passed\n<list>\n\n## Alignment Score\n<N>%" |
| 240 | + } |
| 241 | + ], |
| 242 | + "references": ["<PR link if known>", "<Storybook story URL if known>"] |
| 243 | +} |
94 | 244 | ``` |
95 | 245 |
|
96 | 246 | --- |
97 | 247 |
|
98 | | -*Companion skills: Always run `style-logic-exporter` first to extract current |
99 | | -token state. Run `accessibility-auditor` in parallel for WCAG coverage.* |
| 248 | +## 🔍 Critical Patterns to Detect |
| 249 | + |
| 250 | +- **Shadow DOM bypass:** Any component using `dangerouslySetInnerHTML` to inject |
| 251 | + styles — flag as Critical. |
| 252 | +- **Hardcoded breakpoints:** `sm:`, `md:` used inconsistently with the project's |
| 253 | + layout strategy — flag as Recommended. |
| 254 | +- **Missing `data-testid`:** UI components without test selectors make visual |
| 255 | + testing brittle — flag as Advisory. |
| 256 | + |
| 257 | +## 🛠 Companion Skills |
| 258 | + |
| 259 | +- Run `style-logic-exporter` BEFORE this skill to extract the current token |
| 260 | + state. Pass the output as context when starting the audit. |
| 261 | +- Run `accessibility-auditor` in parallel on the same component to catch WCAG |
| 262 | + violations that are distinct from design token issues. |
| 263 | + |
| 264 | +## 📋 Outcome Actions |
| 265 | + |
| 266 | +- **`READY_FOR_DESIGNER_GATE`:** Proceed to designer approval handoff. Share |
| 267 | + Chromatic build link and KI slug with the design team. |
| 268 | +- **`ESCALATED`:** Route to `docs/design-debt.md` and add to the Manual Review |
| 269 | + queue. Schedule a sync with a designer. |
| 270 | +- **`IN_PROGRESS`:** Wait for the user to apply Iteration 1 fixes before calling |
| 271 | + `/design-system-review iterate`. |
0 commit comments