Design engineering

From softspark/ai-toolkit · View interactive version

Design engineering is an AI agent skill from the GitHub repository softspark/ai-toolkit. UI craftsmanship: animation rules, easing, micro-interactions, state polish. Triggers: animation, transition, ease-out, motion, micro-interaction, hover, loading state, UI polish.

How to use this skill

Skill file

Design Engineering Skill

Based on Emil Kowalski's design engineering philosophy — UI polish, component craftsmanship, and the compound value of invisible details.

Core Principles

Anti-Slop Visual & Structural Checklist

Defaults that signal machine-generated UI ("AI slop"). Each is a falsifiable rule to uphold:

Pre-Emit Self-Critique (Six Axes)

Before marking any UI output complete, score it 1–5 on these six axes (score <3 on any axis triggers a revision pass):

| # | Axis | Assessment |

|---|---|---|

| P | Philosophy | Clear position and intent ("why"), not just arbitrary decoration |

| H | Hierarchy | Clear primary / secondary / tertiary weight distinguishable in 2 seconds |

| E | Execution | Exact rule weights, contrast ratios, focus rings, zero layout shifts |

| S | Specificity | Tailored specifically to this brief, not a generic interchangeable template |

| R | Restraint | Removed anything unearned (decorative bloat, redundant cards, excess padding) |

| V | Variety | Structurally distinct from previous layouts in the project (not just a color swap) |

The 8 Interactive States Discipline

Every interactive element (button, input, select, card, tab, switch) must explicitly handle all 8 states in code. Styling only default + hover is an immediate defect:

| State | Trigger | Required Treatment |

|---|---|---|

| 1. Default | At rest | Clean base styling, defined token bindings |

| 2. Hover | Pointer over (@media (hover: hover)) | Subtle background shift (4–6%) or 1px translate, no layout jump |

| 3. Focus | Keyboard navigation | Visible :focus-visible ring (2px solid, 1–2px offset), instant appearance |

| 4. Active | Pressed | Pressed-in feel: slight darken, transform: translateY(1px) or scale(0.98) |

| 5. Disabled | Inactive (disabled, aria-disabled) | 3 channels: opacity: 0.55, cursor: not-allowed, muted token color |

| 6. Loading | Async in-flight (data-state="loading") | Inline spinner replacing icon/badge, label preserved, submit disabled |

| 7. Error | Validation failure (aria-invalid="true") | Distinct error token border/message, helper text replaced, error icon |

| 8. Success | Operation completed (data-state="success") | Quiet confirmation: subtle green/accent indicator or checkmark, auto-dismiss |

Input Fields & Zero Layout Shift

Input fields, textareas, and selects are where almost-right UIs break:

Responsive Non-Negotiables

Verify every layout at 320px, 375px, 414px, and 768px:

Locked Tokens Discipline

Minimum-Scale Floors

Accessibility-grounded hard thresholds. Going below these is a defect, not a style choice:

| Context | Floor | Basis |

|---|---|---|

| Slide / presentation body text | ~24px | Readable from the back of a room |

| Print body text | ~12pt | Legible at arm's length on paper |

| Mobile touch targets | 44px × 44px | Apple HIG minimum tappable size |

Treat these as the lower bound, not the target. Captions and footnotes may approach the floor; primary content should sit comfortably above it.

Context-First & Pre-Flight Discipline

High-fidelity work MUST be rooted in real context before any pixels are produced:

Question-Budget Gate

Calibrate questions to how bounded the ask is, then proceed:

Explore Many Variations

For exploratory or open work, produce 3+ atomic variations across distinct axes, never three tweaks of one idea:

Match Existing Vocabulary

When editing a live UI, conform to it instead of imposing a new style:

No-Filler Content

Animation Decision Framework

Frequency determines approach

| Usage Pattern | Strategy |

|---|---|

| 100+ daily | No animation |

| Tens daily | Drastically reduce |

| Occasional | Standard animation |

| Rare/first-time | Add delight |

Never animate keyboard-initiated actions — they repeat hundreds of times daily, making animation feel sluggish.

Purpose validation

Every animation requires justification: spatial consistency, state indication, explanation, user feedback, or preventing jarring transitions. "It looks cool" alone disqualifies frequent interactions.

Easing rules

| Direction | Easing | Why |

|---|---|---|

| Entering elements | ease-out | Immediate feedback |

| On-screen movement | ease-in-out | Natural acceleration |

| Hover/color changes | ease | Smooth transition |

| Constant motion | linear | No acceleration |

Critical: Abandon default CSS easings. Use custom curves:

/* Punchy entrance */
transition-timing-function: cubic-bezier(0.23, 1, 0.32, 1);

Never use ease-in — it delays initial movement exactly when attention peaks, making interfaces feel sluggish.

Duration guidelines

| Element | Timing |

|---|---|

| Button press | 100-160ms |

| Tooltips, small popovers | 125-200ms |

| Dropdowns, selects | 150-250ms |

| Modals, drawers | 200-500ms |

UI animations should stay under 300ms. Speed perception matters as much as actual speed.

Component Patterns

Buttons must respond

button:active {
  transform: scale(0.97);
}

Tactile feedback confirming interface responsiveness.

Never scale from zero

/* Bad */
.enter { transform: scale(0); opacity: 0; }

/* Good — natural entrance */
.enter { transform: scale(0.95); opacity: 0; }

Real-world objects don't vanish and reappear. Start from scale(0.95).

Popovers scale from triggers

.popover {
  transform-origin: var(--radix-popover-content-transform-origin);
}

Exception: modals keep centered origin (viewport-anchored, not trigger-anchored).

Tooltip optimization

Initial tooltip includes delay; subsequent hovers skip both delay and animation via [data-instant] attribute — perceived speed without defeating accidental activation prevention.

Advanced Animation Techniques

For advanced transform mastery, 3D orbits, and clip-path animation recipes (tabs, hold-to-delete, image reveals, sliders), see reference/animation-recipes.md.

Performance Rules

GPU acceleration

Only animate transform and opacity — these skip layout and paint. Animating padding, margin, height, width triggers full rendering pipeline.

CSS variables caveat

Changing parent CSS variables recalculates styles on all children. Update transform directly on elements instead.

Framer Motion gotcha

Shorthand properties (x, y, scale) use main-thread requestAnimationFrame, not GPU:

// Bad — main thread
<motion.div animate={{ x: 100 }} />

// Good — GPU accelerated
<motion.div animate={{ transform: "translateX(100px)" }} />

CSS beats JavaScript

CSS animations run off-thread and remain smooth during page loads. Framer Motion drops frames when browser is busy. Use CSS for predetermined animations; JavaScript for dynamic, interruptible ones.

Accessibility

Reduced motion

Keep opacity and color transitions (aid comprehension). Remove movement and position animations:

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

Touch hover protection

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-2px);
  }
}

Touch triggers false hover positives — always gate hover animations.

Building Loved Components

For component craftsmanship principles (developer experience, defaults, edge cases, asymmetric timing), see reference/component-craft.md.

Review Checklist

| Issue | Resolution |

|---|---|

| transition: all | Specify properties: transition: transform 200ms ease-out |

| scale(0) entries | Start scale(0.95) with opacity: 0 |

| ease-in on UI | Switch to ease-out or custom curve |

| Popover transform-origin: center | Use trigger-aware CSS variable |

| Animation on keyboard actions | Remove entirely |

| Duration > 300ms UI | Reduce to 150-250ms |

| Hover without media query | Add @media (hover: hover) and (pointer: fine) |

| Keyframes on rapid triggers | Use CSS transitions |

| Framer x/y under load | Use transform: "translateX()" |

| Identical enter/exit speed | Make exit faster (e.g., 2s enter, 200ms exit) |

| Simultaneous element appearance | Stagger 30-80ms between items |

Two-Stage Verification Handoff

Visual work ships through two passes, mirroring the toolkit's verification-before-completion and subagent two-stage review ethos:

  1. Cheap self-check. Load the rendered result yourself, eyeball it, and fix the obvious breaks (broken layout, wrong token, console errors) before handing off. Never claim done on output you have not opened.
  2. Independent verifier pass. A separate reviewer (or fresh subagent) does the deeper check — visual fidelity against source, layout under different widths, console clean. On pass it stays silent; it surfaces ONLY on failure, with the specific defect.

Anti-Patterns

Rules

Gotchas

For compositor edge cases, Framer Motion GPU optimizations, and reduced-motion gotchas, see reference/animation-recipes.md.

When NOT to Load

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.