AgentSkillsCN

frontend-design

打造独具特色、符合生产标准的前端界面。既可用于设计文档的引导式开发流程,也可作为UI任务实施的专业顾问。

SKILL.md
--- frontmatter
name: frontend-design
description: Create distinctive, production-grade frontend interfaces. Use in bootstrap pipeline for design docs, or as specialist for UI task implementation.

Frontend Design

Overview

This skill operates in two modes:

ModeTriggerPurpose
Docs Modebootstrap skill invokes after architectureGenerate Full Suite design documents
Implementation Modeexecuting-plans detects specialist: frontend-designExecute UI-related tasks

Announce at start: "I'm using the frontend-design skill to [generate design documentation / implement UI]."


DOCS MODE

Trigger

Invoked by bootstrap skill after architecture completes.

Input Gathering

From Existing Docs (read automatically)

SourceExtract
docs/inception/PROJECT_CHARTER.mdProject scope, objectives, constraints
docs/inception/STAKEHOLDER_MAP.mdTarget audience, decision makers
docs/vision/PRODUCT_VISION.mdProduct vision, goals
docs/vision/TARGET_PERSONAS.mdUser profiles, needs, behaviors
docs/vision/VALUE_PROPOSITION.mdUnique selling points, differentiation

From User (minimal questions)

Ask only these three questions:

  1. "Share reference websites or screenshots you want to draw inspiration from"

    • Accept URLs or paths to screenshots
    • Drop images in docs/design/references/
  2. "Any brand assets that already exist?"

    • Logos, colors, fonts, brand guidelines
    • Link to existing assets or describe
  3. "Target platforms?"

    • Web, Mobile, Desktop, All
    • Responsive requirements

Autonomous Research

After gathering inputs:

  1. WebSearch for current design trends in the project's domain
  2. WebFetch reference URLs provided by user
  3. Read screenshots from docs/design/references/
  4. Analyze and synthesize into opinionated design decisions

Key principle: Make autonomous, opinionated decisions based on research and trends. Don't ask endless questions.

Output: Full Suite Documents

Create folder structure:

bash
mkdir -p docs/design/references
touch docs/design/references/.gitkeep

Generate seven documents:

code
docs/design/
├── STYLE_GUIDE.md
├── UI_DESIGN_SYSTEM.md
├── UX_PRINCIPLES.md
├── REFERENCES.md
├── COMPONENT_SPEC.md
├── ANIMATION_GUIDE.md
├── RESPONSIVE_STRATEGY.md
└── references/
    └── .gitkeep

STYLE_GUIDE.md Template

markdown
# Style Guide: {Project Name}

## Brand Identity

### Color Palette

#### Primary Colors
| Name | Hex | RGB | Usage |
|------|-----|-----|-------|
| {name} | #{hex} | rgb(r,g,b) | {when to use} |

#### Secondary Colors
| Name | Hex | RGB | Usage |
|------|-----|-----|-------|
| {name} | #{hex} | rgb(r,g,b) | {when to use} |

#### Semantic Colors
| Name | Hex | Usage |
|------|-----|-------|
| Success | #{hex} | Positive actions, confirmations |
| Warning | #{hex} | Caution states |
| Error | #{hex} | Errors, destructive actions |
| Info | #{hex} | Informational messages |

### CSS Variables

```css
:root {
  /* Primary */
  --color-primary: #{hex};
  --color-primary-hover: #{hex};
  --color-primary-active: #{hex};

  /* Secondary */
  --color-secondary: #{hex};

  /* Neutrals */
  --color-background: #{hex};
  --color-surface: #{hex};
  --color-text: #{hex};
  --color-text-muted: #{hex};

  /* Semantic */
  --color-success: #{hex};
  --color-warning: #{hex};
  --color-error: #{hex};
  --color-info: #{hex};
}

Typography

Font Families

RoleFontWeightFallback
Display{Font Name}700{fallback stack}
Heading{Font Name}600{fallback stack}
Body{Font Name}400-500{fallback stack}
Mono{Font Name}400{fallback stack}

Font Import

css
@import url('https://fonts.googleapis.com/css2?family={Font}:wght@400;500;600;700&display=swap');

Type Scale

LevelSizeWeightLine HeightUsage
Display3rem7001.1Hero headlines
H12.25rem6001.2Page titles
H21.5rem6001.3Section headers
H31.25rem5001.4Subsections
Body1rem4001.5Paragraph text
Small0.875rem4001.4Captions, labels

Spacing

Scale

TokenValueUsage
space-xs0.25remTight gaps
space-sm0.5remComponent padding
space-md1remDefault spacing
space-lg1.5remSection gaps
space-xl2remMajor sections
space-2xl3remPage-level

CSS Variables

css
:root {
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
}

Border Radius

TokenValueUsage
radius-sm0.25remButtons, inputs
radius-md0.5remCards, modals
radius-lg1remLarge containers
radius-full9999pxPills, avatars

Shadows

LevelCSSUsage
sm0 1px 2px rgba(0,0,0,0.05)Subtle lift
md0 4px 6px rgba(0,0,0,0.1)Cards
lg0 10px 15px rgba(0,0,0,0.1)Dropdowns
xl0 20px 25px rgba(0,0,0,0.15)Modals

Iconography

LibraryUsageLink
{Icon Library}Primary icons{url}

Icon Sizes

SizePixelsUsage
sm16pxInline, buttons
md20pxDefault
lg24pxEmphasis
xl32pxFeatures

Created: {YYYY-MM-DD} | Version: 1.0

code

### UI_DESIGN_SYSTEM.md Template

```markdown
# UI Design System: {Project Name}

## Component Catalog

### Buttons

#### Variants
| Variant | Usage | Example |
|---------|-------|---------|
| Primary | Main actions | Save, Submit |
| Secondary | Alternative actions | Cancel, Back |
| Ghost | Subtle actions | Learn more |
| Destructive | Dangerous actions | Delete |

#### States
- Default, Hover, Active, Focus, Disabled, Loading

#### Sizes
- Small (32px), Medium (40px), Large (48px)

### Form Inputs

#### Text Input
- Label above, placeholder hint, helper text below
- Error state with red border and message
- Focus ring with primary color

#### Select / Dropdown
- Custom styled, accessible
- Search for long lists

#### Checkbox / Radio
- Custom styled, clear hit area
- Group labels for related options

### Cards

#### Standard Card
- Surface background, shadow-md
- Padding: space-lg
- Radius: radius-md

#### Interactive Card
- Hover state with shadow-lg transition
- Optional click action

### Modals

- Centered, backdrop blur
- Max-width: 500px (sm), 700px (md), 900px (lg)
- Close button top-right
- Focus trap

### Navigation

#### Top Nav
- Logo left, nav items center/right
- Sticky on scroll
- Mobile: hamburger menu

#### Sidebar
- Collapsible
- Active state indicator
- Icons + labels

### Data Display

#### Tables
- Sticky header
- Zebra stripes optional
- Sortable columns
- Responsive: horizontal scroll or card view

#### Lists
- Clear item separation
- Icon/avatar left, actions right

## Layout Patterns

### Container Widths
| Size | Max Width | Usage |
|------|-----------|-------|
| sm | 640px | Narrow content |
| md | 768px | Default |
| lg | 1024px | Wide content |
| xl | 1280px | Full layouts |

### Grid System
- 12-column grid
- Gap: space-md (desktop), space-sm (mobile)

---
_Created: {YYYY-MM-DD}_ | _Version: 1.0_

UX_PRINCIPLES.md Template

markdown
# UX Principles: {Project Name}

## Core Principles

### 1. {Principle Name}
{Description of principle and why it matters}

**Do:** {Positive example}
**Don't:** {Anti-pattern}

### 2. {Principle Name}
{Description}

## Interaction Patterns

### Feedback

| Action | Feedback | Timing |
|--------|----------|--------|
| Button click | Visual press state | Immediate |
| Form submit | Loading → Success/Error | During operation |
| Data load | Skeleton → Content | While loading |

### Error Handling

| Error Type | Display | Action |
|------------|---------|--------|
| Validation | Inline below field | Immediate |
| Server | Toast notification | After response |
| Critical | Full-page message | Blocking |

### Loading States

| Context | Pattern |
|---------|---------|
| Initial page | Full skeleton |
| Data refresh | Subtle spinner + stale data |
| Button action | Spinner inside button |

## Accessibility (WCAG 2.1 AA)

### Color Contrast
- Text: 4.5:1 minimum
- Large text: 3:1 minimum
- UI components: 3:1 minimum

### Keyboard Navigation
- All interactive elements focusable
- Visible focus indicators
- Logical tab order
- Escape closes modals

### Screen Readers
- Semantic HTML
- ARIA labels for icons/images
- Live regions for dynamic content

## User Flows

### {Flow Name}
```mermaid
flowchart LR
  A[Start] --> B[Step 1]
  B --> C{Decision}
  C -->|Yes| D[Path A]
  C -->|No| E[Path B]

Created: {YYYY-MM-DD} | Version: 1.0

code

### REFERENCES.md Template

```markdown
# Design References: {Project Name}

## Inspiration Sources

### Websites

| URL | What to Take | Notes |
|-----|--------------|-------|
| {url} | {specific elements} | {notes} |

### Screenshots

| File | Source | Inspiration |
|------|--------|-------------|
| `references/{filename}` | {where from} | {what we like} |

### Mood Board

{Description of overall aesthetic direction}

## Design Decisions Log

| Decision | Rationale | Date |
|----------|-----------|------|
| {decision} | {why} | {date} |

---
_Created: {YYYY-MM-DD}_ | _Version: 1.0_

COMPONENT_SPEC.md Template

markdown
# Component Specifications: {Project Name}

## Component: {ComponentName}

### Purpose
{What this component does}

### Props / API

| Prop | Type | Default | Required | Description |
|------|------|---------|----------|-------------|
| {prop} | {type} | {default} | {yes/no} | {description} |

### Variants

| Variant | Description |
|---------|-------------|
| {variant} | {when to use} |

### States

| State | Visual Change |
|-------|---------------|
| default | {description} |
| hover | {description} |
| active | {description} |
| disabled | {description} |

### Slots / Children

| Slot | Purpose |
|------|---------|
| {slot} | {what goes here} |

### Usage Example

```tsx
<ComponentName
  prop="value"
  variant="primary"
/>

Accessibility

  • Role: {role}
  • Keyboard: {interactions}
  • ARIA: {labels}

Created: {YYYY-MM-DD} | Version: 1.0

code

### ANIMATION_GUIDE.md Template

```markdown
# Animation Guide: {Project Name}

## Motion Principles

### 1. Purposeful
Every animation should serve a purpose: guide attention, provide feedback, or establish spatial relationships.

### 2. Quick
Animations should feel snappy. Most under 300ms.

### 3. Natural
Use easing curves that feel organic.

## Timing

| Duration | Usage |
|----------|-------|
| 100ms | Micro-interactions (hover, toggle) |
| 200ms | Standard transitions |
| 300ms | Complex transitions |
| 500ms+ | Emphasis, page transitions |

## Easing Curves

| Name | CSS | Usage |
|------|-----|-------|
| ease-out | cubic-bezier(0, 0, 0.2, 1) | Enter animations |
| ease-in | cubic-bezier(0.4, 0, 1, 1) | Exit animations |
| ease-in-out | cubic-bezier(0.4, 0, 0.2, 1) | Move/resize |
| spring | {custom} | Playful bounce |

### CSS Variables

```css
:root {
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

Page Transitions

Enter

  • Fade in + slide up (20px)
  • Stagger children by 50ms

Exit

  • Fade out
  • Duration: 150ms

Component Animations

Button

  • Hover: scale(1.02), shadow increase
  • Active: scale(0.98)
  • Duration: 100ms

Modal

  • Enter: backdrop fade 200ms, modal scale from 0.95 + fade 300ms
  • Exit: reverse, faster (200ms)

Toast

  • Enter: slide in from edge + fade
  • Exit: slide out + fade

Skeleton

  • Shimmer animation: left-to-right gradient pulse
  • Duration: 1.5s, infinite

Micro-interactions

ElementTriggerAnimation
ToggleClickSwitch slides, background color transitions
CheckboxCheckScale pop (1.0 → 1.1 → 1.0) + checkmark draw
Like buttonClickHeart scale + particle burst

Reduced Motion

css
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

Created: {YYYY-MM-DD} | Version: 1.0

code

### RESPONSIVE_STRATEGY.md Template

```markdown
# Responsive Strategy: {Project Name}

## Approach

**Mobile-first** / **Desktop-first** (choose one)

{Rationale for chosen approach}

## Breakpoints

| Name | Width | Target |
|------|-------|--------|
| sm | 640px | Large phones |
| md | 768px | Tablets |
| lg | 1024px | Laptops |
| xl | 1280px | Desktops |
| 2xl | 1536px | Large screens |

### CSS Variables

```css
/* Tailwind-compatible */
--screen-sm: 640px;
--screen-md: 768px;
--screen-lg: 1024px;
--screen-xl: 1280px;
--screen-2xl: 1536px;

Media Queries

css
/* Mobile-first */
@media (min-width: 640px) { /* sm */ }
@media (min-width: 768px) { /* md */ }
@media (min-width: 1024px) { /* lg */ }
@media (min-width: 1280px) { /* xl */ }

/* Desktop-first */
@media (max-width: 1279px) { /* below xl */ }
@media (max-width: 1023px) { /* below lg */ }
@media (max-width: 767px) { /* below md */ }
@media (max-width: 639px) { /* below sm */ }

Layout Adaptations

Navigation

BreakpointLayout
< mdHamburger menu, drawer
>= mdFull horizontal nav

Grid

BreakpointColumns
< sm1 column
sm-md2 columns
md-lg3 columns
>= lg4+ columns

Typography

BreakpointBase Size
< md16px
>= md16px
>= xl18px

Spacing

BreakpointScale Factor
< md0.75x
>= md1x
>= xl1.25x

Component Behavior

Cards

  • Mobile: Full width, stacked
  • Tablet: 2-column grid
  • Desktop: 3-4 column grid

Tables

  • Mobile: Card view or horizontal scroll
  • Desktop: Full table

Forms

  • Mobile: Single column, full-width inputs
  • Desktop: Multi-column where appropriate

Modals

  • Mobile: Full screen (drawer)
  • Desktop: Centered overlay

Touch Targets

  • Minimum: 44x44px (iOS), 48x48px (Android)
  • Spacing between targets: 8px minimum

Created: {YYYY-MM-DD} | Version: 1.0

code

---

# IMPLEMENTATION MODE

## Trigger

`executing-plans` skill reads TASK.md and finds `specialist: frontend-design`

## Process

### Step 1: Load Design Context

Read design docs as constraints:

docs/design/STYLE_GUIDE.md → Colors, typography, spacing docs/design/UI_DESIGN_SYSTEM.md → Component patterns docs/design/ANIMATION_GUIDE.md → Motion principles docs/design/RESPONSIVE_STRATEGY.md → Breakpoints, adaptations

code

Extract CSS variables, component patterns, and design tokens.

### Step 2: Understand the Task

Read TASK.md for:
- Objective
- Acceptance criteria
- Technical context
- Files to create/modify

### Step 3: Design Thinking

Before coding, establish:

| Aspect | Question |
|--------|----------|
| **Purpose** | What problem does this UI solve? |
| **Tone** | What emotion should it evoke? (within design system) |
| **Constraints** | Technical requirements, accessibility |
| **Differentiation** | What makes this memorable? |

### Step 4: Implement

Create production-grade code that:

- Uses design tokens from STYLE_GUIDE.md (colors, fonts, spacing)
- Follows component patterns from UI_DESIGN_SYSTEM.md
- Applies animations from ANIMATION_GUIDE.md
- Respects breakpoints from RESPONSIVE_STRATEGY.md
- Is visually striking while staying within design system

### Step 5: Verify

| Check | Action |
|-------|--------|
| Design tokens | Verify CSS variables match STYLE_GUIDE |
| Accessibility | Check contrast, keyboard nav, ARIA |
| Responsiveness | Test all breakpoints |
| Animation | Verify reduced motion support |

## Frontend Aesthetics Guidelines

Even within design system constraints, apply these principles:

- **Typography**: Use the defined fonts with intention. Create hierarchy.
- **Color**: Use defined palette boldly. Don't be timid with the design system.
- **Motion**: Apply animations purposefully per ANIMATION_GUIDE.
- **Composition**: Create visual interest within the grid system.
- **Details**: Shadows, borders, spacing - precision matters.

**NEVER** produce generic output. The design system provides constraints, not excuses for mediocrity.

---

## Common Mistakes

| Mistake | Fix |
|---------|-----|
| Ignoring design docs in implementation mode | Always read STYLE_GUIDE first |
| Asking too many questions in docs mode | Just three questions, then research |
| Generic output | Make bold choices within constraints |
| Skipping references folder | Always create it for screenshots |
| Not using CSS variables | Extract and use tokens from STYLE_GUIDE |

## Remember

**Docs Mode:**
- Read inception + vision docs first
- Ask only three questions
- Research trends autonomously
- Generate all seven documents + references folder

**Implementation Mode:**
- Load design docs as constraints
- Apply design system strictly
- Still create memorable, distinctive UI
- Verify against design tokens