design-lab

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Design Lab Skill

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:
  • User confirms final design → cleanup, then generate plan
  • User aborts/cancels → cleanup immediately, no plan generated
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.

无论出于何种情况,流程结束后必须删除所有临时文件:
  • 用户确认最终设计 → 清理文件,然后生成计划
  • 用户中止/取消 → 立即清理,不生成计划
不得遗留
.claude-design/
__design_lab
路由文件。
如果用户在任何时候说出“cancel”、“abort”、“stop”或“nevermind”,请先确认,然后删除所有临时文件。

Phase 0: Preflight Detection

阶段0:前置检查

Before starting the interview, automatically detect:
在开始访谈前,自动检测以下内容:

Package Manager

包管理器

Check for lock files in the project root:
  • pnpm-lock.yaml
    → use
    pnpm
  • yarn.lock
    → use
    yarn
  • package-lock.json
    → use
    npm
  • bun.lockb
    → use
    bun
检查项目根目录下的锁文件:
  • pnpm-lock.yaml
    → 使用
    pnpm
  • yarn.lock
    → 使用
    yarn
  • package-lock.json
    → 使用
    npm
  • bun.lockb
    → 使用
    bun

Framework Detection

框架检测

Check for config files:
  • next.config.js
    or
    next.config.mjs
    or
    next.config.ts
    Next.js
    • Check for
      app/
      directory → App Router
    • Check for
      pages/
      directory → Pages Router
  • vite.config.js
    or
    vite.config.ts
    Vite
  • remix.config.js
    Remix
  • nuxt.config.js
    or
    nuxt.config.ts
    Nuxt
  • astro.config.mjs
    Astro
检查配置文件:
  • next.config.js
    next.config.mjs
    next.config.ts
    Next.js
    • 检查
      app/
      目录 → App Router
    • 检查
      pages/
      目录 → Pages Router
  • vite.config.js
    vite.config.ts
    Vite
  • remix.config.js
    Remix
  • nuxt.config.js
    nuxt.config.ts
    Nuxt
  • astro.config.mjs
    Astro

Styling System Detection

样式系统检测

Check
package.json
dependencies and config files:
  • tailwind.config.js
    or
    tailwind.config.ts
    Tailwind CSS
  • @mui/material
    in dependencies → Material UI
  • @chakra-ui/react
    in dependencies → Chakra UI
  • antd
    in dependencies → Ant Design
  • styled-components
    in dependencies → styled-components
  • @emotion/react
    in dependencies → Emotion
  • .css
    or
    .module.css
    files → CSS Modules
检查
package.json
依赖和配置文件:
  • tailwind.config.js
    tailwind.config.ts
    Tailwind CSS
  • 依赖中包含
    @mui/material
    Material UI
  • 依赖中包含
    @chakra-ui/react
    Chakra UI
  • 依赖中包含
    antd
    Ant Design
  • 依赖中包含
    styled-components
    styled-components
  • 依赖中包含
    @emotion/react
    Emotion
  • 存在
    .css
    .module.css
    文件 → CSS Modules

Design Memory Check

设计记忆检查

Look for existing Design Memory file:
  • docs/design-memory.md
  • DESIGN_MEMORY.md
  • .claude-design/design-memory.md
If found, read it and use to prefill defaults and skip redundant questions.
查找现有的Design Memory文件:
  • docs/design-memory.md
  • DESIGN_MEMORY.md
  • .claude-design/design-memory.md
如果找到,请读取文件内容,用于预填充默认值并跳过重复问题。

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
:
javascript
// 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:
css
: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:
  • MUI:
    theme.ts
    or
    createTheme()
    call
  • Chakra:
    theme/index.ts
    or
    extendTheme()
    call
  • Ant:
    ConfigProvider
    theme prop
Always scan existing components to understand patterns:
  • Find 2-3 existing buttons → note their styling patterns
  • Find 2-3 existing cards → note padding, borders, shadows
  • Find existing forms → note input styles, label placement
  • Find existing typography → note heading sizes, body text
Store inferred styles in the Design Brief for consistent use across all variants.

请勿使用通用/预定义样式。需从项目中提取视觉语言:
如果检测到Tailwind,请读取
tailwind.config.js
tailwind.config.ts
javascript
// 提取并使用:
theme.colors      // 调色板
theme.spacing     // 间距比例
theme.borderRadius // 圆角值
theme.fontFamily  // 字体主题
theme.boxShadow   // 层级阴影系统
如果存在CSS变量,请读取
globals.css
variables.css
:root
定义:
css
:root {
  --color-*     /* 颜色令牌 */
  --spacing-*   /* 间距令牌 */
  --font-*      /* 字体令牌 */
  --radius-*    /* 圆角令牌 */
}
如果检测到UI库(MUI、Chakra、Ant),请读取主题配置:
  • MUI:
    theme.ts
    createTheme()
    调用
  • Chakra:
    theme/index.ts
    extendTheme()
    调用
  • Ant:
    ConfigProvider
    主题属性
始终扫描现有组件以理解设计模式:
  • 找到2-3个现有按钮 → 记录其样式模式
  • 找到2-3个现有卡片 → 记录内边距、边框、阴影
  • 找到现有表单 → 记录输入框样式、标签位置
  • 找到现有排版 → 记录标题尺寸、正文样式
将推导的样式存储在设计简报中,以便在所有变体中保持一致。

Phase 1: Interview

阶段1:访谈

Use the AskUserQuestion tool for all interview steps. Adapt questions based on Design Memory if it exists.
所有访谈步骤均使用AskUserQuestion工具。如果存在Design Memory,请据此调整问题。

Step 1.1: Scope & Target

步骤1.1:范围与目标

Ask these questions (can combine into single AskUserQuestion with multiple questions):
Question 1: Scope
  • Header: "Scope"
  • Question: "Are we designing a single component or a full page?"
  • Options:
    • "Component" - A reusable UI element (button, card, form, modal, etc.)
    • "Page" - A complete page or screen layout
Question 2: New or Redesign
  • Header: "Type"
  • Question: "Is this a new design or a redesign of something existing?"
  • Options:
    • "New" - Creating something from scratch
    • "Redesign" - Improving an existing component/page
If "Redesign" selected, ask: Question 3: Existing Path
  • Header: "Location"
  • Question: "What is the file path or route of the existing UI?"
  • Options: (let user provide via "Other")
If target is unclear, propose a name based on repo patterns and confirm.
提出以下问题(可合并为一个AskUserQuestion包含多个问题):
问题1:范围
  • 标题:"范围"
  • 问题:"我们是设计单个组件还是完整页面?"
  • 选项:
    • "Component" - 可复用UI元素(按钮、卡片、表单、模态框等)
    • "Page" - 完整页面或屏幕布局
问题2:新设计还是重新设计
  • 标题:"类型"
  • 问题:"这是新设计还是对现有内容的重新设计?"
  • 选项:
    • "New" - 从零开始创建
    • "Redesign" - 改进现有组件/页面
如果选择“Redesign”,请提出: 问题3:现有路径
  • 标题:"位置"
  • 问题:"现有UI的文件路径或路由是什么?"
  • 选项:(让用户通过“Other”提供)
如果目标不明确,请根据仓库模式提议一个名称并确认。

Step 1.2: Pain Points & Inspiration

步骤1.2:痛点与灵感

Question 1: Pain Points
  • Header: "Problems"
  • Question: "What are the top pain points with the current design (or what should this new design avoid)?"
  • Options:
    • "Too cluttered/dense" - Information overload, hard to scan
    • "Unclear hierarchy" - Primary actions aren't obvious
    • "Poor mobile experience" - Doesn't work well on small screens
    • "Outdated look" - Feels old or inconsistent with brand
  • multiSelect: true
Question 2: Visual Inspiration
  • Header: "Visual style"
  • Question: "What products or brands should I reference for visual inspiration?"
  • Options:
    • "Stripe" - Clean, minimal, trustworthy
    • "Linear" - Dense, keyboard-first, developer-focused
    • "Notion" - Flexible, content-focused, playful
    • "Apple" - Premium, spacious, refined
  • multiSelect: true
Question 3: Functional Inspiration
  • Header: "Interactions"
  • Question: "What interaction patterns should I emulate?"
  • Options:
    • "Inline editing" - Edit in place without modals
    • "Progressive disclosure" - Show more as needed
    • "Optimistic updates" - Instant feedback, sync in background
    • "Keyboard shortcuts" - Power user efficiency
问题1:痛点
  • 标题:"问题"
  • 问题:"当前设计的主要痛点是什么(或新设计应避免哪些问题)?"
  • 选项:
    • "Too cluttered/dense" - 信息过载,难以浏览
    • "Unclear hierarchy" - 主要操作不明确
    • "Poor mobile experience" - 在小屏幕上表现不佳
    • "Outdated look" - 外观过时或与品牌不一致
  • 多选:是
问题2:视觉灵感
  • 标题:"视觉风格"
  • 问题:"应参考哪些产品或品牌获取视觉灵感?"
  • 选项:
    • "Stripe" - 简洁、极简、可信
    • "Linear" - 紧凑、优先键盘操作、面向开发者
    • "Notion" - 灵活、以内容为中心、趣味化
    • "Apple" - 高端、宽敞、精致
  • 多选:是
问题3:功能灵感
  • 标题:"交互"
  • 问题:"应效仿哪些交互模式?"
  • 选项:
    • "Inline editing" - 无需模态框,就地编辑
    • "Progressive disclosure" - 根据需要逐步展示更多内容
    • "Optimistic updates" - 即时反馈,后台同步
    • "Keyboard shortcuts" - 满足高级用户效率需求

Step 1.3: Brand & Style Direction

步骤1.3:品牌与风格方向

Question 1: Brand Adjectives
  • Header: "Brand tone"
  • Question: "What 3-5 adjectives describe the desired brand feel?"
  • Options:
    • "Minimal" - Clean, simple, uncluttered
    • "Premium" - High-end, polished, refined
    • "Playful" - Fun, friendly, approachable
    • "Utilitarian" - Functional, efficient, no-nonsense
  • multiSelect: true
Question 2: Density
  • Header: "Density"
  • Question: "What information density do you prefer?"
  • Options:
    • "Compact" - More information visible, tighter spacing
    • "Comfortable" - Balanced spacing, easy scanning
    • "Spacious" - Generous whitespace, focused attention
Question 3: Dark Mode
  • Header: "Dark mode"
  • Question: "Is dark mode required?"
  • Options:
    • "Yes" - Must support dark mode
    • "No" - Light mode only
    • "Nice to have" - Support if easy, not required
问题1:品牌形容词
  • 标题:"品牌调性"
  • 问题:"用3-5个形容词描述期望的品牌感受?"
  • 选项:
    • "Minimal" - 简洁、简单、整洁
    • "Premium" - 高端、精致、精良
    • "Playful" - 有趣、友好、亲切
    • "Utilitarian" - 实用、高效、务实
  • 多选:是
问题2:密度
  • 标题:"密度"
  • 问题:"您偏好何种信息密度?"
  • 选项:
    • "Compact" - 展示更多信息,间距更紧凑
    • "Comfortable" - 间距平衡,易于浏览
    • "Spacious" - 充足留白,聚焦注意力
问题3:深色模式
  • 标题:"深色模式"
  • 问题:"是否需要支持深色模式?"
  • 选项:
    • "Yes" - 必须支持深色模式
    • "No" - 仅支持浅色模式
    • "Nice to have" - 若容易实现则支持,非必需

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

步骤1.4:用户角色与待办任务

Question 1: Primary User
  • Header: "User"
  • Question: "Who is the primary end user?"
  • Options:
    • "Developer" - Technical, keyboard-oriented
    • "Designer" - Visual, detail-oriented
    • "Business user" - Efficiency-focused, less technical
    • "End consumer" - General public, varied technical ability
Question 2: Context
  • Header: "Context"
  • Question: "What's the primary usage context?"
  • Options:
    • "Desktop-first" - Primarily used on larger screens
    • "Mobile-first" - Primarily used on phones
    • "Both equally" - Must work well on all devices
Question 3: Key Tasks
  • Header: "Key tasks"
  • Question: "What are the top 3 tasks users must complete?"
  • (Let user provide via "Other" - this is open-ended)
问题1:主要用户
  • 标题:"用户"
  • 问题:"主要终端用户是谁?"
  • 选项:
    • "Developer" - 技术型,偏好键盘操作
    • "Designer" - 视觉型,注重细节
    • "Business user" - 注重效率,技术能力较弱
    • "End consumer" - 普通大众,技术能力参差不齐
问题2:使用场景
  • 标题:"场景"
  • 问题:"主要使用场景是什么?"
  • 选项:
    • "Desktop-first" - 主要在大屏设备上使用
    • "Mobile-first" - 主要在手机上使用
    • "Both equally" - 必须在所有设备上表现良好
问题3:核心任务
  • 标题:"核心任务"
  • 问题:"用户必须完成的前3项核心任务是什么?"
  • (让用户通过“Other”提供,此为开放式问题)

Step 1.5: Constraints

步骤1.5:约束条件

Question 1: Must-Keep Elements
  • Header: "Keep"
  • Question: "Are there elements that must be preserved?"
  • Options:
    • "Existing copy/labels" - Keep current text
    • "Current fields/inputs" - Keep form structure
    • "Navigation structure" - Keep current nav
    • "None" - Free to change everything
Question 2: Technical Constraints
  • Header: "Constraints"
  • Question: "Any technical constraints?"
  • Options:
    • "No new dependencies" - Use existing libraries only
    • "Use existing components" - Build on current design system
    • "Must be accessible (WCAG)" - Strict accessibility requirements
    • "None" - No special constraints
  • multiSelect: true

问题1:必须保留的元素
  • 标题:"保留内容"
  • 问题:"是否有必须保留的元素?"
  • 选项:
    • "Existing copy/labels" - 保留当前文本内容
    • "Current fields/inputs" - 保留表单结构
    • "Navigation structure" - 保留当前导航结构
    • "None" - 可自由修改所有内容
问题2:技术约束
  • 标题:"约束条件"
  • 问题:"是否有任何技术约束?"
  • 选项:
    • "No new dependencies" - 仅使用现有库
    • "Use existing components" - 基于现有设计系统构建
    • "Must be accessible (WCAG)" - 严格符合无障碍要求
    • "None" - 无特殊约束
  • 多选:是

Phase 2: Generate Design Brief

阶段2:生成设计简报

After the interview, create a structured Design Brief as JSON and save to
.claude-design/design-brief.json
:
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.

访谈结束后,创建结构化的设计简报并保存为
.claude-design/design-brief.json
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"
}
在继续下一步前,向用户展示简报摘要。

Phase 3: Generate Design Lab

阶段3:生成设计实验室

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
所有文件均创建在
.claude-design/
下:
.claude-design/
├── lab/
│   ├── page.tsx                 # 主实验室页面(框架专属)
│   ├── variants/
│   │   ├── VariantA.tsx
│   │   ├── VariantB.tsx
│   │   ├── VariantC.tsx
│   │   ├── VariantD.tsx
│   │   └── VariantE.tsx
│   ├── components/
│   │   └── LabShell.tsx         # 实验室布局容器
│   ├── feedback/                # 交互式反馈系统
│   │   ├── types.ts             # TypeScript接口
│   │   ├── selector-utils.ts    # 元素识别工具
│   │   ├── format-utils.ts      # 反馈格式化工具
│   │   ├── FeedbackOverlay.tsx  # 主覆盖层组件
│   │   └── index.ts             # 模块导出
│   └── data/
│       └── fixtures.ts          # 共享模拟数据
├── 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:
  • .claude-design/
    paths can fail due to bundler configurations
  • Relative imports from the same directory always work
  • The route directory gets deleted during cleanup anyway
FeedbackOverlay是Design Lab的核心功能。 若无此功能,用户无法提供交互式反馈。绝对不能生成无FeedbackOverlay的Design Lab。
可靠性策略: 为避免不同项目配置下的导入路径问题,请直接在路由目录(如
app/design-lab/FeedbackOverlay.tsx
)中创建FeedbackOverlay,而非
.claude-design/
。这样可确保相对导入(
./FeedbackOverlay
)始终有效。
路由目录中必需的文件:
app/design-lab/           # 若下划线有效则使用app/__design_lab/
├── page.tsx              # 包含变体的主实验室页面
└── FeedbackOverlay.tsx   # 独立的覆盖层组件(从模板复制)
模板来源:
design-and-refine/templates/feedback/FeedbackOverlay.tsx
此方案的优势:
  • .claude-design/
    路径可能因打包器配置而失效
  • 同一目录下的相对导入始终有效
  • 路由目录在清理时会被删除

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:
  • If React Router exists: add route to
    /__design_lab
  • If no router: create a conditional render in
    App.tsx
    based on
    ?design_lab=true
    query param
Other frameworks: Create the most appropriate temporary route for the detected framework.
Next.js App Router: 创建
app/__design_lab/page.tsx
,从
.claude-design/lab/
导入内容
Next.js Pages Router: 创建
pages/__design_lab.tsx
,从
.claude-design/lab/
导入内容
Vite React:
  • 若存在React Router:添加
    /__design_lab
    路由
  • 若无路由:在
    App.tsx
    中基于
    ?design_lab=true
    查询参数实现条件渲染
其他框架: 为检测到的框架创建最合适的临时路由。

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):
  • UX: Nielsen's heuristics, cognitive load reduction, progressive disclosure
  • Component behavior: Button states, form anatomy, card structure
  • Interaction: Feedback patterns, state handling, optimistic updates
  • Motion: Timing (150-300ms), easing (ease-out entrances, ease-in exits)
  • Accessibility: Focus states, ARIA patterns, touch targets (44px min)
Infer visual styles from the project:
  • Colors → from Tailwind config, CSS variables, or existing components
  • Typography → from existing headings, body text in the codebase
  • Spacing → from the project's spacing scale or existing patterns
  • Border radius → from existing cards, buttons, inputs
  • Shadows → from existing elevated components

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
  • Restructure content hierarchy (what's most important?)
  • Apply Gestalt proximity—group related items closer
  • One primary action per view
  • Use existing typography scale to create clear levels
Variant B: Layout Model Exploration
  • Try a different layout approach (card vs list vs table vs split-pane)
  • Apply card anatomy or table behavior patterns from DESIGN_PRINCIPLES
  • Consider responsive behavior at each breakpoint
  • Use the project's existing grid/layout system
Variant C: Density Variation
  • If brief says "comfortable", try a more compact version
  • If brief says "compact", try a more spacious version
  • Use the project's existing spacing tokens—just apply them differently
  • Show the tradeoffs: more visible data vs easier scanning
Variant D: Interaction Model
  • Different interaction pattern (modal vs inline vs panel vs drawer)
  • Apply feedback patterns: immediate → progress → completion
  • Implement all required states (loading, error, empty, disabled)
  • Consider optimistic updates for non-destructive actions
Variant E: Expressive Direction
  • Push the brand direction the user described in the interview
  • Explore different uses of the project's existing design tokens
  • More or less use of shadows, borders, background colors
  • Apply motion where it adds meaning (hover, focus, transitions)
重要提示: 请阅读
DESIGN_PRINCIPLES.md
以获取UX、交互和动效最佳实践。但请勿使用预定义视觉样式——需从项目中推导样式。
应用通用原则(来自DESIGN_PRINCIPLES.md):
  • UX:尼尔森启发式原则、认知负荷降低、渐进式展示
  • 组件行为:按钮状态、表单结构、卡片布局
  • 交互:反馈模式、状态处理、乐观更新
  • 动效:时长(150-300ms)、缓动(入场用ease-out,退场用ease-in)
  • 无障碍:焦点状态、ARIA模式、触摸目标(最小44px)
从项目中推导视觉样式:
  • 颜色 → 来自Tailwind配置、CSS变量或现有组件
  • 排版 → 来自项目中已有的标题、正文样式
  • 间距 → 来自项目的间距比例或现有模式
  • 圆角 → 来自现有卡片、按钮、输入框
  • 阴影 → 来自现有层级组件

每个变体必须探索不同的设计方向。请勿创建微小变体——需确保变体间有显著差异。所有变体均需使用项目现有的视觉语言。
变体A:信息层级聚焦
  • 重构内容层级(明确核心内容)
  • 应用格式塔接近性原则——将相关内容分组放置
  • 每个视图仅保留一个主要操作
  • 使用现有排版比例创建清晰的层级
变体B:布局模型探索
  • 尝试不同的布局方式(卡片式 vs 列表式 vs 表格式 vs 分栏式)
  • 应用DESIGN_PRINCIPLES中的卡片结构或表格行为模式
  • 考虑每个断点下的响应式表现
  • 使用项目现有的网格/布局系统
变体C:密度变体
  • 若简报要求“舒适”,尝试更紧凑的版本
  • 若简报要求“紧凑”,尝试更宽敞的版本
  • 使用项目现有的间距令牌——仅调整应用方式
  • 展示权衡:更多可见数据 vs 更易浏览
变体D:交互模型
  • 不同的交互模式(模态框 vs 就地编辑 vs 面板 vs 抽屉)
  • 应用反馈模式:即时反馈 → 进度反馈 → 完成反馈
  • 实现所有必需状态(加载、错误、空状态、禁用)
  • 考虑对非破坏性操作使用乐观更新
变体E:风格延伸
  • 强化用户在访谈中描述的品牌方向
  • 探索项目现有设计令牌的不同用法
  • 调整阴影、边框、背景色的使用程度
  • 在能增强意义的场景应用动效(悬停、焦点、过渡)

Lab Page Requirements

实验室页面要求

The Design Lab page must include:
  1. Header with:
    • Design Brief summary (target, scope, key requirements)
    • Instructions for reviewing
  2. Variant Grid with:
    • Clear labels (A, B, C, D, E)
    • Brief rationale for each variant ("Why this exists")
    • The actual rendered variant
    • Notes highlighting key differences
    • IMPORTANT: Each variant container must have
      data-variant="X"
      attribute (where X is A, B, C, D, E, or F). This is required for the feedback system to identify which variant comments belong to.
  3. Responsive behavior:
    • Desktop: side-by-side grid (2-3 columns)
    • Mobile: horizontal scroll or tabs
  4. Shared Data:
    • All variants use the same fixture data from
      data/fixtures.ts
    • Ensures fair comparison
  5. 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.
    • Create
      FeedbackOverlay.tsx
      in the SAME directory as
      page.tsx
    • Import with relative path:
      import { FeedbackOverlay } from './FeedbackOverlay'
    • Render at the END of the page, after all variants
    • Pass
      targetName
      prop with the component/page name
    Example integration:
tsx
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.
Design Lab页面必须包含:
  1. 页头,包含:
    • 设计简报摘要(目标、范围、核心要求)
    • 审阅说明
  2. 变体网格,包含:
    • 清晰的标签(A、B、C、D、E)
    • 每个变体的简短设计理由(“设计初衷”)
    • 实际渲染的变体
    • 突出关键差异的说明
    • 重要提示: 每个变体容器必须添加
      data-variant="X"
      属性(X为A、B、C、D、E或F)。这是反馈系统识别评论所属变体的必需条件。
  3. 响应式表现
    • 桌面端:并排网格(2-3列)
    • 移动端:横向滚动或标签页
  4. 共享数据
    • 所有变体使用
      data/fixtures.ts
      中的相同模拟数据
    • 确保公平对比
  5. 反馈覆盖层(重要提示 - 请勿省略):
    ⚠️ 这是最重要的要求 ⚠️
    FeedbackOverlay允许用户点击元素并留下评论。若无此功能,Design Lab只是无法收集结构化反馈的静态页面。
    • 在与
      page.tsx
      相同的目录中创建
      FeedbackOverlay.tsx
    • 使用相对路径导入:
      import { FeedbackOverlay } from './FeedbackOverlay'
    • 在所有变体之后渲染
    • 传递
      targetName
      属性,值为组件/页面名称
    示例集成:
tsx
import { FeedbackOverlay } from './FeedbackOverlay';  // 相对导入 - 始终有效

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>
          {/* ... 更多变体 */}
        </div>
      </main>

      // 重要提示:必须包含FeedbackOverlay
      <FeedbackOverlay targetName="ComponentName" />
    </div>
  );
}
若忘记添加FeedbackOverlay,用户将无法提供反馈。这会完全违背Design Lab的初衷。

Code Quality

代码质量

Conventions:
  • Follow the project's existing code conventions (file naming, imports, etc.)
  • Use the detected styling system (Tailwind, CSS modules, etc.)
  • Use existing components from the project where appropriate
Accessibility (from DESIGN_PRINCIPLES):
  • Semantic HTML:
    <button>
    not
    <div onclick>
    ,
    <nav>
    ,
    <main>
    ,
    <section>
  • Keyboard navigation: all interactive elements focusable and operable
  • Focus states: visible
    :focus-visible
    with 2px ring and offset
  • Color contrast: 4.5:1 for text, 3:1 for UI elements
  • Touch targets: minimum 44x44px
  • ARIA only when HTML semantics aren't enough
States (every component needs):
  • Default, Hover, Focus, Active, Disabled, Loading, Error, Empty
  • See DESIGN_PRINCIPLES "State Handling" section
Motion:
  • Use appropriate timing: 150-200ms for micro-interactions, 200-300ms for transitions
  • Use ease-out for entrances, ease-in for exits
  • Respect
    prefers-reduced-motion

编码规范:
  • 遵循项目现有的编码规范(文件命名、导入方式等)
  • 使用检测到的样式系统(Tailwind、CSS Modules等)
  • 适当使用项目中的现有组件
无障碍(来自DESIGN_PRINCIPLES):
  • 语义化HTML:使用
    <button>
    而非
    <div onclick>
    ,以及
    <nav>
    <main>
    <section>
  • 键盘导航:所有交互元素可聚焦且可操作
  • 焦点状态:可见的
    :focus-visible
    ,带2px边框和偏移
  • 颜色对比度:文本4.5:1,UI元素3:1
  • 触摸目标:最小44x44px
  • 仅在HTML语义不足时使用ARIA
状态(每个组件都需要):
  • 默认、悬停、焦点、激活、禁用、加载、错误、空状态
  • 请查看DESIGN_PRINCIPLES的“状态处理”章节
动效:
  • 使用合适的时长:微交互150-200ms,过渡效果200-300ms
  • 入场用ease-out,退场用ease-in
  • 尊重
    prefers-reduced-motion
    设置

Phase 4: Present Design Lab to User

阶段4:向用户展示Design Lab

After generating the lab files, immediately present the lab to the user. Do NOT attempt to:
  • Start the dev server yourself (it runs forever and will block)
  • Check if ports are open
  • Open a browser
  • Wait for any server response
生成实验室文件后,请立即向用户展示。请勿尝试:
  • 自行启动开发服务器(服务器会一直运行,导致阻塞)
  • 检查端口是否开放
  • 打开浏览器
  • 等待服务器响应

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:
    - Which variant wins (A-E)
    - What you like about it
    - What should change
  2. 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.
  1. 输出实验室位置和URL:
    ✅ Design Lab已创建!
    
    我已在`.claude-design/lab/`中生成了5种设计变体
    
    查看方式:
    1. 确保开发服务器正在运行(若未运行请执行`pnpm dev`)
    2. 打开:http://localhost:3000/__design_lab
    
    请慢慢对比审阅这些变体,然后告诉我:
    - 您选择哪个变体(A-E)
    - 您喜欢它的哪些方面
    - 需要修改哪些内容
  2. 立即进入阶段5 - 询问反馈。无需等待用户表示已打开浏览器。直接展示反馈问题,方便用户返回时即可提供反馈。

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.

执行
pnpm dev
npm run dev
会启动一个长期运行的进程,永远不会退出。若您执行此操作,会一直等待。用户很可能已经在运行开发服务器,或可在另一个终端自行启动。

Phase 5: Collect Feedback

阶段5:收集反馈

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
展示实验室URL后,用户可通过两种方式提供反馈:
  1. 交互式反馈(推荐):使用浏览器中的内置覆盖层
  2. 手动反馈:通过终端中的AskUserQuestion

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:
markdown
undefined
Design Lab包含类似Figma的反馈覆盖层。展示实验室时,请包含以下说明:
✅ Design Lab已创建!

   我已在`.claude-design/lab/`中生成了5种设计变体

   查看并提供反馈的方式:
   1. 确保开发服务器正在运行(若未运行请执行`pnpm dev`)
   2. 打开:http://localhost:3000/__design_lab

   **添加反馈的步骤:**
   1. 点击“添加反馈”按钮(右下角)
   2. 点击您想评论的任意元素
   3. 输入反馈内容并点击“保存”
   4. 重复此步骤为所有需要评论的元素添加反馈
   5. 填写“整体方向”字段(必填)
   6. 点击“提交所有反馈”
   7. 将复制的文本粘贴到终端此处

   或者直接在下方手动描述您的反馈!
当用户粘贴反馈时,格式如下:
markdown
undefined

Design Lab Feedback

Design Lab反馈

Target: ComponentName Comments: 3
目标: ComponentName 评论数: 3

Variant A

变体A

  1. Button (
    [data-testid='submit']
    , button with "Submit") "Make this more prominent"
  1. 按钮 (
    [data-testid='submit']
    , 显示“Submit”的按钮) "请让这个按钮更突出"

Variant B

变体B

  1. Card (
    .product-card
    , div with "Product Name") "Love this layout"
  1. 卡片 (
    .product-card
    , 显示“Product Name”的div) "喜欢这个布局"

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:
   - Primary: The CSS selector in backticks (e.g., `[data-testid='submit']`)
   - Secondary: The element description (e.g., "button with 'Submit'")
3. **Apply the feedback** by editing the corresponding variant file
采用变体B的结构,应用变体A的按钮样式。

**解析并处理反馈的方式:**

1. **先阅读整体方向** - 这将指导您的整合工作
2. **针对每条评论**,通过以下方式定位元素:
   - 优先使用反引号中的CSS选择器(如`[data-testid='submit']`)
   - 其次使用元素描述(如“显示‘Submit’的按钮”)
3. **应用反馈** - 编辑对应的变体文件

Fallback: Manual Feedback via AskUserQuestion

备选方案:通过AskUserQuestion手动反馈

If the user prefers not to use the interactive overlay (or pastes manual feedback), use the AskUserQuestion flow below:
若用户偏好不使用交互式覆盖层(或粘贴手动反馈),请使用以下AskUserQuestion流程:

Stage 1: Check for a Winner

阶段1:确认是否有选定的变体

Question 1: Ready to pick?
  • Header: "Decision"
  • Question: "Is there one variant you like as is?"
  • Options:
    • "Yes - I found one I like" - Ready to select a winner and refine
    • "No - I like parts of different ones" - Need to synthesize a new variant
问题1:是否已选定?
  • 标题:"决策"
  • 问题:"是否有您完全满意的变体?"
  • 选项:
    • "是 - 我找到了喜欢的变体" - 准备选择获胜变体并优化
    • "否 - 我喜欢不同变体中的部分内容" - 需要整合新变体

Stage 2A: If User Found a Winner

阶段2A:若用户已选定变体

If user said "Yes", ask:
Question 2a: Which one?
  • Header: "Winner"
  • Question: "Which variant do you want to go with?"
  • Options:
    • "Variant A" - [brief description of A]
    • "Variant B" - [brief description of B]
    • "Variant C" - [brief description of C]
    • "Variant D" - [brief description of D]
    • "Variant E" - [brief description of E]
Question 3a: Any tweaks?
  • Header: "Tweaks"
  • Question: "Any small changes needed, or is it good as is?"
  • Options:
    • "Good as is" - No changes needed, proceed to final preview
    • "Minor tweaks needed" - I'll describe what to adjust
If "Minor tweaks needed", ask user to describe changes via text input.
Then proceed to Phase 7: Final Preview.
若用户回答“是”,请提出:
问题2a:选择哪个?
  • 标题:"获胜变体"
  • 问题:"您想选择哪个变体?"
  • 选项:
    • "变体A" - [变体A的简短描述]
    • "变体B" - [变体B的简短描述]
    • "变体C" - [变体C的简短描述]
    • "变体D" - [变体D的简短描述]
    • "变体E" - [变体E的简短描述]
问题3a:是否需要调整?
  • 标题:"调整需求"
  • 问题:"是否需要小幅调整,还是直接定稿?"
  • 选项:
    • "直接定稿" - 无需修改,进入最终预览
    • "需要小幅调整" - 我将描述需要调整的内容
若选择“需要小幅调整”,请让用户通过文本输入描述修改内容。
然后进入阶段7:最终预览

Stage 2B: If User Wants to Synthesize

阶段2B:若用户希望整合变体

If user said "No - I like parts of different ones", ask:
Question 2b: What do you like about each?
  • Header: "Feedback"
  • Question: "What do you like about each variant? (mention specific elements from A, B, C, D, E)"
  • (Let user provide detailed feedback via "Other" text input)
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.

若用户回答“否 - 我喜欢不同变体中的部分内容”,请提出:
问题2b:您喜欢每个变体的哪些方面?
  • 标题:"反馈"
  • 问题:"您喜欢每个变体的哪些方面?(请提及A、B、C、D、E中的具体元素)"
  • (让用户通过“Other”文本输入提供详细反馈)
可提供示例回复格式引导用户:
- A:喜欢卡片布局和间距
- B:配色方案很合适
- C:悬停交互很棒
- D:没有突出的优点
- E:排版层级最清晰
然后进入阶段6:整合新变体

Phase 6: Synthesize New Variant

阶段6:整合新变体

Based on the user's feedback about what they liked from each variant:
  1. Create a new hybrid variant (Variant F) that combines:
    • The specific elements the user called out from each
    • The best structural decisions across all variants
    • Any patterns that appeared in multiple variants
  2. Replace the Design Lab with a comparison view:
    • Show the new synthesized Variant F prominently
    • Keep 1-2 of the original variants that were closest for comparison
    • Remove variants that had nothing the user liked
  3. Update the
    /__design_lab
    route
    to show the new arrangement
  4. Ask for feedback again:
Question: How's the new variant?
  • Header: "Review"
  • Question: "How does the synthesized variant (F) look?"
  • Options:
    • "This is it!" - Proceed to final preview
    • "Getting closer" - Need another iteration
    • "Went the wrong direction" - Let me clarify what I want
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.

基于用户反馈中提到的各变体优点:
  1. 创建新的混合变体(变体F),整合:
    • 用户提到的各变体中的具体元素
    • 所有变体中最佳的结构决策
    • 多个变体中出现的共性模式
  2. 替换Design Lab为对比视图
    • 突出展示新整合的变体F
    • 保留1-2个最接近的原始变体用于对比
    • 删除用户未提及优点的变体
  3. 更新
    /__design_lab
    路由
    以展示新的布局
  4. 再次询问反馈:
问题:新变体如何?
  • 标题:"审阅"
  • 问题:"整合后的变体(F)看起来如何?"
  • 选项:
    • "就这个了!" - 进入最终预览
    • "接近了" - 需要再次迭代
    • "方向错了" - 我将明确我的需求
若选择“接近了”或“方向错了”,请收集更具体的反馈并迭代。支持多次整合,直到用户满意。
然后进入阶段7:最终预览

Phase 7: Final Preview

阶段7:最终预览

Once user is satisfied:
  1. Create
    .claude-design/preview/
    directory:
    .claude-design/preview/
    ├── page.tsx                    # Preview page
    └── FinalDesign.tsx             # The winning design
  2. Create route at
    /__design_preview
  3. For redesigns, include before/after comparison:
    • Toggle switch or split view
    • Show original alongside proposed
  4. Ask for final confirmation:
Question: Confirm final design?
  • Header: "Confirm"
  • Question: "Ready to finalize this design?"
  • Options:
    • "Yes, finalize it" - Proceed to cleanup and generate implementation plan
    • "No, needs changes" - Tell me what to adjust
    • "Abort - cancel everything" - Delete all temp files, no plan generated
If "No, needs changes": gather feedback and iterate. If "Abort": proceed to Abort Handling below.

用户满意后:
  1. 创建
    .claude-design/preview/
    目录:
    .claude-design/preview/
    ├── page.tsx                    # 预览页面
    └── FinalDesign.tsx             # 最终设计
  2. 创建
    /__design_preview
    路由
  3. 若为重新设计,请包含前后对比:
    • 切换开关或分栏视图
    • 同时展示原始版本和提议版本
  4. 询问最终确认:
问题:确认最终设计?
  • 标题:"确认"
  • 问题:"是否准备定稿此设计?"
  • 选项:
    • "是,定稿" - 进入清理和生成实施计划阶段
    • "否,需要修改" - 告诉我需要调整的内容
    • "中止 - 取消所有操作" - 删除所有临时文件,不生成计划
若选择“否,需要修改”:收集反馈并迭代。 若选择“中止”:进入下方的中止处理

Abort Handling

中止处理

If the user wants to cancel/abort at ANY point during the process (not just final confirmation), they may say things like:
  • "cancel"
  • "abort"
  • "stop"
  • "nevermind"
  • "forget it"
  • "I changed my mind"
When abort is detected:
  1. Confirm the abort:
    • "Are you sure you want to cancel? This will delete all the design lab files I created."
  2. If confirmed, clean up immediately:
    • Delete
      .claude-design/
      directory entirely
    • Delete temporary route files (
      app/__design_lab/
      , etc.)
    • Do NOT generate any implementation plan
    • Do NOT update Design Memory
  3. Acknowledge:
    • "Design exploration cancelled. All temporary files have been cleaned up. Let me know if you want to start fresh later."

若用户在流程中的任何阶段希望取消/中止(不仅是最终确认),可能会说:
  • "cancel"
  • "abort"
  • "stop"
  • "nevermind"
  • "forget it"
  • "我改变主意了"
检测到中止请求时:
  1. 确认中止:
    • "您确定要取消吗?这将删除我创建的所有设计实验室文件。"
  2. 若用户确认,立即清理:
    • 完全删除
      .claude-design/
      目录
    • 删除临时路由文件(
      app/__design_lab/
      等)
    • 不生成任何实施计划
    • 不更新Design Memory
  3. 告知用户:
    • "设计探索已取消。所有临时文件已清理。若您之后想重新开始,请告诉我。"

Phase 8: Finalize

阶段8:定稿

When user confirms (selected "Yes, finalize it"):
用户确认后(选择“是,定稿”):

8.1: Cleanup

8.1:清理

Delete all temporary files:
  • Remove
    .claude-design/
    directory entirely
  • Remove temporary route files:
    • app/__design_lab/
      (Next.js App Router)
    • pages/__design_lab.tsx
      (Next.js Pages Router)
    • app/__design_preview/
    • pages/__design_preview.tsx
    • Revert any
      App.tsx
      modifications (Vite)
Safety rules:
  • ONLY delete files inside
    .claude-design/
  • ONLY delete route files that the plugin created
  • NEVER delete user-authored files
  • Verify file paths before deletion
删除所有临时文件:
  • 完全删除
    .claude-design/
    目录
  • 删除临时路由文件:
    • app/__design_lab/
      (Next.js App Router)
    • pages/__design_lab.tsx
      (Next.js Pages Router)
    • app/__design_preview/
    • pages/__design_preview.tsx
    • 还原对
      App.tsx
      的所有修改(Vite)
安全规则:
  • 仅删除
    .claude-design/
    内的文件
  • 仅删除插件创建的路由文件
  • 绝不删除用户创建的文件
  • 删除前验证文件路径

8.2: Generate Implementation Plan

8.2:生成实施计划

Create
DESIGN_PLAN.md
in the project root:
markdown
undefined
在项目根目录创建
DESIGN_PLAN.md
markdown
undefined

Design Implementation Plan: [TargetName]

设计实施计划:[TargetName]

Summary

摘要

  • Scope: [component/page]
  • Target: [file path]
  • Winner variant: [A-E]
  • Key improvements: [from feedback]
  • 范围: [组件/页面]
  • 目标: [文件路径]
  • 获胜变体: [A-E]
  • 核心改进: [来自反馈]

Files to Change

需修改的文件

  • src/components/Example.tsx
    - Main component refactor
  • src/styles/example.css
    - Style updates
  • ... (list all affected files)
  • src/components/Example.tsx
    - 主组件重构
  • src/styles/example.css
    - 样式更新
  • ...(列出所有受影响的文件)

Implementation Steps

实施步骤

  1. [Specific step with code guidance]
  2. [Next step]
  3. ...
  1. [带代码指导的具体步骤]
  2. [下一步]
  3. ...

Component API

组件API

  • Props:
    • prop1: type
      - description
    • ...
  • State:
    • Internal state requirements
  • Events:
    • Callbacks and handlers
  • 属性:
    • prop1: type
      - 描述
    • ...
  • 状态:
    • 内部状态需求
  • 事件:
    • 回调函数和处理程序

Required UI States

必需的UI状态

  • 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
  • 键盘导航正常工作
  • 焦点状态可见
  • 标签和aria-*属性正确
  • 颜色对比度符合WCAG AA标准
  • 已通过屏幕阅读器测试

Testing Checklist

测试检查清单

  • Unit tests for logic
  • Component tests for rendering
  • Visual regression tests (if applicable)
  • E2E smoke test (if applicable)
  • 逻辑单元测试
  • 组件渲染测试
  • 视觉回归测试(若适用)
  • E2E冒烟测试(若适用)

Design Tokens

设计令牌

  • [Any new tokens to add]
  • [Existing tokens to use]

Generated by Design Variations plugin
undefined
  • [需添加的新令牌]
  • [需使用的现有令牌]

由Design Variations插件生成
undefined

8.3: Update Design Memory

8.3:更新Design Memory

Create or update
DESIGN_MEMORY.md
:
If new file:
markdown
undefined
创建或更新
DESIGN_MEMORY.md
若为新文件:
markdown
undefined

Design Memory

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:
- Append new patterns discovered
- Update any conflicting guidance with latest decisions
- Keep file concise and actionable

---
  • 组件结构: [文件组织]
  • 样式方式: [Tailwind类、CSS Modules等]
  • 现有基础组件: [Button、Input、Card等]

由Design Variations插件更新

若更新现有文件:
- 添加新发现的模式
- 用最新决策更新冲突的指导内容
- 保持文件简洁且实用

---

Error Handling

错误处理

Framework Not Detected

未检测到框架

If framework cannot be determined:
  • Ask user: "I couldn't detect your framework. What are you using?"
  • Provide common options: Next.js, Vite, Create React App, Vue, etc.
若无法确定框架:
  • 询问用户:"我无法检测到您使用的框架。您使用的是什么框架?"
  • 提供常见选项:Next.js、Vite、Create React App、Vue等

Dev Server Fails

开发服务器启动失败

If dev server won't start:
  • Check for port conflicts
  • Provide manual instructions
  • Suggest user starts server themselves
若开发服务器无法启动:
  • 检查端口冲突
  • 提供手动说明
  • 建议用户自行启动服务器

Route Integration Fails

路由集成失败

If can't create temporary route:
  • Fall back to creating standalone HTML file
  • Provide instructions for manual preview
若无法创建临时路由:
  • 退而创建独立HTML文件
  • 提供手动预览说明

Cleanup Interrupted

清理中断

If cleanup is interrupted:
  • Log what was deleted vs remaining
  • Provide manual cleanup instructions
  • Never leave partial state without informing user

若清理过程中断:
  • 记录已删除和剩余的文件
  • 提供手动清理说明
  • 若状态不完整,务必告知用户

Configuration Options

配置选项

The plugin supports these optional configurations (via environment or project config):
  • DESIGN_AUTO_IMPLEMENT
    : If
    true
    , implement the plan immediately after confirmation
  • DESIGN_KEEP_LAB
    : If
    true
    , don't delete lab until explicit cleanup command
  • DESIGN_MEMORY_PATH
    : Custom path for Design Memory file

插件支持以下可选配置(通过环境变量或项目配置):
  • DESIGN_AUTO_IMPLEMENT
    :若为
    true
    ,确认后立即实施计划
  • DESIGN_KEEP_LAB
    :若为
    true
    ,直到收到明确清理命令才删除实验室
  • DESIGN_MEMORY_PATH
    :Design Memory文件的自定义路径

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"
  1. 用户:
    /design-variations:design CheckoutSummary
  2. 插件检测到:Next.js App Router、Tailwind、pnpm
  3. 插件发现:无现有Design Memory
  4. 插件提出:访谈问题(5个步骤)
  5. 插件生成:设计简报摘要
  6. 插件创建:
    .claude-design/lab/
    包含5种变体
  7. 插件创建:
    app/__design_lab/page.tsx
  8. 插件启动:
    pnpm dev
  9. 插件输出:"打开http://localhost:3000/__design_lab"
  10. 用户在浏览器中审阅变体
  11. 插件询问:"您选择哪个变体?"
  12. 用户:"变体C,但需要修改X和Y"
  13. 插件优化:更新变体C
  14. 用户:"看起来不错"
  15. 插件创建:最终预览页面
    /__design_preview
  16. 用户:"确认"
  17. 插件:删除所有临时文件
  18. 插件:生成
    DESIGN_PLAN.md
  19. 插件:创建
    DESIGN_MEMORY.md
  20. 插件:"完成!请查看DESIGN_PLAN.md获取实施步骤"