design-system-context
Managing design tokens and system context for LLM-driven UI development. Covers loading, persisting, and optimizing design decisions within context windows.
What this skill does
# Design System Context Management
Master the art of managing design system context for LLM-driven UI development. This skill covers strategies for loading design tokens, persisting decisions, and optimizing context window usage.
---
## When to Use This Skill
- Loading design tokens into LLM context efficiently
- Persisting design decisions across sessions
- Optimizing context window for large design systems
- Managing multiple design system variants
- Building context-aware UI generation pipelines
- Maintaining consistency across agent conversations
---
## The Context Challenge
Design systems contain vast amounts of information:
- **Design tokens**: Colors, spacing, typography, shadows, etc.
- **Component specs**: 50-200+ components with variants
- **Usage guidelines**: Do's, don'ts, examples
- **Brand guidelines**: Voice, imagery, personality
**The Problem**: Context windows are finite. Loading everything wastes tokens and degrades performance.
**The Solution**: Strategic context management - load what's needed, when it's needed.
---
## Context Architecture
### Layered Context Model
Organize design system context in layers of specificity:
```
Layer 4: Task-Specific Context (highest priority)
↑
Layer 3: Component Context
↑
Layer 2: Design Token Context
↑
Layer 1: Brand/System Context (foundation)
```
**Implementation**:
```python
class DesignSystemContext:
"""
Layered context management for design systems.
"""
def __init__(self, system_name: str):
self.layers = {
"brand": self.load_brand_context(), # ~500 tokens
"tokens": self.load_design_tokens(), # ~2000 tokens
"components": {}, # On-demand
"task": {}, # Per-request
}
def load_brand_context(self) -> dict:
"""
Layer 1: Foundational brand context.
Always loaded, rarely changes.
"""
return {
"brand_name": "Acme Corp",
"brand_voice": "Professional, approachable, confident",
"core_values": ["Simplicity", "Trust", "Innovation"],
"color_philosophy": "Blue conveys trust, accent sparingly",
"typography_philosophy": "Clean sans-serif, generous line-height",
}
def load_design_tokens(self) -> dict:
"""
Layer 2: Design tokens.
Loaded per session, reference frequently.
"""
return {
"colors": {
"primary": {"50": "#EEF2FF", "500": "#6366F1", "900": "#312E81"},
"gray": {"50": "#F9FAFB", "500": "#6B7280", "900": "#111827"},
"success": "#10B981",
"warning": "#F59E0B",
"error": "#EF4444",
},
"spacing": {
"0": "0", "1": "0.25rem", "2": "0.5rem",
"4": "1rem", "6": "1.5rem", "8": "2rem",
},
"typography": {
"font_family": "Inter, system-ui, sans-serif",
"sizes": {"xs": "0.75rem", "sm": "0.875rem", "base": "1rem"},
"weights": {"normal": 400, "medium": 500, "bold": 700},
},
"radius": {"sm": "0.25rem", "md": "0.375rem", "lg": "0.5rem"},
"shadows": {
"sm": "0 1px 2px rgba(0,0,0,0.05)",
"md": "0 4px 6px rgba(0,0,0,0.1)",
},
}
def load_component_context(self, component_name: str) -> dict:
"""
Layer 3: Component-specific context.
Loaded on-demand when working on specific components.
"""
component_docs = self.fetch_component_docs(component_name)
return {
"specification": component_docs.spec,
"variants": component_docs.variants,
"props": component_docs.props,
"examples": component_docs.examples[:3], # Limit examples
"related_components": component_docs.related[:5],
}
def set_task_context(self, task: dict) -> None:
"""
Layer 4: Task-specific context.
Fresh per request, highest priority.
"""
self.layers["task"] = {
"objective": task.get("objective"),
"constraints": task.get("constraints", []),
"preferences": task.get("preferences", {}),
"previous_decisions": task.get("decisions", []),
}
```
---
## Token-Efficient Context Strategies
### Strategy 1: Compressed Token Format
Reduce verbosity while maintaining meaning:
```python
# Verbose format (~200 tokens)
verbose_tokens = """
The primary color palette consists of:
- Primary 50 (lightest): #EEF2FF, used for backgrounds
- Primary 100: #E0E7FF
- Primary 200: #C7D2FE
- Primary 500 (base): #6366F1, used for primary actions
- Primary 600: #4F46E5
- Primary 900 (darkest): #312E81, used for text on light
"""
# Compressed format (~50 tokens)
compressed_tokens = """
colors.primary: {50:#EEF2FF(bg), 500:#6366F1(action), 900:#312E81(text)}
"""
# Ultra-compressed format (~20 tokens)
ultra_compressed = "pri:#6366F1 bg:#EEF2FF txt:#312E81"
```
**Compression Techniques**:
```python
class TokenCompressor:
"""
Compress design tokens for efficient context usage.
"""
def compress_colors(self, colors: dict) -> str:
"""
Compress color palette to essential values.
Only include: 50 (light), 500 (base), 900 (dark)
"""
essential = {}
for name, shades in colors.items():
essential[name] = {
k: v for k, v in shades.items()
if k in ["50", "500", "900"]
}
return json.dumps(essential, separators=(",", ":"))
def compress_spacing(self, spacing: dict) -> str:
"""
Compress spacing to pattern description.
"""
# Instead of listing all values
return "spacing: 4px base unit, scale: 1,2,4,6,8,12,16,24,32"
def compress_typography(self, typography: dict) -> str:
"""
Compress typography to essentials.
"""
return f"font:{typography['font_family'].split(',')[0]} sizes:xs/sm/base/lg/xl"
```
---
### Strategy 2: Semantic Chunking
Split context into semantic chunks for retrieval:
```python
class SemanticContextChunks:
"""
Organize design system into retrievable semantic chunks.
"""
def __init__(self, design_system: dict):
self.chunks = self.create_chunks(design_system)
self.embeddings = self.embed_chunks()
def create_chunks(self, system: dict) -> list[dict]:
"""
Create semantic chunks from design system.
"""
chunks = []
# Color chunks
chunks.append({
"type": "colors",
"category": "primary",
"description": "Primary brand colors for actions and emphasis",
"content": system["tokens"]["colors"]["primary"],
})
chunks.append({
"type": "colors",
"category": "semantic",
"description": "Semantic colors for feedback states",
"content": {
"success": system["tokens"]["colors"]["success"],
"warning": system["tokens"]["colors"]["warning"],
"error": system["tokens"]["colors"]["error"],
},
})
# Component chunks
for component in system["components"]:
chunks.append({
"type": "component",
"category": component["category"],
"description": component["description"],
"content": component["spec"],
})
return chunks
def retrieve_relevant(self, query: str, top_k: int = 5) -> list[dict]:
"""
Retrieve chunks relevant to the current task.
"""
query_embedding = self.embed(query)
scores = [
(chunk, cosine_similarity(query_embedding, emb))
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.