A documentation structure that helps AI tools understand your design system — not just the components, but when, why, and how to use them.
AI coding tools (Cursor, Claude, Copilot) are powerful for prototyping, but they consistently make poor component choices without proper context. They don't understand:
- When to use a Modal vs a Sheet vs a Toast
- Why your design system has specific patterns
- What edge cases and gotchas to watch for
- How components should be composed together
- Which animation presets to apply
They know what components exist, but not how to think about using them.
The result: Technically valid code that's contextually wrong. You end up fixing AI's component choices instead of building.
A tiered documentation system that gives AI the context it needs:
- Decision trees for component selection
- Component registry with one-liner descriptions
- Pattern references for common scenarios
- Explicit instructions telling AI to read docs first
- Mental model — how to think about the component
- When to use / When NOT to use — decision criteria
- Anatomy — visual breakdown of parts
- Props, usage, composition patterns
- Animation specs and behavior
- Edge cases and gotchas
- Instructions that tell AI tools to check docs before coding
- Checklists for component selection
- File reference guides
AI reads the index first → navigates to specific docs → follows documented patterns.
| Without This System | With This System |
|---|---|
| AI loads 50KB+ of docs upfront | AI loads ~5KB index + ~3KB per component needed |
| AI guesses component choices | AI follows decision trees |
| No guidance on alternatives | "When NOT to use" prevents wrong choices |
| Generic implementations | Documented composition patterns |
| Missing animations | Animation specs included |
The "When NOT to use" section is surprisingly the most valuable. It prevents AI from reaching for the wrong tool.
# Clone the template
git clone https://github.com/yourname/design-system-ai-template.git
# Copy into your project
cp design-system-ai-template/DESIGN_SYSTEM.md ./your-project/
cp design-system-ai-template/.cursorrules ./your-project/
cp -r design-system-ai-template/.claude ./your-project/
cp -r design-system-ai-template/components ./your-project/design-system-ai-template/
├── README.md ← You're reading this
├── DESIGN_SYSTEM.md ← Main index (AI reads first)
├── .cursorrules ← Cursor AI instructions
├── .claude/
│ └── rules.md ← Claude AI instructions
├── foundations/
│ └── motion.md ← Animation guidelines (optional)
├── patterns/
│ └── forms.md ← Pattern example (optional)
└── components/
└── ui/
└── _component.template.md ← Template for new components
- Copy
components/ui/_component.template.md - Rename to
components/ui/[component-name]/[component-name].md - Fill in every section — especially "When NOT to use"
- Add to the Component Registry in
DESIGN_SYSTEM.md - Add to relevant Decision Trees if needed
-
Update
DESIGN_SYSTEM.md- Modify decision trees for your component set
- Update the component registry
- Add your common patterns
-
Adjust AI rules
- Customize
.cursorrulesand.claude/rules.md - Add project-specific instructions
- Customize
-
Add foundations (optional)
foundations/colors.mdfoundations/typography.mdfoundations/spacing.mdfoundations/motion.md
AI won't check documentation automatically. You need explicit instructions:
> ⚠️ **AI Instructions:** Before implementing any UI, consult this index first.
> Do NOT guess component usage. Navigate to the relevant `.md` file and read it fully before writing code.AI parses structured flowcharts better than paragraphs:
Feedback type?
├── Success/error message (temporary) → Toast
├── Inline validation → FormField error state
├── System status → Banner
└── Loading state → Skeleton / Spinner
This section prevents the most common AI mistakes:
## When NOT to Use
❌ **Don't use Modal when:**
- Content is informational only → use `Toast` or `Banner`
- User might need to reference page content → use `Sheet`
- It's a success message → use `Toast`For prototyping, motion matters. Include specs:
## Behavior & Animation
| State | Change | Duration |
|-------|--------|----------|
| Hover | Lift + shadow | 150ms ease-out |
| Active | Scale down | 100ms ease-out |Don't just document props — show how components work together:
// Deletion confirmation pattern
<Modal open={showConfirm} onClose={handleClose}>
<Modal.Header>
<Modal.Title>Delete project?</Modal.Title>
</Modal.Header>
<Modal.Footer>
<Button variant="ghost" onClick={handleClose}>Cancel</Button>
<Button variant="destructive" onClick={handleDelete}>Delete</Button>
</Modal.Footer>
</Modal>| Layer | Size | When AI Reads |
|---|---|---|
DESIGN_SYSTEM.md |
~3-4KB | Always (entry point) |
Component .md |
~2-3KB each | Only when needed |
patterns/*.md |
~1-2KB each | Only for specific patterns |
foundations/*.md |
~1-2KB each | Only when relevant |
Total for typical task: ~8-10KB vs 50KB+ without this system
Build a delete confirmation using @patterns/deletion.md
and @components/ui/modal/modal.md
When you add components, immediately add them to:
- The Component Registry table
- Relevant Decision Trees
Document these first — they're used most:
- Button
- Input
- Card
- Modal
- Toast
When AI makes wrong choices, check if the docs are clear enough. Improve them.
Found ways to improve AI comprehension? PRs welcome:
- Better decision tree formats
- Additional component templates
- Pattern documentation examples
- Improvements to AI rules
MIT — Use freely, attribution appreciated.
Inspired by countless hours of AI-assisted prototyping and asking "why did it pick that component?"