UX Design Expertise
When to Use This Skill
Load this skill when you need to:
- Create or classify components using Atomic Design
- Transform BDD scenarios into Storybook stories
- Create RTL tests or Storybook play functions
- Define selector contracts for testing
- Perform UX review before PR approval
- Create or update the brand system specification
- Check the component catalog before creating new components
Common triggers:
- Refinement phase creates visual sub-tasks
- UI features need Storybook stories
- PR touches
src/components/ or stories/
- Discovery phase needs brand system specification
- New feature may duplicate existing components
Quick Reference
Core principles:
- Design happens in code (Storybook) — Figma is an optional visual layer (see
af-sync-figma-designs)
- Extended Atomic Design hierarchy: Tokens → Primitives → Atoms → Molecules → Organisms → Templates → Pages → Flows
- Component Catalog Check before creating anything new
- Storybook play functions are PRIMARY for UI testing
- RTL tests are for non-visual logic only
- View Components are the single source of truth — shared by Storybook stories AND app pages
- Design Grammar (
.design-grammar/) defines the shared cross-project vocabulary
The 7-Stage Design Flow:
- UX Intent Extraction → Understand requirements
- Visual Language + Base Tokens → Establish tokens from day one
- Component Design in Storybook → Build in atomic folders
- Behavior Locked with Tests → Play functions + RTL
- Design Sign-off → Storybook + tests complete
- Handoff to Engineering → Ownership transfer
- Pattern Tokenisation → Extract emergent patterns
Key deliverables:
- View components (
src/components/views/) — rendering logic shared by stories and pages
- Storybook stories (all states, themes, viewports)
- Selector contract (
/tests/selectors/[capability].ts)
- Components in atomic folders (
src/components/{primitives,atoms,molecules,organisms,templates}/)
Rules
Extended Atomic Design Hierarchy
The full hierarchy extends classic Atomic Design with Primitives below and Pages/Flows above:
Tokens → Primitives → Atoms → Molecules → Organisms → Templates → Pages → Flows
| Level |
Purpose |
Examples |
| Tokens |
Design values (colors, spacing, typography) |
--color-primary, --spacing-md |
| Primitives |
Unstyled behavioural + layout building blocks |
Component: <Pressable>, <Slot>; Layout: <Stack>, <Grid> |
| Atoms |
Styled single-purpose elements |
<Button>, <Badge>, <Input> |
| Molecules |
Small atom combinations |
<FormField>, <NavItem>, <PricingCard> |
| Organisms |
Large UI sections (page sections) |
<Hero>, <FeatureGrid>, <Pricing> |
| Templates |
Page structure without content |
<LandingTemplate>, <DashboardTemplate> |
| Pages |
Templates + real content (data-fetching boundary) |
<LandingPage>, <PricingPage> |
| Flows |
Multi-page user journeys |
Signup flow, Onboarding flow, Checkout flow |
Primitives split into two categories:
- Component primitives — Behavioural wrappers (e.g.,
<Pressable>, <Collapsible>, <Slot>)
- Layout primitives — Spatial containers (e.g.,
<Stack>, <Grid>, <Container>, <Spacer>)
Atomic Design Rules
- MUST classify components using the extended hierarchy above
- MUST check component catalog BEFORE creating — Browse Storybook sidebar, check shadcn/ui, compose before creating
- MUST use atomic folder structure —
src/components/{primitives,atoms,molecules,organisms,templates}/
- MUST mirror atomic levels in Storybook titles —
title: 'Atoms/Button', title: 'Organisms/Auth/SignupForm'
- SHOULD prefer shadcn/ui for atoms — Only create custom atoms when shadcn/ui doesn't cover the need
Component Rules
- MUST read design system FIRST —
/docs/design/design-system.md
- MUST map every BDD scenario to a story — 100% coverage
- MUST create selector contracts — Bridge between stories and tests
- MUST separate components from stories — Stories import from
src/components/, never embed code
- MUST check tsconfig.json paths before imports — Path aliases vary by project
View Components Pattern
View components are the single source of truth for rendering logic. Both Storybook stories and app pages import the same view component — no duplication.
src/components/views/
├── PricingView.tsx ← rendering logic (props in, JSX out)
├── DashboardView.tsx
└── OnboardingView.tsx
src/app/pricing/page.tsx ← data fetching + auth → passes props to PricingView
stories/PricingView.stories.tsx ← mock data → passes props to PricingView
Rules:
11. MUST create view components for any page-level UI — src/components/views/[Name]View.tsx
12. View components accept props, return JSX — No data fetching, no auth, no side effects
13. Pages are thin wrappers — page.tsx handles data/auth, passes props to the view component
14. Stories import views directly — Stories provide mock data to the same view component that pages use
15. MUST NOT duplicate rendering logic — If a story and a page render the same UI, extract to a view component
Design Grammar
The Design Grammar at .design-grammar/ defines the shared cross-project vocabulary. It provides JSON definitions for every level of the atomic hierarchy.
Rules:
16. MUST consult Design Grammar before creating new components — check if a grammar definition exists
17. Components SHOULD conform to grammar JSON — structure, prop names, and variants defined in grammar
18. New patterns MUST be proposed to grammar — if you create a novel organism or molecule, add its JSON definition
19. Token values come from grammar — never invent token names; use what the grammar defines
20. Grammar is platform-agnostic — same JSON drives React, Flutter, and other renderers
Grammar structure:
.design-grammar/
├── primitives/ ← component + layout primitive definitions
│ ├── components.json
│ └── layouts.json
├── atoms.json ← atom definitions
├── molecules.json ← molecule definitions
├── organisms.json ← organism definitions (including marketing sections)
├── templates.json ← template definitions
├── pipeline/ ← token build tooling (Style Dictionary)
└── tokens-studio/ ← Figma ↔ repo token sync
Testing Rules
- Storybook play functions are PRIMARY for UI component testing (real browser)
- RTL tests are for non-visual logic ONLY — Hooks, utils, state machines
- MUST NOT duplicate assertions — If play function tests it, don't repeat in RTL
- MUST include accessibility assertions — Roles, labels, focus management
- Tests MUST pass before handoff — Engineering keeps them passing
Design Token Rules
- MUST establish base tokens in Stage 2 — Brand colors, typography, spacing, radius, shadows
- Stage 7 is for emergent patterns ONLY — Not base tokens
- MUST use design system tokens — Never hard-code values that have tokens
- Token changes require pipeline validation — Run
npm run validate and npm run build in .design-grammar/pipeline/
Accessibility Rules (WCAG 2.1 AA)
- Semantic HTML mandatory — Headings, ARIA roles, landmarks, form labels
- Keyboard navigation complete — Tab order, focus visible, Escape closes modals
- Screen reader support — ARIA labels, live regions, described-by
- Color contrast minimum 4.5:1 — Text on background
- Touch targets minimum 44px — Mobile-friendly
Story Variant Rules
- MUST create responsive variants — Mobile (320-768px), Tablet (768-1024px), Desktop (1024px+)
- MUST create theme variants — Light and Dark mode using decorators
- MUST use
tags: ['autodocs'] — Enable auto-generated component documentation
- SHOULD add JSDoc to props interfaces — Appears in autodocs as prop descriptions
- SHOULD use CSF 3 with
satisfies Meta — Modern Storybook pattern
Workflows
Workflow: Creating Stories from Scenarios
When: Refinement phase, after BDD scenarios.
- Read BDD scenarios from mini-PRD Section 4
- Check Design Grammar — Does
.design-grammar/ define this component type?
- Component Catalog Check — Browse Storybook, check shadcn/ui
- Read design system at
/docs/design/design-system.md
- Create selector contract at
/tests/selectors/[capability].ts
- Classify components using extended hierarchy (Tokens → Primitives → ... → Flows)
- Create view components at
src/components/views/ for page-level UI
- Create atomic components in
src/components/{primitives,atoms,molecules,organisms,templates}/
- Create stories that import view components or atomic components
- Write stories per scenario (happy, error, boundary, validation)
- Add responsive variants (Mobile, Tablet, Desktop)
- Add theme variants (Light, Dark)
- Add play functions for interaction testing
- Add
tags: ['autodocs'] and JSDoc on props
- Test locally:
npm run storybook
See UX Design Guide for detailed steps and examples.
Workflow: UX Review
When: Delivery phase, before PR approval for UI changes.
- Gather inputs: UI under review, brand system specification, design decision log, reference class
- Run 7-point checklist: Structure, Component Discipline, Density, State/Feedback, Accessibility, Brand Alignment, Decision Log Compliance
- Classify findings as: Aligned | Tension | Violation
- Emit outputs: Implementation fixes, token evolution, guideline amendments, design decisions
Hard rule: If a reference class can't be stated, the review is invalid.
See UX Design Guide for full checklist.
Workflow: Component Catalog Check
When: Before creating ANY new component.
- Browse Storybook sidebar — does this component already exist?
- Check shadcn/ui —
mcp__shadcn-ui-server__list_shadcn_components
- Can you compose from existing atoms/molecules?
- Only create new if nothing exists at the right level
- Classify the new component: atom, molecule, organism, or template
Common Pitfalls
| Pitfall |
Solution |
| Creating duplicates |
Check Storybook catalog first |
| Embedding code in stories |
Stories import from src/components/ |
| RTL duplicating play functions |
Play functions are primary for UI |
| No theme variants |
Add Light/Dark mode stories |
| Missing autodocs |
Add JSDoc + tags: ['autodocs'] |
| Wrong import paths |
Read tsconfig.json first |
| Flat component structure |
Use atomic folders with primitives/ level |
| Deferring all tokens |
Base tokens go in Stage 2 |
| Duplicating render logic |
Extract to view components (src/components/views/) |
| Page components doing rendering |
Pages fetch data only — delegate rendering to views |
| Ignoring Design Grammar |
Check .design-grammar/ before creating new component types |
| Inventing token names |
Use grammar-defined tokens only |
Integration with AgentFlow Phases
| Phase |
Activities |
| Discovery |
Brand system specification, reference class, base design tokens, Brand Page in Storybook |
| Refinement |
Catalog Check → Components → Stories → Tests → Sign-off |
| Delivery |
Engineering wires components, UX Review before PR |
| Post-Delivery |
Extract emergent pattern tokens |
Essential Reading
Comprehensive guide (workflows, examples, review checklists):
Design system:
- Project design system:
/docs/design/design-system.md
Variant reference:
- Tailwind Plus catalogue:
.design-grammar/sources/tailwind-plus/catalogue.json — 657 component variants mapped to grammar types. Use as a reference when choosing variants for new components.
Related skills:
af-write-bdd-scenarios — Scenario understanding
af-configure-test-frameworks — Test patterns
af-develop-flutter-apps — Mobile-specific patterns
af-sync-figma-designs — Figma round-trip workflows (optional visual layer)
MCP Tools:
mcp__shadcn-ui-server__list_shadcn_components — List available components
mcp__shadcn-ui-server__get_component_details — Get component specs
mcp__shadcn-ui-server__get_component_examples — Get usage examples
Remember:
- Extended hierarchy: Tokens → Primitives → Atoms → Molecules → Organisms → Templates → Pages → Flows
- View components (
src/components/views/) are the single source of truth for rendering
- Check Design Grammar (
.design-grammar/) AND component catalog BEFORE creating
- Play functions are PRIMARY for UI testing
- Base tokens established in Stage 2, emergent patterns in Stage 7
- Storybook is the source of truth, not Figma
- Pages fetch data only — delegate all rendering to view components
1---2name: af-design-ui-components3description: Design UI components with Storybook stories, RTL tests, and accessibility compliance. Use when creating component specifications, performing UX reviews, aligning BDD scenarios with UI design, or working with shadcn/ui.4---5
6# UX Design Expertise
7
8## When to Use This Skill
9
10Load this skill when you need to:
11- Create or classify components using Atomic Design
12- Transform BDD scenarios into Storybook stories
13- Create RTL tests or Storybook play functions
14- Define selector contracts for testing
15- Perform UX review before PR approval
16- Create or update the brand system specification
17- Check the component catalog before creating new components
18
19**Common triggers:**
20- Refinement phase creates visual sub-tasks
21- UI features need Storybook stories
22- PR touches `src/components/` or `stories/`
23- Discovery phase needs brand system specification
24- New feature may duplicate existing components
25
26## Quick Reference
27
28**Core principles:**
291. Design happens in code (Storybook) — Figma is an optional visual layer (see `af-sync-figma-designs`)
302. Extended Atomic Design hierarchy: Tokens → Primitives → Atoms → Molecules → Organisms → Templates → Pages → Flows
313. Component Catalog Check before creating anything new
324. Storybook play functions are PRIMARY for UI testing
335. RTL tests are for non-visual logic only
346. View Components are the single source of truth — shared by Storybook stories AND app pages
357. Design Grammar (`.design-grammar/`) defines the shared cross-project vocabulary
36
37**The 7-Stage Design Flow:**
381. UX Intent Extraction → Understand requirements
392. Visual Language + Base Tokens → Establish tokens from day one
403. Component Design in Storybook → Build in atomic folders
414. Behavior Locked with Tests → Play functions + RTL
425. Design Sign-off → Storybook + tests complete
436. Handoff to Engineering → Ownership transfer
447. Pattern Tokenisation → Extract emergent patterns
45
46**Key deliverables:**
47- View components (`src/components/views/`) — rendering logic shared by stories and pages
48- Storybook stories (all states, themes, viewports)
49- Selector contract (`/tests/selectors/[capability].ts`)
50- Components in atomic folders (`src/components/{primitives,atoms,molecules,organisms,templates}/`)
51
52## Rules
53
54### Extended Atomic Design Hierarchy
55
56The full hierarchy extends classic Atomic Design with Primitives below and Pages/Flows above:
57
58```
59Tokens → Primitives → Atoms → Molecules → Organisms → Templates → Pages → Flows
60```
61
62| Level | Purpose | Examples |
63|-------|---------|---------|
64| **Tokens** | Design values (colors, spacing, typography) | `--color-primary`, `--spacing-md` |
65| **Primitives** | Unstyled behavioural + layout building blocks | Component: `<Pressable>`, `<Slot>`; Layout: `<Stack>`, `<Grid>` |
66| **Atoms** | Styled single-purpose elements | `<Button>`, `<Badge>`, `<Input>` |
67| **Molecules** | Small atom combinations | `<FormField>`, `<NavItem>`, `<PricingCard>` |
68| **Organisms** | Large UI sections (page sections) | `<Hero>`, `<FeatureGrid>`, `<Pricing>` |
69| **Templates** | Page structure without content | `<LandingTemplate>`, `<DashboardTemplate>` |
70| **Pages** | Templates + real content (data-fetching boundary) | `<LandingPage>`, `<PricingPage>` |
71| **Flows** | Multi-page user journeys | Signup flow, Onboarding flow, Checkout flow |
72
73**Primitives** split into two categories:
74- **Component primitives** — Behavioural wrappers (e.g., `<Pressable>`, `<Collapsible>`, `<Slot>`)
75- **Layout primitives** — Spatial containers (e.g., `<Stack>`, `<Grid>`, `<Container>`, `<Spacer>`)
76
77### Atomic Design Rules
78
791. **MUST classify components** using the extended hierarchy above
802. **MUST check component catalog BEFORE creating** — Browse Storybook sidebar, check shadcn/ui, compose before creating
813. **MUST use atomic folder structure** — `src/components/{primitives,atoms,molecules,organisms,templates}/`
824. **MUST mirror atomic levels in Storybook titles** — `title: 'Atoms/Button'`, `title: 'Organisms/Auth/SignupForm'`
835. **SHOULD prefer shadcn/ui for atoms** — Only create custom atoms when shadcn/ui doesn't cover the need
84
85### Component Rules
86
876. **MUST read design system FIRST** — `/docs/design/design-system.md`
887. **MUST map every BDD scenario to a story** — 100% coverage
898. **MUST create selector contracts** — Bridge between stories and tests
909. **MUST separate components from stories** — Stories import from `src/components/`, never embed code
9110. **MUST check tsconfig.json paths before imports** — Path aliases vary by project
92
93### View Components Pattern
94
95View components are the **single source of truth** for rendering logic. Both Storybook stories and app pages import the same view component — no duplication.
96
97```
98src/components/views/
99 ├── PricingView.tsx ← rendering logic (props in, JSX out)
100 ├── DashboardView.tsx
101 └── OnboardingView.tsx
102
103src/app/pricing/page.tsx ← data fetching + auth → passes props to PricingView
104stories/PricingView.stories.tsx ← mock data → passes props to PricingView
105```
106
107**Rules:**
10811. **MUST create view components** for any page-level UI — `src/components/views/[Name]View.tsx`
10912. **View components accept props, return JSX** — No data fetching, no auth, no side effects
11013. **Pages are thin wrappers** — `page.tsx` handles data/auth, passes props to the view component
11114. **Stories import views directly** — Stories provide mock data to the same view component that pages use
11215. **MUST NOT duplicate rendering logic** — If a story and a page render the same UI, extract to a view component
113
114### Design Grammar
115
116The **Design Grammar** at `.design-grammar/` defines the shared cross-project vocabulary. It provides JSON definitions for every level of the atomic hierarchy.
117
118**Rules:**
11916. **MUST consult Design Grammar** before creating new components — check if a grammar definition exists
12017. **Components SHOULD conform to grammar JSON** — structure, prop names, and variants defined in grammar
12118. **New patterns MUST be proposed to grammar** — if you create a novel organism or molecule, add its JSON definition
12219. **Token values come from grammar** — never invent token names; use what the grammar defines
12320. **Grammar is platform-agnostic** — same JSON drives React, Flutter, and other renderers
124
125**Grammar structure:**
126```
127.design-grammar/
128 ├── primitives/ ← component + layout primitive definitions
129 │ ├── components.json
130 │ └── layouts.json
131 ├── atoms.json ← atom definitions
132 ├── molecules.json ← molecule definitions
133 ├── organisms.json ← organism definitions (including marketing sections)
134 ├── templates.json ← template definitions
135 ├── pipeline/ ← token build tooling (Style Dictionary)
136 └── tokens-studio/ ← Figma ↔ repo token sync
137```
138
139### Testing Rules
140
14121. **Storybook play functions are PRIMARY** for UI component testing (real browser)
14222. **RTL tests are for non-visual logic ONLY** — Hooks, utils, state machines
14323. **MUST NOT duplicate assertions** — If play function tests it, don't repeat in RTL
14424. **MUST include accessibility assertions** — Roles, labels, focus management
14525. **Tests MUST pass before handoff** — Engineering keeps them passing
146
147### Design Token Rules
148
14926. **MUST establish base tokens in Stage 2** — Brand colors, typography, spacing, radius, shadows
15027. **Stage 7 is for emergent patterns ONLY** — Not base tokens
15128. **MUST use design system tokens** — Never hard-code values that have tokens
15229. **Token changes require pipeline validation** — Run `npm run validate` and `npm run build` in `.design-grammar/pipeline/`
153
154### Accessibility Rules (WCAG 2.1 AA)
155
15630. **Semantic HTML mandatory** — Headings, ARIA roles, landmarks, form labels
15731. **Keyboard navigation complete** — Tab order, focus visible, Escape closes modals
15832. **Screen reader support** — ARIA labels, live regions, described-by
15933. **Color contrast minimum 4.5:1** — Text on background
16034. **Touch targets minimum 44px** — Mobile-friendly
161
162### Story Variant Rules
163
16435. **MUST create responsive variants** — Mobile (320-768px), Tablet (768-1024px), Desktop (1024px+)
16536. **MUST create theme variants** — Light and Dark mode using decorators
16637. **MUST use `tags: ['autodocs']`** — Enable auto-generated component documentation
16738. **SHOULD add JSDoc to props interfaces** — Appears in autodocs as prop descriptions
16839. **SHOULD use CSF 3 with `satisfies Meta`** — Modern Storybook pattern
169
170## Workflows
171
172### Workflow: Creating Stories from Scenarios
173
174**When:** Refinement phase, after BDD scenarios.
175
1761. Read BDD scenarios from mini-PRD Section 4
1772. **Check Design Grammar** — Does `.design-grammar/` define this component type?
1783. **Component Catalog Check** — Browse Storybook, check shadcn/ui
1794. Read design system at `/docs/design/design-system.md`
1805. Create selector contract at `/tests/selectors/[capability].ts`
1816. Classify components using extended hierarchy (Tokens → Primitives → ... → Flows)
1827. **Create view components** at `src/components/views/` for page-level UI
1838. Create atomic components in `src/components/{primitives,atoms,molecules,organisms,templates}/`
1849. Create stories that import view components or atomic components
18510. Write stories per scenario (happy, error, boundary, validation)
18611. Add responsive variants (Mobile, Tablet, Desktop)
18712. Add theme variants (Light, Dark)
18813. Add play functions for interaction testing
18914. Add `tags: ['autodocs']` and JSDoc on props
19015. Test locally: `npm run storybook`
191
192See [UX Design Guide](../../docs/guides/ux-design-guide.md) for detailed steps and examples.
193
194### Workflow: UX Review
195
196**When:** Delivery phase, before PR approval for UI changes.
197
1981. Gather inputs: UI under review, brand system specification, design decision log, reference class
1992. Run 7-point checklist: Structure, Component Discipline, Density, State/Feedback, Accessibility, Brand Alignment, Decision Log Compliance
2003. Classify findings as: Aligned | Tension | Violation
2014. Emit outputs: Implementation fixes, token evolution, guideline amendments, design decisions
202
203**Hard rule:** If a reference class can't be stated, the review is invalid.
204
205See [UX Design Guide](../../docs/guides/ux-design-guide.md#ux-review-workflow) for full checklist.
206
207### Workflow: Component Catalog Check
208
209**When:** Before creating ANY new component.
210
2111. Browse Storybook sidebar — does this component already exist?
2122. Check shadcn/ui — `mcp__shadcn-ui-server__list_shadcn_components`
2133. Can you compose from existing atoms/molecules?
2144. Only create new if nothing exists at the right level
2155. Classify the new component: atom, molecule, organism, or template
216
217## Common Pitfalls
218
219| Pitfall | Solution |
220|---------|----------|
221| Creating duplicates | Check Storybook catalog first |
222| Embedding code in stories | Stories import from `src/components/` |
223| RTL duplicating play functions | Play functions are primary for UI |
224| No theme variants | Add Light/Dark mode stories |
225| Missing autodocs | Add JSDoc + `tags: ['autodocs']` |
226| Wrong import paths | Read tsconfig.json first |
227| Flat component structure | Use atomic folders with `primitives/` level |
228| Deferring all tokens | Base tokens go in Stage 2 |
229| Duplicating render logic | Extract to view components (`src/components/views/`) |
230| Page components doing rendering | Pages fetch data only — delegate rendering to views |
231| Ignoring Design Grammar | Check `.design-grammar/` before creating new component types |
232| Inventing token names | Use grammar-defined tokens only |
233
234## Integration with AgentFlow Phases
235
236| Phase | Activities |
237|-------|-----------|
238| **Discovery** | Brand system specification, reference class, base design tokens, Brand Page in Storybook |
239| **Refinement** | Catalog Check → Components → Stories → Tests → Sign-off |
240| **Delivery** | Engineering wires components, UX Review before PR |
241| **Post-Delivery** | Extract emergent pattern tokens |
242
243## Essential Reading
244
245**Comprehensive guide (workflows, examples, review checklists):**
246- [UX Design Guide](../../docs/guides/ux-design-guide.md)
247
248**Design system:**
249- Project design system: `/docs/design/design-system.md`
250
251**Variant reference:**
252- Tailwind Plus catalogue: `.design-grammar/sources/tailwind-plus/catalogue.json` — 657 component variants mapped to grammar types. Use as a reference when choosing variants for new components.
253
254**Related skills:**
255- `af-write-bdd-scenarios` — Scenario understanding
256- `af-configure-test-frameworks` — Test patterns
257- `af-develop-flutter-apps` — Mobile-specific patterns
258- `af-sync-figma-designs` — Figma round-trip workflows (optional visual layer)
259
260**MCP Tools:**
261- `mcp__shadcn-ui-server__list_shadcn_components` — List available components
262- `mcp__shadcn-ui-server__get_component_details` — Get component specs
263- `mcp__shadcn-ui-server__get_component_examples` — Get usage examples
264
265---
266
267**Remember:**
2681. Extended hierarchy: Tokens → Primitives → Atoms → Molecules → Organisms → Templates → Pages → Flows
2692. View components (`src/components/views/`) are the single source of truth for rendering
2703. Check Design Grammar (`.design-grammar/`) AND component catalog BEFORE creating
2714. Play functions are PRIMARY for UI testing
2725. Base tokens established in Stage 2, emergent patterns in Stage 7
2736. Storybook is the source of truth, not Figma
2747. Pages fetch data only — delegate all rendering to view components