name: dt-design-system description: >- Creates and modifies Digitaltableteur UI components, layout patterns, Storybook stories, contracts, and design tokens under nextjs-app/shared/. Use when the user says "new component", "scaffold component", "Storybook story", "design system", "CSS Modules", "component contract", "validate:components", or edits files in shared/components or shared/patterns. Do NOT use for Next.js page routes (use dt-nextjs-app) or API endpoints (use dt-api-routes). metadata: version: 1.1.0 category: design-system
Design system workflow
Instructions
Step 1: Load context
- Read
references/area-guide.md - Before creating UI, run
dt-use-existing-componentornpm run find-component -- "your intent". - Search for existing components before creating new ones:
rg -n "<SimilarName" nextjs-app/shared/components/
- For new components, open
docs/LLM_COMPONENT_GENERATION_RULES.mdby relevant section only — do not paste the full 12k-word doc into context.
Step 2: Scaffold (new component)
npm run new-component ComponentName
Expected output: folder under nextjs-app/shared/components/ComponentName/ with .tsx, .module.css, .stories.tsx, .test.tsx, .contract.json, .spec.md, .mdx, index.ts.
CRITICAL before finishing:
- WIP badge on Storybook story until promoted
- axe-core assertion in
.test.tsx - EN / FI / SV keys if user-facing strings
- Design tokens from
variables.css— no hardcoded colors
Step 3: Validate
npm run validate:components
npm test -- ComponentName
If validation fails, halt and fix reported contract/spec/MDX issues before proceeding.
Step 4: Promote (remove WIP badge)
Only when ALL pass:
- Unit + axe tests green
npm run test:stories:smokefor the story- Full i18n coverage
- Visual check in Storybook or via
npx agent-browser
Ask the user before promoting contract status to stable.
Token changes
npm run build:tokens
Regenerates nextjs-app/shared/foundations/dist/agent-manifest.json.
@dt usage gate
Do not replace pattern-level <h*> / header chrome <button> with @dt/Title / @dt/Button unless explicitly requested — that changes typography and breaks section CSS. Fix heading levels only (h3 → h2) while keeping existing classes. npm run lint:dt-usage flags @/components/ui/* in app/, patterns, pages, and shared components (known shadcn debt allowlisted).
Agent / MCP discovery
- CLI:
npm run find-component -- "your intent" - Local MCP:
npm run ds:mcp(stdio — seedocs/DESIGN_SYSTEM_MCP.md) - HTTP:
/mcpon production (design-system tools + consulting)
Examples
Example 1: New Button variant
User says: "Add a ghost variant to Button"
Actions:
- Load existing
nextjs-app/shared/components/Button/ - Update
Button.tsx,Button.module.css,Button.contract.json,Button.spec.md - Add story variant + test coverage
- Run
npm run validate:components && npm test -- Button
Example 2: New layout pattern
User says: "Create a pricing table pattern"
Actions:
- Check
nextjs-app/shared/patterns/for similar patterns - Compose from
@dtprimitives (Title,Text,Card,Grid) — no raw<h2>or<p> - Follow same contract/story/test structure as components
- Run validation gates
Troubleshooting
validate:components fails on contract
Cause: props in .tsx drifted from .contract.json or spec has open TODOs at beta+.
Solution: align contract schema with exported props; rewrite stub MDX/spec prose flagged in agent-manifest.json.
Storybook story missing WIP badge
Cause: scaffolder default removed manually.
Solution: restore WIP badge until a11y + visual + i18n gates pass.
Tests fail on axe violations
Cause: missing labels, contrast, or keyboard support.
Solution: fix a11y in component first; do not suppress axe rules without documented justification in spec.
Boundaries
- MUST NOT use inline styles (except dynamic
backgroundImage) - MUST NOT create single-file components outside folder structure
- MUST NOT remove WIP badge without full verification gate