- Applies to React applications and component libraries using TypeScript.
- Optimize for composability, testability, and clear component boundaries.
- React with TypeScript is required.
- Tailwind CSS is the default styling system.
- Routing must use either:
- React Router v7, or
- TanStack Router
- Storybook is required for component documentation.
- Each component file should follow this order:
- imports
Propsinterface/type- component implementation
- named export
- Prefer one component per file unless tightly coupled primitives are trivial.
- Use named exports; avoid default exports.
- Every component must have explicit prop typing.
- Use
interfacefor public props by default. - Keep props minimal and explicit; avoid
any. - Use discriminated unions for variant-heavy components.
- Local UI state:
useState(oruseReducerwhen transitions are complex). - Global/shared client state: Zustand.
- Do not use global state for ephemeral local concerns.
- Keep async data fetching concerns separate from UI-only state.
- Tailwind utility classes are preferred for styling.
- Inline styles are not allowed except dynamic CSS variables when unavoidable.
- CSS Modules are not allowed.
- Shared visual primitives should be wrapped in reusable components.
- Route definitions should be centralized and strongly typed.
- Use route-level data loading patterns provided by the selected router.
- Keep route components thin; delegate business logic to hooks/services.
- Every component must have tests using React Testing Library.
- Test files use
*.test.tsx. - Cover at least:
- render baseline
- critical interactions
- accessibility-relevant behavior (labels, roles, keyboard where applicable)
- Assert user-visible outcomes, not implementation details.
- Every shared/reusable component must include stories.
- Provide at least:
- default state
- key variants
- edge/empty/loading/error states when relevant
- Keep stories aligned with production props and realistic data.
- Example feature structure:
components/for reusable UIfeatures/<name>/for domain-specific UI + hooks + testsroutes/for route entry componentsstate/for Zustand stores
- Typecheck and lint pass.
- Component tests exist and pass for new/changed UI.
- Storybook stories are added/updated for reusable components.
- Styling follows Tailwind-first, no inline styles, no CSS modules.