Design lab

From MaggieAppleton/maggieappleton.com-V3 · View interactive version

Design lab is an AI agent skill from the GitHub repository MaggieAppleton/maggieappleton.com-V3. Conduct design interviews, generate five distinct UI variations in a temporary design lab, collect feedback, and produce implementation plans. Use when the user wants to explore UI design options, redesign existing components, or create new UI with multiple approaches to compare.

How to use this skill

Skill file

Design Lab Skill

This skill implements a complete design exploration workflow: interview, generate variations, collect feedback, refine, preview, and finalize.

CRITICAL: Cleanup Behavior

All temporary files MUST be deleted when the process ends, whether by:

Never leave .claude-design/ or __design_lab routes behind. If the user says "cancel", "abort", "stop", or "nevermind" at any point, confirm and then delete all temporary artifacts.


Phase 0: Preflight Detection

Before starting the interview, automatically detect:

Package Manager

Check for lock files in the project root:

Framework Detection

Check for config files:

Styling System Detection

Check package.json dependencies and config files:

Design Memory Check

Look for existing Design Memory file:

If found, read it and use to prefill defaults and skip redundant questions.

Visual Style Inference (CRITICAL)

DO NOT use generic/predefined styles. Extract visual language from the project:

If Tailwind detected, read tailwind.config.js or tailwind.config.ts:

// Extract and use:
theme.colors      // Color palette
theme.spacing     // Spacing scale
theme.borderRadius // Radius values
theme.fontFamily  // Typography
theme.boxShadow   // Elevation system

If CSS Variables exist, read globals.css, variables.css, or :root definitions:

:root {
  --color-*     /* Color tokens */
  --spacing-*   /* Spacing tokens */
  --font-*      /* Typography tokens */
  --radius-*    /* Border radius tokens */
}

If UI library detected (MUI, Chakra, Ant), read the theme configuration:

Always scan existing components to understand patterns:

Store inferred styles in the Design Brief for consistent use across all variants.


Phase 1: Interview

Use the AskUserQuestion tool for all interview steps. Adapt questions based on Design Memory if it exists.

Step 1.1: Scope & Target

Ask these questions (can combine into single AskUserQuestion with multiple questions):

Question 1: Scope

Question 2: New or Redesign

If "Redesign" selected, ask:

Question 3: Existing Path

If target is unclear, propose a name based on repo patterns and confirm.

Step 1.2: Pain Points & Inspiration

Question 1: Pain Points

Question 2: Visual Inspiration

Question 3: Functional Inspiration

Step 1.3: Brand & Style Direction

Question 1: Brand Adjectives

Question 2: Density

Question 3: Dark Mode

Step 1.4: Persona & Jobs-to-be-Done

Question 1: Primary User

Question 2: Context

Question 3: Key Tasks

Step 1.5: Constraints

Question 1: Must-Keep Elements

Question 2: Technical Constraints


Phase 2: Generate Design Brief

After the interview, create a structured Design Brief as JSON and save to .claude-design/design-brief.json:

{
  "scope": "component|page",
  "isRedesign": true|false,
  "targetPath": "src/components/Example.tsx",
  "targetName": "Example",
  "painPoints": ["Too dense", "Primary action unclear"],
  "inspiration": {
    "visual": ["Stripe", "Linear"],
    "functional": ["Inline validation"]
  },
  "brand": {
    "adjectives": ["minimal", "trustworthy"],
    "density": "comfortable",
    "darkMode": true
  },
  "persona": {
    "primary": "Developer",
    "context": "desktop-first",
    "keyTasks": ["Complete checkout", "Review order", "Apply discount"]
  },
  "constraints": {
    "mustKeep": ["existing fields"],
    "technical": ["no new dependencies", "WCAG accessible"]
  },
  "framework": "nextjs-app",
  "packageManager": "pnpm",
  "stylingSystem": "tailwind"
}

Display a summary to the user before proceeding.


Phase 3: Generate Design Lab

Directory Structure

Create all files under .claude-design/:

.claude-design/
├── lab/
│   ├── page.tsx                 # Main lab page (framework-specific)
│   ├── variants/
│   │   ├── VariantA.tsx
│   │   ├── VariantB.tsx
│   │   ├── VariantC.tsx
│   │   ├── VariantD.tsx
│   │   └── VariantE.tsx
│   ├── components/
│   │   └── LabShell.tsx         # Lab layout wrapper
│   ├── feedback/                # Interactive feedback system
│   │   ├── types.ts             # TypeScript interfaces
│   │   ├── selector-utils.ts    # Element identification
│   │   ├── format-utils.ts      # Feedback formatting
│   │   ├── FeedbackOverlay.tsx  # Main overlay component
│   │   └── index.ts             # Module exports
│   └── data/
│       └── fixtures.ts          # Shared mock data
├── design-brief.json
└── run-log.md

Feedback System Setup (CRITICAL - NEVER SKIP)

The FeedbackOverlay is the PRIMARY feature of the Design Lab. Without it, users cannot provide interactive feedback. NEVER generate a Design Lab without the FeedbackOverlay.

Reliability Strategy: To avoid import path issues across different project configurations, create the FeedbackOverlay directly in the route directory (e.g., app/design-lab/FeedbackOverlay.tsx), NOT in .claude-design/. This ensures a simple relative import (./FeedbackOverlay) always works.

Required Files in Route Directory:

app/design-lab/           # or app/__design_lab/ if underscores work
├── page.tsx              # Main lab page with variants
└── FeedbackOverlay.tsx   # Self-contained overlay component (copy from templates)

Template Source: design-and-refine/templates/feedback/FeedbackOverlay.tsx

Why this approach:

Route Integration

Next.js App Router:

Create app/__design_lab/page.tsx that imports from .claude-design/lab/

Next.js Pages Router:

Create pages/__design_lab.tsx that imports from .claude-design/lab/

Vite React:

Other frameworks:

Create the most appropriate temporary route for the detected framework.

Variant Generation Guidelines

IMPORTANT: Read DESIGN_PRINCIPLES.md for UX, interaction, and motion best practices. But DO NOT use predefined visual styles—infer them from the project.

Apply universal principles (from DESIGN_PRINCIPLES.md):

Infer visual styles from the project:


Each variant MUST explore a different design axis. Do not create minor variations—make them meaningfully distinct. Use the project's existing visual language for all variants.

Variant A: Information Hierarchy Focus

Variant B: Layout Model Exploration

Variant C: Density Variation

Variant D: Interaction Model

Variant E: Expressive Direction

Lab Page Requirements

The Design Lab page must include:

  1. Header with:
  1. Variant Grid with:
  1. Responsive behavior:
  1. Shared Data:
  1. Feedback Overlay (CRITICAL - NEVER OMIT):

⚠️ THIS IS THE MOST IMPORTANT REQUIREMENT ⚠️

The FeedbackOverlay enables users to click on elements and leave comments. Without it, the Design Lab is just a static page with no way to collect structured feedback.

Example integration:

import { FeedbackOverlay } from './FeedbackOverlay';  // Relative import - always works

export default function DesignLabPage() {
  return (
    <div className="min-h-screen bg-background">
      <header>...</header>

      <main>
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
          <div data-variant="A">
            <VariantA />
          </div>
          <div data-variant="B">
            <VariantB />
          </div>
          {/* ... more variants */}
        </div>
      </main>

      {/* CRITICAL: FeedbackOverlay must be included */}
      <FeedbackOverlay targetName="ComponentName" />
    </div>
  );
}

If you forget the FeedbackOverlay, the user CANNOT provide feedback. This defeats the entire purpose of the Design Lab.

Code Quality

Conventions:

Accessibility (from DESIGN_PRINCIPLES):

States (every component needs):

Motion:


Phase 4: Present Design Lab to User

After generating the lab files, immediately present the lab to the user. Do NOT attempt to:

What to Do

  1. Output the lab location and URL:

```

✅ Design Lab created!

I've generated 5 design variants in .claude-design/lab/

To view them:

1. Make sure your dev server is running (run pnpm dev if not)

2. Open: http://localhost:3000/__design_lab

Take your time reviewing the variants side-by-side, then come back and tell me:

```

  1. Immediately proceed to Phase 5 - ask for feedback. Do NOT wait for the user to say they've opened the browser. Just present the feedback questions right away so they're ready when the user returns.

Why Not Start the Server

Running pnpm dev or npm run dev starts a long-running process that never exits. If you run it, you'll wait forever. The user likely already has their dev server running, or can start it themselves in another terminal.


Phase 5: Collect Feedback

After presenting the lab URL, the user can provide feedback in two ways:

  1. Interactive Feedback (recommended): Using the built-in overlay in the browser
  2. Manual Feedback: Via AskUserQuestion in the terminal

Interactive Feedback (Primary Method)

The Design Lab includes a Figma-like feedback overlay. When presenting the lab, include these instructions:

✅ Design Lab created!

I've generated 5 design variants in `.claude-design/lab/`

To view and provide feedback:
1. Make sure your dev server is running (run `pnpm dev` if not)
2. Open: http://localhost:3000/__design_lab

**To add feedback:**
1. Click the "Add Feedback" button (bottom-right corner)
2. Click any element you want to comment on
3. Type your feedback and click "Save"
4. Repeat for all elements you want to comment on
5. Fill in the "Overall Direction" field (required)
6. Click "Submit All Feedback"
7. Paste the copied text here in the terminal

Or just describe your feedback manually below!

When the user pastes feedback, it will be in this format:

## Design Lab Feedback

**Target:** ComponentName
**Comments:** 3

### Variant A
1. **Button** (`[data-testid='submit']`, button with "Submit")
   "Make this more prominent"

### Variant B
1. **Card** (`.product-card`, div with "Product Name")
   "Love this layout"

### Overall Direction
Go with Variant B's structure. Apply Variant A's button styling.

How to parse and act on this feedback:

  1. Read the Overall Direction first - this guides your synthesis
  2. For each comment, locate the element using:
  1. Apply the feedback by editing the corresponding variant file

Fallback: Manual Feedback via AskUserQuestion

If the user prefers not to use the interactive overlay (or pastes manual feedback), use the AskUserQuestion flow below:

Stage 1: Check for a Winner

Question 1: Ready to pick?

Stage 2A: If User Found a Winner

If user said "Yes", ask:

Question 2a: Which one?

Question 3a: Any tweaks?

If "Minor tweaks needed", ask user to describe changes via text input.

Then proceed to Phase 7: Final Preview.

Stage 2B: If User Wants to Synthesize

If user said "No - I like parts of different ones", ask:

Question 2b: What do you like about each?

Example response format to guide user:

- A: Love the card layout and spacing
- B: The color scheme feels right
- C: The interaction on hover is great
- D: Nothing stands out
- E: The typography hierarchy is clearest

Then proceed to Phase 6: Synthesize New Variant.


Phase 6: Synthesize New Variant

Based on the user's feedback about what they liked from each variant:

  1. Create a new hybrid variant (Variant F) that combines:
  1. Replace the Design Lab with a comparison view:
  1. Update the /__design_lab route to show the new arrangement
  1. Ask for feedback again:

Question: How's the new variant?

If "Getting closer" or "Went the wrong direction", gather more specific feedback and iterate. Support multiple synthesis passes until user is satisfied.

Then proceed to Phase 7: Final Preview.


Phase 7: Final Preview

Once user is satisfied:

  1. Create .claude-design/preview/ directory:

```

.claude-design/preview/

├── page.tsx # Preview page

└── FinalDesign.tsx # The winning design

```

  1. Create route at /__design_preview
  1. For redesigns, include before/after comparison:
  1. Ask for final confirmation:

Question: Confirm final design?

If "No, needs changes": gather feedback and iterate.

If "Abort": proceed to Abort Handling below.


Abort Handling

If the user wants to cancel/abort at ANY point during the process (not just final confirmation), they may say things like:

When abort is detected:

  1. Confirm the abort:
  1. If confirmed, clean up immediately:
  1. Acknowledge:

Phase 8: Finalize

When user confirms (selected "Yes, finalize it"):

8.1: Cleanup

Delete all temporary files:

Safety rules:

8.2: Generate Implementation Plan

Create DESIGN_PLAN.md in the project root:

# Design Implementation Plan: [TargetName]

## Summary
- **Scope:** [component/page]
- **Target:** [file path]
- **Winner variant:** [A-E]
- **Key improvements:** [from feedback]

## Files to Change
- [ ] `src/components/Example.tsx` - Main component refactor
- [ ] `src/styles/example.css` - Style updates
- [ ] ... (list all affected files)

## Implementation Steps
1. [Specific step with code guidance]
2. [Next step]
3. ...

## Component API
- **Props:**
  - `prop1: type` - description
  - ...
- **State:**
  - Internal state requirements
- **Events:**
  - Callbacks and handlers

## Required UI States
- **Loading:** [description]
- **Empty:** [description]
- **Error:** [description]
- **Disabled:** [description]
- **Validation:** [description]

## Accessibility Checklist
- [ ] Keyboard navigation works
- [ ] Focus states visible
- [ ] Labels and aria-* attributes correct
- [ ] Color contrast meets WCAG AA
- [ ] Screen reader tested

## Testing Checklist
- [ ] Unit tests for logic
- [ ] Component tests for rendering
- [ ] Visual regression tests (if applicable)
- [ ] E2E smoke test (if applicable)

## Design Tokens
- [Any new tokens to add]
- [Existing tokens to use]

---

*Generated by Design Variations plugin*

8.3: Update Design Memory

Create or update DESIGN_MEMORY.md:

If new file:

# Design Memory

## Brand Tone
- **Adjectives:** [from interview]
- **Avoid:** [anti-patterns discovered]

## Layout & Spacing
- **Density:** [preference]
- **Grid:** [if established]
- **Corner radius:** [if consistent]
- **Shadows:** [if consistent]

## Typography
- **Headings:** [font, weights used]
- **Body:** [font, size]
- **Emphasis:** [patterns]

## Color
- **Primary:** [color tokens]
- **Secondary:** [color tokens]
- **Neutral strategy:** [approach]
- **Semantic colors:** [error, success, warning]

## Interaction Patterns
- **Forms:** [validation approach, layout]
- **Modals/Drawers:** [when to use which]
- **Tables/Lists:** [preferred patterns]
- **Feedback:** [toast, inline, etc.]

## Accessibility Rules
- **Focus:** [visible focus approach]
- **Labels:** [labeling conventions]
- **Motion:** [reduced motion support]

## Repo Conventions
- **Component structure:** [file organization]
- **Styling approach:** [Tailwind classes, CSS modules, etc.]
- **Existing primitives:** [Button, Input, Card, etc.]

---

*Updated by Design Variations plugin*

If updating existing file:


Error Handling

Framework Not Detected

If framework cannot be determined:

Dev Server Fails

If dev server won't start:

Route Integration Fails

If can't create temporary route:

Cleanup Interrupted

If cleanup is interrupted:


Configuration Options

The plugin supports these optional configurations (via environment or project config):


Example Session Flow

  1. User: /design-variations:design CheckoutSummary
  2. Plugin detects: Next.js App Router, Tailwind, pnpm
  3. Plugin finds: No existing Design Memory
  4. Plugin asks: Interview questions (5 steps)
  5. Plugin generates: Design Brief summary
  6. Plugin creates: .claude-design/lab/ with 5 variants
  7. Plugin creates: app/__design_lab/page.tsx
  8. Plugin starts: pnpm dev
  9. Plugin outputs: "Open http://localhost:3000/__design_lab"
  10. User reviews variants in browser
  11. Plugin asks: "Which variant wins?"
  12. User: "Variant C, but change X and Y"
  13. Plugin refines: Updates Variant C
  14. User: "Looks good"
  15. Plugin creates: Final preview at /__design_preview
  16. User: "Confirmed"
  17. Plugin: Deletes all temp files
  18. Plugin: Generates DESIGN_PLAN.md
  19. Plugin: Creates DESIGN_MEMORY.md
  20. Plugin: "Done! See DESIGN_PLAN.md for implementation steps"
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.