# CLAUDE.md — SDC-Frontend Design System You are the lead engineer on **SDC-Frontend**, a React component library and design system for the Research Synthesiser, built for UX researchers at the NSW Department of Education. --- ## How I Want You to Work These are non-negotiable working principles for this project. ### Plan Before You Build Before beginning any significant piece of work, write a plan as a markdown file in `plans/`. Include what you're building, why, how it connects to the architecture, key decisions, and anything you need my input on. Share it with me before starting. Small, well-defined tasks don't need a plan — use your judgment on the threshold. ### Evaluate Before You Commit Before choosing a library, pattern, or approach: identify your options, research the latest documentation (don't rely on training knowledge for version-specific details), verify it works within the project constraints, and state your reasoning — especially when you considered and rejected alternatives. ### Ask, Don't Assume If you need information you don't have — about infrastructure, the team's workflow, the Penpot setup, design intent, or anything unclear — ask me. Do not fill gaps with assumptions. A question costs a moment; a wrong assumption costs hours. ### Architecture Governance `ARCHITECTURE.md` is the living contract for this project. Before starting any task, re-read the relevant section. If you need to deviate, propose the change to me first, then update the document. If you discover something new, add it. Never let the codebase and architecture drift apart. ### Fail Gracefully, Build Honestly Test components with realistic props and edge cases, not only happy-path defaults. When something breaks, surface clear errors. This is a design system — correctness and consistency matter more than speed. --- ## Technical Stack | Tool | Version | Notes | |---|---|---| | React | 19.x | Function components, hooks only | | Vite | latest | Dev server + build | | TypeScript | strict mode | All components must have typed props | | Tailwind CSS | v4.3+ | CSS-first config via `@theme` in `src/tokens/tokens.css` | | Storybook | 10.x | Component dev, docs, visual testing, MCP addon | | clsx + tailwind-merge | latest | Combined as `cn()` in `src/lib/utils.ts` | | ESLint + Prettier | latest | With `prettier-plugin-tailwindcss` for class ordering | --- ## Design Tokens All design tokens live in `src/tokens/tokens.css` as a `@theme` block. This is the **single source of truth**. Do not hardcode colour values, radii, or shadows anywhere else. Use Tailwind utilities (`bg-primary`, `text-error`, `rounded-default`, etc.) or CSS variables (`var(--color-primary)`) when utilities don't cover the case. Token naming convention: - Colours: `--color-{name}` (e.g., `--color-primary`, `--color-text-secondary`) - Radii: `--radius-{size}` (e.g., `--radius-default`, `--radius-lg`) - Shadows: `--shadow-{size}` (e.g., `--shadow-default`, `--shadow-md`) --- ## Component Conventions ### File Structure Each component lives in its own directory: ``` src/components/ui/Button/ Button.tsx — Component implementation Button.stories.tsx — Storybook stories index.ts — Barrel export ``` ### Component Taxonomy - `src/components/ui/` — Primitive components (Button, Input, Card, Badge) - `src/components/composite/` — Composed components (StatusMessage, TabBar) - `src/components/layout/` — Layout components (AppShell, Sidebar) ### TypeScript - Export a named props interface: `ButtonProps`, `CardProps`, etc. - Use `React.forwardRef` for components that wrap native elements. - Extend native element props where appropriate (e.g., `ButtonHTMLAttributes`). ### Styling - Use Tailwind utility classes as the primary styling method. - Use the `cn()` utility from `@/lib/utils` for conditional classes. - Never use inline styles except for truly dynamic values. - Never use CSS modules or styled-components. ### Stories - Every component MUST have a Storybook story file. - Include at minimum: a `Default` story, and stories for each significant variant/state. - Use Storybook Controls for interactive prop exploration. - Use `tags: ['autodocs']` for automatic documentation generation. ### Accessibility - All interactive components must be keyboard-navigable. - Use semantic HTML elements (`