prompt-engineering-ui
Prompt patterns for consistent UI generation. Covers precise design intent communication, component specification formats, and iterative refinement patterns for LLM-driven UI development.
What this skill does
# Prompt Engineering for UI Generation
Master the art of communicating design intent to LLMs. This skill covers prompt patterns specifically optimized for generating consistent, high-quality user interfaces.
---
## When to Use This Skill
- Writing prompts that generate consistent UI components
- Describing design intent precisely to AI systems
- Building reusable prompt templates for design systems
- Iterating on UI generation with structured feedback
- Creating few-shot examples for UI patterns
- Debugging inconsistent UI generation outputs
---
## The UI Prompting Challenge
UI generation is uniquely challenging because it requires:
1. **Visual precision** - Exact spacing, colors, typography
2. **Behavioral specification** - Interactions, states, animations
3. **Contextual coherence** - Fitting within a design system
4. **Accessibility compliance** - WCAG, ARIA, keyboard navigation
5. **Responsive adaptation** - Multiple breakpoints, devices
6. **Code quality** - Clean, maintainable output
Standard prompting techniques often fail because UI is simultaneously visual, behavioral, and technical.
---
## Core Prompt Patterns
### Pattern 1: The Component Contract
Define components as contracts with explicit input/output specifications.
```markdown
## Component Contract: DataTable
### Purpose
Display tabular data with sorting, filtering, and pagination.
### Props (Inputs)
| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| data | T[] | Yes | - | Array of data objects |
| columns | ColumnDef[] | Yes | - | Column configuration |
| pageSize | number | No | 10 | Rows per page |
| sortable | boolean | No | true | Enable column sorting |
| filterable | boolean | No | false | Show filter inputs |
### Visual Specification
- **Container**: bg-white rounded-lg shadow-sm border border-gray-200
- **Header row**: bg-gray-50 text-gray-600 text-sm font-medium
- **Data rows**: hover:bg-gray-50 border-b border-gray-100
- **Typography**: Font-sans, body text 14px, headers 12px uppercase
- **Spacing**: Cell padding 12px horizontal, 8px vertical
### States
1. **Loading**: Skeleton rows with pulse animation
2. **Empty**: Centered message with icon
3. **Error**: Red border, error message below
4. **Selected**: bg-blue-50, left border accent
### Accessibility Requirements
- role="table" on container
- Sortable columns announce sort direction
- Focus visible on all interactive elements
- Keyboard navigation: Tab through headers, Enter to sort
### Output Format
React TypeScript component using Tailwind CSS.
Include JSDoc comments and prop types.
```
**Why This Works**:
- Explicit contract eliminates ambiguity
- Visual specs use actual CSS values
- States prevent incomplete implementations
- Accessibility is non-negotiable requirement
---
### Pattern 2: Design Token Injection
Embed design tokens directly in prompts for consistency.
```markdown
Generate a Card component following these design tokens:
## Tokens
```json
{
"spacing": {
"xs": "4px",
"sm": "8px",
"md": "16px",
"lg": "24px",
"xl": "32px"
},
"colors": {
"surface": {
"primary": "#FFFFFF",
"secondary": "#F9FAFB",
"elevated": "#FFFFFF"
},
"border": {
"subtle": "#E5E7EB",
"default": "#D1D5DB"
},
"shadow": {
"sm": "0 1px 2px rgba(0,0,0,0.05)",
"md": "0 4px 6px rgba(0,0,0,0.1)"
}
},
"radius": {
"sm": "4px",
"md": "8px",
"lg": "12px"
}
}
```
## Requirements
- Card uses `surface.elevated` background
- Border uses `border.subtle`
- Padding uses `spacing.lg`
- Border radius uses `radius.lg`
- Shadow uses `shadow.md`
Map these tokens to Tailwind classes where possible.
```
**Token Mapping Strategy**:
```typescript
// Prompt can include this mapping guide
const tokenToTailwind = {
"spacing.xs": "p-1",
"spacing.sm": "p-2",
"spacing.md": "p-4",
"spacing.lg": "p-6",
"spacing.xl": "p-8",
"colors.surface.primary": "bg-white",
"colors.surface.secondary": "bg-gray-50",
"colors.border.subtle": "border-gray-200",
"radius.lg": "rounded-xl",
"shadow.md": "shadow-md",
};
```
---
### Pattern 3: Visual Reference Chain
Chain visual descriptions from abstract to concrete.
```markdown
## Component: Hero Section
### Mood (Abstract)
Confident, minimal, focused. The user should feel capable and unintimidated.
### Aesthetic (Semi-Abstract)
- Clean sans-serif typography
- Generous whitespace (40% of viewport)
- Single accent color for CTAs
- Photography: abstract, not literal
### Visual Details (Concrete)
- **Layout**: Centered, max-width 1200px, py-24
- **Headline**: text-5xl font-bold tracking-tight text-gray-900
- **Subheadline**: text-xl text-gray-600 max-w-2xl mx-auto mt-6
- **CTA Group**: mt-10 flex gap-4 justify-center
- **Primary CTA**: bg-indigo-600 hover:bg-indigo-700 text-white px-8 py-4 rounded-lg
- **Secondary CTA**: border border-gray-300 text-gray-700 px-8 py-4 rounded-lg
### Content
- Headline: "Build interfaces that inspire"
- Subheadline: "The design system that empowers creators to ship beautiful products faster."
- Primary CTA: "Get Started"
- Secondary CTA: "Learn More"
```
**The Chain**:
```
Mood → Aesthetic → Visual Details → Content
↓ ↓ ↓ ↓
Emotion Style CSS Values Text
```
This pattern works because it builds from intention to implementation.
---
### Pattern 4: State Machine Specification
Define component states as a state machine.
```markdown
## Button Component States
### State Machine
```
idle → hover → pressed → idle
↓ ↓ ↓
focus focus focus
↓ ↓ ↓
disabled (terminal)
loading (blocks all transitions)
```
### State Definitions
| State | Visual Treatment | Tailwind Classes |
|-------|------------------|------------------|
| idle | Default appearance | bg-blue-600 text-white |
| hover | Slightly darker | hover:bg-blue-700 |
| focus | Ring indicator | focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 |
| pressed | Darker, slight scale | active:bg-blue-800 active:scale-[0.98] |
| disabled | Muted, no pointer | disabled:bg-gray-300 disabled:cursor-not-allowed |
| loading | Spinner, no text | Spinner SVG, opacity-50, pointer-events-none |
### Transitions
- All transitions: `transition-all duration-150 ease-in-out`
- Scale transitions: spring-like (use framer-motion if available)
### Implementation Notes
- Use `<button>` element, never `<div>`
- disabled state must be set via HTML attribute
- loading should set aria-busy="true"
```
---
### Pattern 5: Constraint-First Prompting
Lead with constraints to narrow the solution space.
```markdown
## Constraints (Non-Negotiable)
### Technical Constraints
- React 18+ with TypeScript strict mode
- Tailwind CSS only (no CSS-in-JS)
- No external component libraries
- Bundle size: component must be < 5KB gzipped
### Design Constraints
- Must pass WCAG 2.1 AA
- Must work without JavaScript (progressive enhancement)
- Must support RTL layouts
- Color contrast ratio >= 4.5:1
### Browser Support
- Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
- No IE11 support required
### Performance Constraints
- First paint < 100ms
- No layout shift on load
- Images must be lazy-loaded
---
## Now, generate a Modal component that satisfies all constraints above.
```
**Why Constraints First**:
- Eliminates invalid solutions immediately
- Focuses generation on viable approaches
- Makes review easier (checklist validation)
- Prevents "creative" solutions that break requirements
---
## Iterative Refinement Patterns
### The Feedback Loop Protocol
Structure feedback for effective iteration:
```markdown
## Iteration 1 Feedback
### What Works
- Component structure is correct
- Props interface is well-typed
- Basic styling matches tokens
### What Needs Fixing
#### Critical (Must Fix)
1. **Missing keyboard navigation**
- Current: Only mouse interaction works
- Required: Arrow keys to navigate, Enter toRelated 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.