Why Figma Generates Explicit Rules Instead of Relying on Examples
TRIGGER
Developers using AI code generation tools had to repeatedly prompt with spacing, tokens, and naming conventions because the AI had no knowledge of the team's existing standards—leading to inconsistent output that required manual correction.
APPROACH
Figma's MCP server includes automated design system rule generation that scans the existing codebase and outputs a structured rules file. Input: existing codebase with design system implementation (mature systems with 50+ components work best). Output: structured rules file containing token definitions, component patterns, style hierarchies, and naming conventions that AI agents reference during code generation. The tool extracts token definitions, component libraries, style hierarchies, and naming conventions into a machine-readable format that acts as system-level context for AI agents. This eliminates the need for developers to repeatedly prompt with spacing, tokens, and naming conventions in every code generation request. The rules file serves as persistent context that reduces ambiguity and ensures generated code adheres to team standards.
PATTERN
“AI won't learn your patterns from examples—it needs declarative rules. Extract implicit standards into machine-readable constraints; AI agents can follow structured rules but can't infer conventions from code examples alone.”
✓ WORKS WHEN
- Codebase already has consistent patterns worth preserving (mature design system with 50+ components)
- Team has established naming conventions and token hierarchies that can be formalized
- Multiple developers or AI agents need to generate code that matches existing standards
- Design system spans multiple frameworks or platforms requiring consistent translation
✗ FAILS WHEN
- Codebase has inconsistent patterns—extracting rules will codify the inconsistency
- Standards are still evolving rapidly and rules file would be immediately outdated
- Team is small enough (1-2 developers) that tribal knowledge suffices
- Project is greenfield with no existing patterns to extract