EasyPlatform scan-design-system
[Documentation] Scan project and populate/sync docs/project-reference/design-system/README.md with design system overview, app-to-doc mapping, design tokens, and component inventory.
git clone https://github.com/duc01226/EasyPlatform
T=$(mktemp -d) && git clone --depth=1 https://github.com/duc01226/EasyPlatform "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/scan-design-system" ~/.claude/skills/duc01226-easyplatform-scan-design-system && rm -rf "$T"
.claude/skills/scan-design-system/SKILL.md<!-- SYNC:critical-thinking-mindset -->[IMPORTANT] Use
to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ATTENTION ask user whether to skip.TaskCreate
<!-- /SYNC:critical-thinking-mindset --> <!-- SYNC:ai-mistake-prevention -->Critical Thinking Mindset — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act. Anti-hallucination: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
<!-- /SYNC:ai-mistake-prevention -->AI Mistake Prevention — Failure modes to avoid on every task:
- Check downstream references before deleting. Deleting components causes documentation and code staleness cascades. Map all referencing files before removal.
- Verify AI-generated content against actual code. AI hallucinates APIs, class names, and method signatures. Always grep to confirm existence before documenting or referencing.
- Trace full dependency chain after edits. Changing a definition misses downstream variables and consumers derived from it. Always trace the full chain.
- Trace ALL code paths when verifying correctness. Confirming code exists is not confirming it executes. Always trace early exits, error branches, and conditional skips — not just happy path.
- When debugging, ask "whose responsibility?" before fixing. Trace whether bug is in caller (wrong data) or callee (wrong handling). Fix at responsible layer — never patch symptom site.
- Assume existing values are intentional — ask WHY before changing. Before changing any constant, limit, flag, or pattern: read comments, check git blame, examine surrounding code.
- Verify ALL affected outputs, not just the first. Changes touching multiple stacks require verifying EVERY output. One green check is not all green checks.
- Holistic-first debugging — resist nearest-attention trap. When investigating any failure, list EVERY precondition first (config, env vars, DB names, endpoints, DI registrations, data preconditions), then verify each against evidence before forming any code-layer hypothesis.
- Surgical changes — apply the diff test. Bug fix: every changed line must trace directly to the bug. Don't restyle or improve adjacent code. Enhancement task: implement improvements AND announce them explicitly.
- Surface ambiguity before coding — don't pick silently. If request has multiple interpretations, present each with effort estimate and ask. Never assume all-records, file-based, or more complex path.
Prerequisites: MUST ATTENTION READ before executing:
<!-- SYNC:scan-and-update-reference-doc --><!-- /SYNC:scan-and-update-reference-doc --> <!-- SYNC:output-quality-principles -->Scan & Update Reference Doc — Surgical updates only, never full rewrite.
- Read existing doc first — understand current structure and manual annotations
- Detect mode: Placeholder (only headings, no content) → Init mode. Has content → Sync mode.
- Scan codebase for current state (grep/glob for patterns, counts, file paths)
- Diff findings vs doc content — identify stale sections only
- Update ONLY sections where code diverged from doc. Preserve manual annotations.
- Update metadata (date, counts, version) in frontmatter or header
- NEVER rewrite entire doc. NEVER remove sections without evidence they're obsolete.
<!-- /SYNC:output-quality-principles -->Output Quality — Token efficiency without sacrificing quality.
- No inventories/counts — AI can
. Counts go stale instantlygrep | wc -l- No directory trees — AI can
/glob. Use 1-line path conventionsls- No TOCs — AI reads linearly. TOC wastes tokens
- No examples that repeat what rules say — one example only if non-obvious
- Lead with answer, not reasoning. Skip filler words and preamble
- Sacrifice grammar for concision in reports
- Unresolved questions at end, if any
Quick Summary
Goal: Scan project for design system artifacts and populate
docs/project-reference/design-system/README.md with an overview of the design system, app-to-documentation mapping, design token inventory, and component catalog. (content auto-injected by hook — check for [Injected: ...] header before reading)
Workflow:
- Read — Load current target doc, detect init vs sync mode
- Scan — Discover design system structure via parallel sub-agents
- Report — Write findings to external report file
- Generate — Build/update reference doc from report
- Verify — Validate component paths and token files exist
Key Rules:
- Generic — works with any design system approach (custom, Storybook, Figma tokens, etc.)
- Discover design system organization dynamically from file system
- Map relationships between apps and their design documentation
- Every reference must point to real files found in this project
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
Scan Design System
Phase 0: Read & Assess
- Read
docs/project-reference/design-system/README.md - Resolve config-driven paths from
:docs/project-config.json
(e.g.,designSystem.canonicalDoc
) — single source of truth for new codedesign-system-canonical.md
(e.g.,designSystem.tokenFiles
) — drop-in token files["design-tokens.scss","design-tokens.css"]- Never hardcode these names — content varies per project, names come from config.
- Detect mode: init (placeholder, OR canonical/tokens missing on disk) or sync (populated and present)
- If sync: extract existing sections and note what's already well-documented
- Also check for app-specific design docs in the same directory
Phase 1: Plan Scan Strategy
Discover design system locations:
directory and its contentsdocs/project-reference/design-system/- Storybook config (
,.storybook/
)*.stories.ts - Design token files (JSON, CSS, SCSS variables)
- Component library directories (shared components, UI kit)
- Figma token exports or style dictionary config
Use
docs/project-config.json designSystem section if available for:
— where design docs livedocsPath
— which apps have which design docs (per-app inventory)appMappings
— single target/canonical design system filenamecanonicalDoc
— drop-in token files (SCSS/CSS) referenced by canonicaltokenFiles
Resolve canonical doc + token file paths from config. Never hardcode names — they differ per project.
This skill executes 3 parallel sub-agents in Phase 2: (1) Design System Structure, (2) Component Inventory, (3) Token & Component Source Discovery.
Phase 2: Execute Scan (Parallel Sub-Agents)
Launch 3 Explore agents in parallel:
Agent 1: Design System Structure
- Glob for
to map all design docsdocs/project-reference/design-system/** - Find design token files (CSS custom properties, SCSS variables, JSON tokens)
- Discover Storybook stories (
,*.stories.ts
,*.stories.tsx
)*.stories.mdx - Find component library entry points (index files, barrel exports)
- Look for style dictionary or token transformation configs
- Map app-to-design-doc relationships (which app uses which design doc)
- Verify canonical doc at
has expected sections (Foundations / Components / Patterns / Accessibility / Adoption Strategy). Flag missing sections.{docsPath}/{canonicalDoc} - Verify token files at
exist and contain variable declarations ({docsPath}/{tokenFiles[i]}
,--brand-*
, etc.). Flag empty/missing.$brand-*
Agent 2: Component Inventory
- Grep for reusable UI components (shared component directories, exported components)
- Find component categories (layout, forms, feedback, navigation, data display)
- Discover component variants (size, color, state variations)
- Count components per category
- Find icon sets or asset libraries
- Look for accessibility patterns in components (ARIA roles, keyboard support)
- Find documentation for individual components (JSDoc, README, Storybook docs)
Agent 3: Token & Component Source Discovery (init-authoring support)
Scope: discover design tokens and component class prefixes from actual source code so init mode can author canonical doc + token files. Bias toward declarations + frequency, NOT raw literal occurrences — auto-generated junk is strictly worse than placeholder.
Source scope (whitelist, not full repo):
,src/**/styles/**/*.{scss,css}
,src/**/themes/**/*.{scss,css}src/**/tokens/**/*.{scss,css}
,src/**/*.scss
ONLY when path containssrc/**/*.css
,theme
,token
,palette
,design
, orstyle-guidevariables- Exclude
,node_modules
,dist
,.nx
,coverage
, component-local styles*.spec.scss
Discovery rules (declarations + frequency, NOT every literal):
- CSS custom properties (declarations only):
— capture LHS only, dedupe.--[a-zA-Z][a-zA-Z0-9_-]*\s*: - SCSS variable declarations:
— anchor to start-of-line so usages are excluded.^\s*\$[a-zA-Z][a-zA-Z0-9_-]*\s*: - Color values used ≥3 times across whitelist:
- Hex:
#[0-9a-fA-F]{3,8}\b - RGB/RGBA:
rgba?\([^)]+\) - HSL/HSLA:
hsla?\([^)]+\) - Apply frequency filter: drop values appearing <3 times (one-offs ≠ design tokens).
- Hex:
- Spacing scale (declarations only):
— extract numeric values, dedupe and sort.(padding|margin|gap|width|height|inset|top|right|bottom|left)\s*:\s*[\d.]+(px|rem|em) - Typography (declarations only):
— extract RHS values, dedupe.(font-family|font-size|font-weight|line-height|letter-spacing)\s*: - Breakpoints:
— extract widths, dedupe.@media[^{]*\((min|max)-width:\s*[\d.]+(px|em|rem)\) - Z-index (declarations only):
— extract values, dedupe and sort.z-index\s*:\s*[-\d]+ - Elevation/shadow (declarations only):
— extract RHS values, dedupe.(box-shadow|filter\s*:\s*drop-shadow)\s*: - Component prefixes: Use
fromcomponentSystem.selectorPrefixes
if present; else grep BEM-style block selectors (docs/project-config.json
and\.[a-z][a-z0-9-]*__
) and dedupe by block name.\.[a-z][a-z0-9-]*--
Categorise findings: Colors / Typography / Spacing / Breakpoints / Z-Index / Elevation / Component-prefixes / Other. Persist incrementally — append to report after each category, don't batch at end. Quality gate: If a category has <3 unique entries OR >200 entries, log "scope too narrow/broad — manual refinement required" instead of dumping into canonical doc.
Write all findings to:
plans/reports/scan-design-system-{YYMMDD}-{HHMM}-report.md
Phase 3: Analyze & Generate
Read the report. Build these sections:
Target Sections
| Section | Content |
|---|---|
| Design System Overview | High-level description of the design system approach, tools, and organization |
| App Documentation Map | Table: App name, Design doc path, Token source, Component library |
| Design Tokens | Token categories (color, typography, spacing, elevation), file locations, naming convention |
| Component Inventory | Table: Component name, Category, Variants, Path, Has docs? |
| Icon & Asset Library | Icon set source, asset directory paths, usage patterns |
| Storybook | Storybook setup (if exists), story organization, how to add new stories |
| Usage Guidelines | How to consume tokens and components in application code |
Content Rules
- Use tables for component inventory and token listings
- Include actual token values (colors, spacing scale) where practical
- Show component usage examples from real application code
- Map each app to its specific design documentation file
Authoring (init mode only)
When init mode detected (canonical doc missing or placeholder per Phase 0 detection):
- Author
from Agent 3 findings:{docsPath}/{canonicalDoc}- Prepend regen marker: First line MUST be
(substitute today's ISO date). Markdown renderers ignore HTML comments.<!-- Generated by /scan-design-system on YYYY-MM-DD; refine sections manually --> - Sections (in order):
- Foundations (intro, design philosophy)
- Tokens (color palette, typography scale, spacing scale, breakpoints, z-index, elevation, radius)
- Components (per-component class prefix + semantic role)
- Patterns (composition examples)
- Accessibility (WCAG 2.1 AA notes — color contrast, focus, motion)
- Adoption Strategy (how to consume tokens in app code)
- Prepend regen marker: First line MUST be
- Author each
by grouping discovered declarations by category and emitting valid SCSS/CSS:{docsPath}/{tokenFiles[i]}- First action: REMOVE the
sentinel (PLACEHOLDER_MARKER_SCSS
) from the placeholder file BEFORE writing real tokens. If sentinel survives,/* @claude:placeholder — do not commit */
placeholder advisory loops indefinitely.session-init-docs.cjs
file: SCSS variable block per category, then CSS custom property mirrors inside.scss:root {}
file: CSS custom properties only inside.css:root {}- Categories emitted: Colors, Typography, Spacing, Breakpoints, Z-Index, Elevation/Shadow.
- First action: REMOVE the
- Preserve manual content in sync mode — if doc/token file already populated (not placeholder), DO NOT overwrite. Only add missing token entries.
- Token category scope (full): colors (≥3-occurrence filter), CSS custom properties (
declarations), SCSS variables (--*
declarations), spacing scale (declarations), typography (declarations), breakpoints ($*
), z-index (declarations), elevation (@media min/max-width
/box-shadow
).filter: drop-shadow
Phase 4: Write & Verify
- Write updated doc with
at top<!-- Last scanned: YYYY-MM-DD --> - Verify: 3 design doc paths exist on filesystem
- Verify: component paths in inventory match actual files
- Verify config-driven paths exist:
and every{docsPath}/{canonicalDoc}
.{docsPath}/{tokenFiles[i]}- If init mode AND missing/placeholder: invoke Phase 3 Authoring step to generate from Agent 3 findings.
- If sync mode AND missing: log gap only (preserve manual content; flag for user re-authoring decision).
- Report: sections updated, component count, token categories documented, canonical + token presence.
Closing Reminders
- IMPORTANT MUST ATTENTION break work into small todo tasks using
BEFORE startingTaskCreate - IMPORTANT MUST ATTENTION search codebase for 3+ similar patterns before creating new code
- IMPORTANT MUST ATTENTION cite
evidence for every claim (confidence >80% to act)file:line - IMPORTANT MUST ATTENTION add a final review todo task to verify work quality <!-- SYNC:scan-and-update-reference-doc:reminder -->
- IMPORTANT MUST ATTENTION read existing doc first, scan codebase, diff, surgical update only. Never rewrite entire doc. <!-- /SYNC:scan-and-update-reference-doc:reminder --> <!-- SYNC:output-quality-principles:reminder -->
- IMPORTANT MUST ATTENTION follow output quality rules: no counts/trees/TOCs, rules > descriptions, 1 example per pattern, primacy-recency anchoring. <!-- /SYNC:output-quality-principles:reminder --> <!-- SYNC:critical-thinking-mindset:reminder -->
- MUST ATTENTION apply critical thinking — every claim needs traced proof, confidence >80% to act. Anti-hallucination: never present guess as fact. <!-- /SYNC:critical-thinking-mindset:reminder --> <!-- SYNC:ai-mistake-prevention:reminder -->
- MUST ATTENTION apply AI mistake prevention — holistic-first debugging, fix at responsible layer, surface ambiguity before coding, re-read files after compaction. <!-- /SYNC:ai-mistake-prevention:reminder -->