zakariaf/flutter-skills/design-system-structure
Claude Code and agent skill by zakariaf/flutter-skills
- community
Checking that the SKILL.md file is still in the repository.
Structures a Flutter design system as tokens→theme→modifiers→shapes with two-tier tokens (primitives named by measured value, semantic slots named by role) exposed through a ThemeExtension read via an asserting of(context); hand-authors both light and dark ColorScheme instead of ColorScheme.fromSeed, keeps every raw color/hex/Colors./Curves./Duration/BorderRadius/fontSize inside lib/theme/ behind a no-raw-values gate, collapses animation to zero under reduced motion, restores the persisted theme before first paint, bundles fonts (never google_fonts/dynamic_color), and derives each stateful meaning's supporting color last so color is never its sole signal. Use when creating or editing ThemeData/ThemeExtension/ColorScheme, adding or renaming a design token, wiring theme injection or theme-mode persistence, reaching for fromSeed/dynamic_color/google_fonts/FontVariation, structuring a theme/ or DesignSystem/ folder, or reviewing any widget that renders a color, radius, duration, or font.
Install
npx vskill@latest install zakariaf/flutter-skills/design-system-structureSKILL.md
The same SKILL.md was published earlier as zakariaf/flutter-skills/design-system-structure.
design-system-structure
A design system is code that is incapable of holding a stray opinion: every aesthetic value lives in one directory, and every widget reads it back through a named slot. This skill owns how tokens, themes, components, and shapes are structured and consumed — not which colors or radii to pick (that belongs to your design source of truth). Getting the structure right makes a reskin a diff lib/theme/ and turns a stray Color(0xFF…) in feature code into a build failure instead of a style nit.
Read the reference for the task at hand:
references/token-tiers-and-themeextension.md— two-tier token naming, ThemeExtension mechanics, the assertingof(), hand-authoredColorSchemevsfromSeed, honestlerp.references/motion-and-reduced-motion.md— the three animations Material mounts by default, whyNoSplashis not enough, reduced-motion-means-zero,pumpAndSettlebans in tests.references/typography-and-fonts.md— bundling fonts,LicenseRegistry,FontWeightdriveswght, silentFontVariationno-ops, subsetting without instancing, per-script fallback cascades.references/contrast-and-redundant-encoding.md— AA as a unit test, ≥3 grayscale-legible signals per meaning, reading a11y flags fromMediaQuery.
Run scripts/check_raw_values.sh and scripts/check_font_bundling.sh before a PR.
Non-negotiable rules
- No raw aesthetic value outside `lib/theme/
— the gate is the law.** AColor(0x…)/Colors.` (except `transparent`) / `Curves./Duration(milliseconds:|seconds:(exceptDuration.zero) / literalBorderRadius.circular(n)/fontSize: nin feature or shared UI code failsscripts/check_raw_values.sh. A legitimate new need is a **new token slot, never a// ignore`** — one place to diff is the whole point. - Two token tiers; widgets read only the semantic tier. Tier 1 = primitives named by the measured value (
neutral12= OKLCH lightness ×100), never by rank (grey700), appearance (darkGrey), or brand (brandPrimary). Tier 2 = semantic slots named by role (surface,onSurface,hairline,accent). A widget that reaches a Tier-1 primitive has hardcoded one theme. WHY: rank scales have no room to insert and lie in dark mode; appearance names invert catastrophically; brand names die with the brand. - Read tokens through a `ThemeExtension` and an asserting `of(context)`. Never a static
constclass, never anInheritedWidgetside channel.of()asserts on a missing extension — it does not?? fallback. WHY:MaterialAppdrives light/dark switching and correct-by-construction invalidation; a fallback silently ships a theme no test verified, and loud-in-debug beats wrong-in-field. - Hand-author `ColorScheme`; never `ColorScheme.fromSeed` (or `dynamic_color`) for identity.
fromSeed's per-role overrides do not propagate — overridesurfaceandsurfaceContainerHighstays seed-derived. State every role you consume, keep the M3 role names so Material widgets theme themselves, and let unstated roles takeColorScheme's own defaults, not a seed's opinion. WHY: "seed plus a few overrides" means owning the ~9 roles you chose and every seam of the ~40 you didn't. - Layer the system: tokens → theme → modifiers/components → shapes. Author light and dark by hand (dark is never an auto-flip), each passing AA independently, and attach every extension to both
ThemeDatas. Inject the theme exactly once, at the composition root. WHY: theming the app must touch one directory; a palette-only dark theme ships light's ratios into the dark. - `lerp` honestly or snap deliberately; `copyWith` is mandatory. Interpolate colors and doubles; snap non-interpolables (font families,
ShapeBorder) att < 0.5. If your app bans theme animation and you snap everything, leave a comment — a bare step-lerpreads as unfinished and the next reader will "fix" it. WHY: a new field silently forgotten inlerpis the classic design-system rot. - Color is a derived token, computed LAST — never a status's only channel. Color is a pure function of a canonical value object (an enum/small class), resolved through a semantic slot at the end; status is never read from color, and the supporting color is a slot read, not a literal. The never-color-alone floor itself — ≥3 non-color signals (glyph, label, weight/position) per stateful meaning — is owned by
accessibility-as-code; this skill only enforces that the color reinforcing them is a derived slot. WHY: a color not derived from the value object drifts out of sync, and a widget that leans on color alone dies in grayscale. - Reduced motion collapses to zero, not "gentler." Read
MediaQuery.disableAnimationsOf(context)and resolve toDuration.zero/ a cross-fade to the end state — never a shorter duration or a softer curve. Motion is never the only signal for a state change. WHY: a user who asked the OS to stop animations asked for stop. - Restore the persisted theme before first paint. Load the saved theme mode / variant before
runApp, from the same versioned settings the rest of the app uses (not an asyncshared_preferencesread that lands a frame late). An unknown or corrupt stored value falls back explicitly and visibly, never to anullthat leavesof()asserting on a device with no debugger. WHY: a flash of the wrong theme is a sudden luminance change the user did not cause. - Bundle fonts; never `google_fonts` at runtime. Declare fonts in
pubspec.yaml, ship the license text and register it viaLicenseRegistry, and drive weight withFontWeight(which drives thewghtaxis) — not a redundantFontVariation('wght', …). Declare a per-scriptfontFamilyFallbackcascade that ends in a known-good face. WHY:google_fontsships an HTTP code path by default;FontVariation('opsz'|'ital', …)silently no-ops on a font that lacks the axis, so a "working" italic is invisible in review. - Painters snapshot tokens; `paint()` never reads `BuildContext`. Resolve
Theme.of(context).extension<T>()once at the widget layer and pass the values into theCustomPainter/Scenefields. WHY: keepspaint()allocation-free and testable without aMaterialApp; seecustom-canvas-and-gestures. - The reduced-motion flag is read from `MediaQuery` (`disableAnimationsOf`), never app state — it feeds
resolveMotion(this skill's helper, below). Reading the other platform a11y flags (boldTextOf,highContrastOf,textScaler) fromMediaQueryrather than a stale app-state copy is owned byaccessibility-as-code.
The token layering
tokens → theme → modifiers → shapes. Primitives carry values; a ThemeExtension names semantic slots; a ThemeData builder folds slots into Material's ColorScheme and component themes; shape factories live on their own extension so a component asks for a silhouette, not a radius.
Full worked file (primitives, a shapes extension with a cardShape factory, the hand-authored ColorScheme, honest lerp, and one-shot injection): examples/app_theme.dart.
Hand-author ColorScheme, keep the M3 role names
A Material TextField reads surfaceContainerHighest, onSurfaceVariant, outline, and error on its own — name the roles right and it themes with zero per-widget InputDecoration patching that would drift out of sync on the next theme change.
Reduced motion: read the flag, collapse to zero
NoSplash.splashFactory alone is not enough — the pressed highlight fade is a separate InkHighlight, and MaterialApp interpolates ThemeData over kThemeAnimationDuration unless you pass themeAnimationStyle: AnimationStyle.noAnimation. See references/motion-and-reduced-motion.md for all three switches.
Restore the theme before first paint
Persisting the choice but reading it back asynchronously (a bare shared_preferences read) lands a frame late and flashes the wrong theme. state-management-riverpod covers threading the resolved variant through a themeModeProvider; app-startup-and-bootstrap covers the main() ordering.
Redundant encoding: derive color last
The ≥3-non-color-signals floor is owned by accessibility-as-code; the design-system contribution shown here is narrower — the supporting color is derived last from a canonical value object through a semantic slot, never read as the source of state:
Full chip widget rendering all three signals: examples/status_encoding.dart.
Anti-patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/design-system-structure/SKILL.md
Popularity
- Repository stars
- 22
- Repository forks
- 4
- 7-day trend score
- 16
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/zakariaf/flutter-skills/design-system-structure)