Purpose
Extract helps you:- Identify repeated UI patterns worth systematizing
- Find hard-coded values that should become design tokens
- Consolidate inconsistent variations
- Create reusable components from scattered implementations
- Build and maintain a healthy design system
Parameters
string
The feature, component, or area to extract from. When omitted, analyzes the entire codebase for extraction opportunities.
When to Use
Use the extract skill when:- You notice repeated UI patterns across the codebase
- Hard-coded colors, spacing, or typography appear multiple times
- Similar components have inconsistent implementations
- You’re establishing or enriching a design system
- Code duplication is creating maintenance burden
- Inconsistency is affecting user experience
Workflow
1. Discover
Find the Design System
Locates your design system, component library, or shared UI directory. Understands:- Component organization and naming conventions
- Design token structure (if any)
- Documentation patterns
- Import/export conventions
Identify Patterns
Searches for:- Repeated components: Similar UI patterns used multiple times (buttons, cards, inputs)
- Hard-coded values: Colors, spacing, typography, shadows that should be tokens
- Inconsistent variations: Multiple implementations of the same concept
- Reusable patterns: Layout, composition, or interaction patterns worth systematizing
Assess Value
Not everything should be extracted. Considers:- Is this used 3+ times, or likely to be reused?
- Would systematizing this improve consistency?
- Is this a general pattern or context-specific?
- What’s the maintenance cost vs benefit?
2. Plan Extraction
Creates a systematic extraction plan:- Components to extract: Which UI elements become reusable?
- Tokens to create: Which hard-coded values become design tokens?
- Variants to support: What variations does each component need?
- Naming conventions: Names that match existing patterns
- Migration path: How to refactor existing uses
Design systems grow incrementally. Extract what’s clearly reusable now, not everything that might someday be reusable.
3. Extract & Enrich
Builds improved, reusable versions:Components
Creates components with:- Clear props API with sensible defaults
- Proper variants for different use cases
- Built-in accessibility (ARIA, keyboard navigation, focus management)
- Documentation and usage examples
Design Tokens
Creates tokens with:- Clear naming (primitive vs semantic)
- Proper hierarchy and organization
- Documentation of when to use each token
Patterns
Documents patterns with:- When to use this pattern
- Code examples
- Variations and combinations
4. Migrate
Replaces existing uses with shared versions:- Find all instances: Search for the patterns you’ve extracted
- Replace systematically: Update each use to consume the shared version
- Test thoroughly: Ensure visual and functional parity
- Delete dead code: Remove old implementations
5. Document
Updates design system documentation:- Add new components to the component library
- Document token usage and values
- Add examples and guidelines
- Update Storybook or component catalog
Key Principles
Never:- Extract one-off, context-specific implementations without generalization
- Create components so generic they’re useless
- Extract without considering existing conventions
- Skip proper TypeScript types or prop documentation
- Create tokens for every single value (tokens should have semantic meaning)
Usage Examples
Example 1: Extract Button Variants
- Find all button implementations across the codebase
- Identify common patterns and variants
- Create a unified Button component with proper variants
- Replace all existing buttons with the new component
- Document usage in the design system
Example 2: Extract Color Tokens
- Find all hard-coded color values
- Group similar colors and identify semantic usage
- Create color token system (primitive + semantic)
- Replace hard-coded values with tokens
- Document color usage guidelines
Example 3: General Extraction
- Analyzes entire codebase for duplication and patterns
- Identifies highest-value extraction opportunities
- Prioritizes by impact (frequency × inconsistency)
- Systematically extracts and consolidates
Design System Growth
The extract skill supports healthy design system evolution:Extraction Criteria
- Extract
- Don't Extract
- Used 3+ times
- Clear reuse potential
- Improves consistency
- Reduces maintenance
Philosophy
A good design system is a living system. The extract skill helps you:- Identify patterns as they emerge
- Enrich them thoughtfully
- Maintain them consistently
