Claude Cursor GitHub Copilot Skill

css-architecture-design-system-review

Review CSS for specificity and cascade-layer discipline, design-token (custom-property) conformance, and responsive strategy correctness (container queries vs. media queries), catching specificity wars, hardcoded-value token drift, and non-reflowing layouts that fail WCAG 1.4.10/

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download vincentchuwaichow-vanguard-frontier-agentic-skills_frontend_css-architecture-design-system-review-febe32a.zip · 12 KB
Part of vincentchuwaichow/vanguard-frontier-agentic — 293 skills

Install

skills CLI npx skills add https://github.com/VincentChuWaiChow/vanguard-frontier-agentic/tree/master/skills/frontend/css-architecture-design-system-review
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install vincentchuwaichow-vanguard-frontier-agentic@llmmart
Git git clone https://github.com/VincentChuWaiChow/vanguard-frontier-agentic.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole vincentchuwaichow/vanguard-frontier-agentic collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

CSS Architecture & Design System Review

Purpose

CSS at scale degrades through two silent mechanisms: specificity creep (engineers reaching for !important or ID selectors to win cascade fights instead of fixing the underlying layer structure) and design-token drift (hardcoded values reappearing next to a token system, diverging visual output over time). Neither shows up as a compile error or a failing test — they show up eighteen months later as an unmaintainable stylesheet nobody wants to touch. This skill catches both at review time, plus the responsive-strategy and WCAG visual-presentation failures that are CSS's specific accessibility responsibility.

When to use

Use this skill when the user asks to:

  • review a CSS/component-styling diff for specificity, cascade, or maintainability issues,
  • audit a codebase's design-token (CSS custom-property) conformance,
  • decide between container queries and media queries for a responsive pattern,
  • establish or enforce a cascade-layer strategy (@layer reset, base, tokens, components, utilities, overrides),
  • check layout resilience against WCAG 2.2 reflow (1.4.10) and resize-text (1.4.4) criteria.

Do not use this skill for:

  • JavaScript/framework component architecture — use the matching framework-specific review skill instead,
  • live visual-regression testing or contrast-ratio measurement — that requires a runtime tool, not static review,
  • choosing a CSS methodology from scratch with no existing code — that is a greenfield design conversation, not a review.

Context7 Documentation Protocol

  • Resolve the MDN Web Docs library ID with resolve-library-id (matched result: /mdn/content) before citing any cascade-layer, container-query, or custom-property specificity claim.
  • Before asserting cascade-layer precedence, !important interaction, or container-query browser-support behavior, call query-docs against /mdn/content and cite the section — do not assert from memory. Cascade-layer !important precedence is inverted relative to normal-declaration precedence and is easy to misstate without checking.
  • If Context7 is unavailable, fall back to the official_docs URLs in this skill's metadata.json and label the claim documentation-based, unverified against current release.
  • Never assume a browser-support baseline (e.g., "container queries are safe everywhere now") without checking current docs; treat support claims as version/date-sensitive, not fixed facts.

Lean operating rules

  • Never approve new !important without a documented cascade-layer justification — it is a symptom that the layer/selector structure should be fixed, not a valid quick fix. Note: !important precedence is inverted across layers (earlier-declared layers win for important declarations), so verify actual winning behavior against the declared @layer order rather than assuming a simple override.
  • Never approve new ID-selector styling for components; treat it as a specificity-escalation risk that will require !important or worse to override later.
  • In any codebase with an established design-token system, flag hardcoded color/spacing/typography values and name the nearest token substitute — do not silently allow token drift. Distinguish token tiers (primitive → semantic → component) when recommending a substitute; do not point a component-level override at a raw primitive if a semantic token exists.
  • Do not bikeshed methodology (BEM vs. utility-first vs. CSS Modules vs. cascade layers) when a convention is already established; enforce consistency with what exists over personal preference.
  • Query current MDN/W3C docs for @layer/@container support and semantics before ruling — container queries only reached broad Baseline status in 2023 and cascade-layer support nuances (especially !important interaction) vary; never assert current support from memory.
  • Distinguish container queries (component depends on its container's size) from media queries (component depends on the viewport) — recommending the wrong one for the actual dependency is a correctness bug, not a style preference. A component intended for reuse across differently-sized containers (sidebar, main content, modal) needs a container query; a page-level layout shift needs a media query.
  • Never treat CSS as an access-control boundary; display:none/visibility:hidden hiding an affordance is not a substitute for server-side authorization. Flag this as a HIGH-severity finding, not a style note, whenever hidden-but-present markup carries privileged data or actions.
  • Flag anything needing live visual-regression or contrast-ratio measurement as a residual risk requiring live-runtime verification, not asserted from static analysis alone.
  • Flag attribute-selector-plus-background-image patterns (e.g. input[value^="a"] { background: url(...) }) as a potential CSS-based data-exfiltration vector — they can leak user-controlled attribute values via network requests.
  • Flag third-party @import rules with no accompanying Subresource Integrity or CSP style-src consideration as a supply-chain risk, not a performance nitpick.
  • Never execute, build, or run application code, and never fetch live pages to "see how it renders" without the user's explicit ask; this is a static-review skill augmented only by documentation lookups (Read/Grep/Glob plus scoped git diff and WebFetch for docs/spec grounding).

References

Load these only when needed:

  • Cascade layer strategy — use when establishing or auditing a @layer order for a codebase, or resolving a specificity conflict between two legitimate rules.
  • Design token conformance patterns — use when auditing hardcoded-value drift against an existing custom-property token system, including token-tier (primitive vs. semantic vs. component) conventions.
  • Responsive strategy decision guide — use when deciding container query vs. media query, or auditing reflow/resize-text compliance at 400%/200% zoom.

Response minimum

Return, at minimum:

  • the specificity/cascade verdict per flagged selector, with its computed specificity value when relevant,
  • a token-conformance report distinguishing token-referenced values from hardcoded ones,
  • the responsive-strategy verdict (container query vs. media query appropriateness) for any new responsive rule,
  • the recommended cascade-layer placement for new rules,
  • residual risk notes for anything requiring live visual-regression or contrast-checker verification beyond this static review.
Files (vanguard-frontier-agentic)
  • references
    • cascade-layer-strategy.md 6.5 KB
      # Cascade layer strategy
      
      Use this reference when establishing or auditing a `@layer` order for a codebase, or resolving a specificity conflict between two legitimate rules.
      
      ## What people get wrong
      
      The naive story is:
      
      > Cascade layers are just a naming convention — put rules in a `@layer` block and specificity stops mattering.
      
      Half right, and the half that's wrong is dangerous. Layers change *which layer wins*, but specificity still decides the winner *within* a layer, and — critically — the precedence order **inverts** for `!important` declarations. Per MDN's cascade-layers guidance: earlier-declared layers win over later-declared layers for normal declarations, but for `!important` declarations, earlier-declared layers win over later ones too — meaning an `!important` in an early "reset" layer can beat an `!important` in a later "overrides" layer, which is the opposite of what most engineers assume ("overrides should always win"). Unlayered styles sit in an implicit final layer for normal declarations, but unlayered `!important` styles have *lower* precedence than any layered `!important` declaration. Get this backwards and you'll "fix" a cascade bug by adding `!important` to the wrong layer and watch it silently lose anyway.
      
      ## Officially grounded shape (MDN / W3C Cascade 5)
      
      - `@layer name1, name2, name3;` declares layer order upfront, independent of where each layer's rules are later defined in the file.
      - Layer order determines precedence **regardless of selector specificity** for normal (non-important) declarations — a low-specificity selector in a later layer beats a high-specificity selector in an earlier layer.
      - Unlayered styles form an implicit layer that comes **last** (highest precedence) for normal declarations.
      - For `!important` declarations, the precedence order is **inverted**: earlier-declared layers' important styles win over later layers' important styles, and layered important styles always beat unlayered important styles.
      - Inline `style=""` importance still beats all author-layer `!important` declarations, regardless of layer order.
      - `@import url(...) layer(name);` can assign an entire imported stylesheet to a layer, which is useful for third-party CSS you don't control (framework resets, component libraries) — put it in an early layer so your own rules can override it without `!important`.
      
      ## Non-negotiable design rules
      
      ### 1. Declare the full layer order in one place, upfront
      
      Do not let layer order emerge implicitly from file-load order. A single `@layer reset, base, tokens, components, utilities, overrides;` statement (naming may vary per codebase convention) at the top of the entry stylesheet is the source of truth. If layer order is scattered or redeclared inconsistently across files, the *effective* order becomes whatever browser resolves first-seen — audit for this as a HIGH-severity finding.
      
      ### 2. `!important` inside a layer is not a free pass — verify the inversion
      
      Before approving `!important` anywhere, confirm which layer it lives in and whether the intended "win" actually happens under the inverted precedence rule. An `!important` added to `overrides` (a late layer) to "make sure it wins" will **lose** to an `!important` already present in an earlier layer like `reset`. This is the single most common cascade-layer mistake — check it explicitly, don't assume.
      
      ### 3. Third-party/vendor CSS goes in the earliest layer
      
      Wrap vendor resets, component-library base styles, or any CSS the team doesn't control in its own early layer (or `@import ... layer(vendor);`). This guarantees your own component/utility layers can override it with normal specificity, with no `!important` needed at all — that's the actual payoff of adopting layers.
      
      ### 4. Utilities still need to out-rank components, by layer not specificity
      
      If the codebase uses utility classes (e.g. Tailwind-style) alongside component styles, utilities must live in a layer declared *after* the components layer. Do not rely on utility classes having higher specificity than component selectors — that's fragile and exactly the pattern layers exist to replace.
      
      ### 5. New ID-selector or `!important` usage outside an established layer is a regression, not a quick fix
      
      Once a codebase has adopted cascade layers, any new unlayered `!important` or ID-selector styling should be treated as bypassing the system the team already invested in. Flag it and point to the correct layer.
      
      ## Specificity primer (for the parts layers don't cover)
      
      Within a single layer (or in a codebase with no layers), specificity still resolves conflicts using the standard weight: inline style > ID selectors > class/attribute/pseudo-class selectors > type/pseudo-element selectors, with `!important` overriding all of the above except a later `!important` of equal-or-higher-weight origin. Report specificity as a 4-part tuple (inline, IDs, classes/attrs/pseudo-classes, types/pseudo-elements) when it materially matters to a finding — do not just say "too specific" without the number.
      
      ## Minimal safe implementation flow
      
      1. Confirm whether the codebase already declares a layer order. If yes, audit new rules against it. If no, do not retrofit an entire stylesheet into layers as a side effect of a routine review — recommend it as a separate, scoped initiative and note the current specificity-conflict risk in the meantime.
      2. For any flagged `!important` or ID selector, identify the specific rule it's fighting and the minimal layer-based fix (move to correct layer, or remove the escalation entirely because the real fix is layer placement).
      3. Verify inverted `!important` precedence explicitly for any layer-crossing `!important` conflict before declaring a winner — do not eyeball it.
      4. Note any third-party CSS that isn't isolated into its own layer as a maintainability risk.
      
      ## Adversarial checklist
      
      Before finalizing a cascade-layer finding, answer these:
      
      - Is the full layer order declared in exactly one place, and does every file agree with it?
      - If this conflict involves `!important` on both sides, did I apply the inverted precedence rule, or did I default to "later wins" (which is wrong for important declarations)?
      - Is this `!important` compensating for a missing/incorrect layer assignment, rather than a legitimate necessity (e.g., overriding inline styles from a CMS)?
      - Is the specificity claim backed by an actual computed tuple, or asserted qualitatively ("too specific")?
      
      If any answer is "not sure," lower the finding's confidence and label it `documentation-based, needs live cascade-order verification` rather than presenting it as a confirmed defect.
      
    • responsive-strategy.md 6.9 KB
      # Responsive strategy decision guide
      
      Use this reference when deciding container query vs. media query, or auditing reflow/resize-text compliance at 400%/200% zoom.
      
      ## What people get wrong
      
      The naive story is:
      
      > Container queries are the new best practice — replace media queries with them wherever possible.
      
      Wrong. Container queries and media queries answer different questions and are not interchangeable. A media query answers "how big is the viewport (or does the user prefer reduced motion / dark mode / etc.)?" A container query answers "how big is *this specific containing element*, regardless of viewport?" A component meant to be reusable inside a narrow sidebar *and* a wide main-content area needs a container query — a media query cannot express that, because the viewport is the same in both placements. Conversely, a page-level layout shift (e.g. switching a top-nav to a hamburger menu) is inherently viewport-driven and belongs in a media query — wrapping the whole page in a container just to query it is unnecessary indirection.
      
      ## Officially grounded shape (MDN CSS Containment / Container Queries)
      
      - `container-type: inline-size;` (or `size`) on an ancestor establishes a **query container**; `container-name` optionally scopes which `@container` rules target it.
      - `@container (width >= 400px) { ... }` and named variants `@container excerpt (width >= 400px) { ... }` share the same comparison syntax and logical operators (`and`, `or`, `not`) as media queries.
      - Container **style** queries (`@container style(--flag: value)`) also exist for querying a custom-property value on the container, distinct from size queries — verify which variant (`size` vs `style` vs both) the codebase/browser target actually needs before recommending one.
      - A container query cannot query the size of the element it's applied to relative to itself (no self-referential sizing loop) — the `container-type` must be set on an **ancestor**, and the query targets descendants of that ancestor.
      - Setting `container-type: size` or `inline-size` on an element applies layout/size containment to it, which affects how that element's children are sized (e.g. percentage heights) — this is a real layout side effect, not a no-op flag, and must be accounted for, not just bolted on to "enable container queries."
      
      ## Non-negotiable design rules
      
      ### 1. Ask "does this depend on its container, or on the viewport?" before choosing
      
      If the same component needs different styling depending on *where it's placed* (sidebar vs. full-width), that's a container-size dependency → container query. If the same component always needs the same styling regardless of placement, but that styling should change based on *screen size*, that's a viewport dependency → media query. Do not default to container queries just because they are newer; recommending one when the actual dependency is viewport-based is a correctness bug, not a stylistic choice.
      
      ### 2. Verify the containment side effect before approving `container-type`
      
      Applying `container-type: size` or `inline-size` establishes containment that can change how a container's children resolve percentage-based dimensions and can affect the container's own intrinsic sizing behavior. Flag any new `container-type` addition to an element whose children rely on percentage heights or intrinsic sizing without a check that behavior is still correct.
      
      ### 3. Do not recommend "just add both" as a hedge
      
      Applying both a media query and a container query to the same rule for the "same" breakpoint without a distinct rationale for each is a maintainability trap — two systems now need to be kept in sync for one visual outcome. If both are genuinely needed (e.g., viewport-level layout change *and* the component independently needs to adapt to a narrower container within that layout), state the distinct rationale for each explicitly.
      
      ### 4. Media queries remain correct — and required — for preference-based and non-size media features
      
      `prefers-reduced-motion`, `prefers-color-scheme`, `prefers-contrast`, `forced-colors`, and print media all have no container-query equivalent; container queries only address size/style-of-container, not user/device preference signals. Never suggest replacing a preference-based media query with a container query.
      
      ## WCAG 2.2 reflow and resize-text audit
      
      - **1.4.10 Reflow**: content must be usable without horizontal scrolling (except content requiring 2D layout, like data tables or images) at a 320 CSS-px equivalent viewport width (i.e., 400% zoom on a 1280px-wide viewport). Flag any fixed-width container, fixed `min-width` wider than ~320px on primary content, or `overflow-x` forced on the body/main content region as a reflow-failure risk.
      - **1.4.4 Resize text**: text must remain readable and functional when resized up to 200% without loss of content or functionality, without requiring assistive technology. Flag any font-size defined in `px` on root/body text without a corresponding relative-unit (`rem`/`em`/`%`) sizing strategy, and flag any fixed-height text container that would clip text at 200% zoom.
      - Fixed viewport units (`vh`/`vw`) used for text container height, combined with fixed-size text, is a common reflow+resize-text double failure — flag it as one finding with both WCAG criteria cited, not two separate notes.
      - These are static-review flags based on markup/CSS inspection, not a substitute for live zoom/reflow testing in a real browser — always label the finding `documentation-based risk, requires live verification at 400%/200% zoom`.
      
      ## Minimal safe implementation flow
      
      1. For each new/changed responsive rule, identify what the styling actually depends on: container size, viewport size, or a user/device preference.
      2. Match the dependency to the correct query type per the rules above.
      3. If `container-type` is newly applied, check descendant elements for percentage-based sizing that containment could affect.
      4. Scan for fixed-width primary-content containers, fixed-px text sizing, and fixed-height text containers as reflow/resize-text risk flags.
      5. Report all size-based container-query/media-query findings and all WCAG 1.4.10/1.4.4 flags as `documentation-based risk` pending live-browser verification — never assert a WCAG pass/fail from static review alone.
      
      ## Adversarial checklist
      
      Before finalizing a responsive-strategy finding, answer these:
      
      - Is the actual styling dependency container-size, viewport-size, or a user/device preference — confirmed, not assumed?
      - If recommending `container-type`, did I check whether it changes containment behavior for existing percentage-sized children?
      - Am I recommending both a media query and a container query for the same visual outcome without a distinct rationale for each?
      - Have I mislabeled a static-review flag as a confirmed WCAG pass/fail instead of a risk pending live verification?
      
      If any answer is "not sure," lower the finding's confidence and label it `documentation-based, requires live verification` rather than presenting it as a confirmed defect.
      
    • token-conformance.md 5.6 KB
      # Design token conformance patterns
      
      Use this reference when auditing hardcoded-value drift against an existing custom-property token system, including token-tier (primitive vs. semantic vs. component) conventions.
      
      ## What people get wrong
      
      The naive story is:
      
      > If a codebase has CSS custom properties, any hex code or `px` value found in a stylesheet is a violation — just swap in the nearest-looking token.
      
      Wrong on two counts. First, not every hardcoded value is drift — a one-off value with no semantic meaning (e.g. a decorative `box-shadow` blur radius unique to one component) may legitimately not belong in the token system. Second, "nearest-looking" is the wrong selection criterion: swapping a hardcoded `#3B82F6` for whatever token happens to render the closest shade of blue, without checking whether that token is semantically named for a *different* purpose (e.g. `--color-danger` vs `--color-brand-primary` happening to be visually similar), silently couples unrelated UI concerns and will drift the moment either token's value changes for its actual intended purpose.
      
      ## Officially grounded shape (W3C CSS Custom Properties / MDN)
      
      - CSS custom properties (`--token-name: value;`) are just inherited, cascade-participating properties — they carry no built-in type, tier, or namespace semantics. Any tiering convention (primitive/semantic/component) is a *codebase convention*, not a CSS-spec-enforced structure. Verify the codebase's actual convention before applying a generic three-tier assumption.
      - `var(--token-name, fallback)` resolves to `fallback` only if the custom property is unset or invalid at computed-value time — an empty-string or whitespace-only fallback is valid and will not error, which can silently produce unstyled output. Flag fallback values used to paper over a token that should exist but doesn't.
      - Custom properties are visible to and overridable at any DOM node via the cascade — a component-scoped token override (e.g. `.card { --spacing-gap: 8px; }`) is a normal and often correct pattern, not automatically drift.
      
      ## Non-negotiable design rules
      
      ### 1. Establish which token tiers actually exist in this codebase before auditing
      
      Common conventions: **primitive** (raw values: `--blue-500: #3B82F6`), **semantic** (purpose-bound: `--color-brand-primary: var(--blue-500)`), **component** (scoped: `--button-bg: var(--color-brand-primary)`). Not every codebase has all three tiers. Read the existing token file(s) first — do not assume a tier structure the codebase hasn't adopted.
      
      ### 2. Flag hardcoded values only when a token exists for that exact purpose
      
      If a semantic token like `--spacing-md` exists and a new rule hardcodes `16px` where `--spacing-md` resolves to the same value, that's drift — flag it and name the token. If no token covers that specific purpose (e.g. a genuinely one-off decorative value), do not force a token substitution; note it as "no matching token — token-system gap or legitimately one-off" and let a human decide whether to add a token.
      
      ### 3. Recommend the correct tier, not just the nearest value
      
      When a hardcoded value should become a token, point to the most specific applicable tier — component tier if a component-scoped token already exists for that role, semantic tier if not, primitive tier only as a last resort (raw primitives should rarely be referenced directly from component styles; that's what semantic tokens are for). Recommending a raw primitive when a semantic token already covers the case reintroduces exactly the coupling problem tokens exist to prevent.
      
      ### 4. Treat `var()` fallback values as a signal, not noise
      
      A `var(--token, <hardcoded-fallback>)` pattern used defensively across many call sites for the *same* token is a sign the token itself may be missing from some build/theme context — flag it as a build/theming risk, not a per-call-site style nitpick.
      
      ### 5. Do not flag legitimate component-scoped overrides as drift
      
      `.card--compact { --card-padding: var(--spacing-sm); }` is normal token-system usage (a component redefining a token it owns, still referencing the token system). Only flag when the override value is hardcoded raw instead of referencing another token, or when it silently diverges from the token's documented purpose.
      
      ## Minimal safe implementation flow
      
      1. Locate and read the codebase's token definition file(s) (commonly `:root { --... }` blocks, a `tokens.css`, or a design-tokens JSON/YAML source feeding generated CSS).
      2. Determine the tier convention in use, if any.
      3. Grep the diff/file under review for raw color (`#`, `rgb(`, `hsl(`), spacing (`px`, `rem` outside of token definitions), and typography (font-family, font-size literals) values.
      4. For each hit, check whether an existing token resolves to the same or functionally equivalent value and purpose. Report a match, a "gap" (no token exists), or confirm it's an intentional one-off.
      5. Never invent a token name that doesn't exist in the codebase and present it as if it does — only recommend using tokens that are confirmed present via Read/Grep.
      
      ## Adversarial checklist
      
      Before finalizing a token-conformance finding, answer these:
      
      - Does a token actually exist for this exact purpose, confirmed via Read/Grep — not assumed from naming convention alone?
      - Am I recommending the most specific applicable tier (component > semantic > primitive), or just the first token that visually matches?
      - Could this hardcoded value be a legitimate one-off rather than drift?
      - Is this `var()` fallback masking a real token-availability gap in some theme/build context?
      
      If any answer is "not sure," report it as "no matching token found — confirm with design-system owner" rather than asserting a specific token substitution as fact.
      
  • metadata.json 1.6 KB
    {
      "id": "css-architecture-design-system-review",
      "name": "CSS Architecture & Design System Review",
      "type": "skill",
      "provider": "frontend",
      "harnesses": [
        "claude-code",
        "cursor",
        "codex",
        "gemini",
        "kiro",
        "other"
      ],
      "summary": "Reviews CSS for specificity/cascade-layer discipline, design-token conformance, and responsive strategy (container queries vs. media queries), catching specificity wars, token drift, and non-reflowing layouts before they compound into unmaintainable stylesheets.",
      "source_type": "original",
      "official_docs": [
        "https://developer.mozilla.org/en-US/docs/Web/CSS",
        "https://www.w3.org/TR/css-cascade-5/",
        "https://www.w3.org/TR/css-variables-1/",
        "https://www.w3.org/TR/css-contain-3/",
        "https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascade/Cascade_layers",
        "https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries",
        "https://www.w3.org/TR/WCAG22/#visual-presentation"
      ],
      "security_notes": "Do not treat CSS visibility/display properties as an access-control mechanism — hiding an element with CSS never substitutes for server-side authorization; flag any pattern that relies on it as a security control. Flag attribute-selector-plus-background-image patterns that could exfiltrate user-controlled attribute values via network requests (CSS-based data-exfiltration vector). Flag third-party @import without SRI/CSP style-src consideration.",
      "last_verified": "2026-07-02",
      "path": "skills/frontend/css-architecture-design-system-review",
      "author": "github: VincentChuWaiChow",
      "version": "0.1.0"
    }
    
  • SKILL.md 7.1 KB
    ---
    name: css-architecture-design-system-review
    description: Review CSS for specificity and cascade-layer discipline, design-token (custom-property) conformance, and responsive strategy correctness (container queries vs. media queries), catching specificity wars, hardcoded-value token drift, and non-reflowing layouts that fail WCAG 1.4.10/1.4.4 before they compound into unmaintainable stylesheets.
    allowed-tools: Read Grep Glob Bash(git diff:*) WebFetch
    metadata:
      author: "github: VincentChuWaiChow"
      version: "0.1.0"
      updated: "2026-07-02"
      category: architecture
    ---
    
    # CSS Architecture & Design System Review
    
    ## Purpose
    
    CSS at scale degrades through two silent mechanisms: specificity creep (engineers reaching for `!important` or ID selectors to win cascade fights instead of fixing the underlying layer structure) and design-token drift (hardcoded values reappearing next to a token system, diverging visual output over time). Neither shows up as a compile error or a failing test — they show up eighteen months later as an unmaintainable stylesheet nobody wants to touch. This skill catches both at review time, plus the responsive-strategy and WCAG visual-presentation failures that are CSS's specific accessibility responsibility.
    
    ## When to use
    
    Use this skill when the user asks to:
    
    - review a CSS/component-styling diff for specificity, cascade, or maintainability issues,
    - audit a codebase's design-token (CSS custom-property) conformance,
    - decide between container queries and media queries for a responsive pattern,
    - establish or enforce a cascade-layer strategy (`@layer reset, base, tokens, components, utilities, overrides`),
    - check layout resilience against WCAG 2.2 reflow (1.4.10) and resize-text (1.4.4) criteria.
    
    Do not use this skill for:
    
    - JavaScript/framework component architecture — use the matching framework-specific review skill instead,
    - live visual-regression testing or contrast-ratio measurement — that requires a runtime tool, not static review,
    - choosing a CSS methodology from scratch with no existing code — that is a greenfield design conversation, not a review.
    
    ## Context7 Documentation Protocol
    
    - Resolve the MDN Web Docs library ID with `resolve-library-id` (matched result: `/mdn/content`) before citing any cascade-layer, container-query, or custom-property specificity claim.
    - Before asserting cascade-layer precedence, `!important` interaction, or container-query browser-support behavior, call `query-docs` against `/mdn/content` and cite the section — do not assert from memory. Cascade-layer `!important` precedence is inverted relative to normal-declaration precedence and is easy to misstate without checking.
    - If Context7 is unavailable, fall back to the `official_docs` URLs in this skill's `metadata.json` and label the claim `documentation-based, unverified against current release`.
    - Never assume a browser-support baseline (e.g., "container queries are safe everywhere now") without checking current docs; treat support claims as version/date-sensitive, not fixed facts.
    
    ## Lean operating rules
    
    - Never approve new `!important` without a documented cascade-layer justification — it is a symptom that the layer/selector structure should be fixed, not a valid quick fix. Note: `!important` precedence is inverted across layers (earlier-declared layers win for important declarations), so verify actual winning behavior against the declared `@layer` order rather than assuming a simple override.
    - Never approve new ID-selector styling for components; treat it as a specificity-escalation risk that will require `!important` or worse to override later.
    - In any codebase with an established design-token system, flag hardcoded color/spacing/typography values and name the nearest token substitute — do not silently allow token drift. Distinguish token tiers (primitive → semantic → component) when recommending a substitute; do not point a component-level override at a raw primitive if a semantic token exists.
    - Do not bikeshed methodology (BEM vs. utility-first vs. CSS Modules vs. cascade layers) when a convention is already established; enforce consistency with what exists over personal preference.
    - Query current MDN/W3C docs for `@layer`/`@container` support and semantics before ruling — container queries only reached broad Baseline status in 2023 and cascade-layer support nuances (especially `!important` interaction) vary; never assert current support from memory.
    - Distinguish container queries (component depends on its container's size) from media queries (component depends on the viewport) — recommending the wrong one for the actual dependency is a correctness bug, not a style preference. A component intended for reuse across differently-sized containers (sidebar, main content, modal) needs a container query; a page-level layout shift needs a media query.
    - Never treat CSS as an access-control boundary; `display:none`/`visibility:hidden` hiding an affordance is not a substitute for server-side authorization. Flag this as a HIGH-severity finding, not a style note, whenever hidden-but-present markup carries privileged data or actions.
    - Flag anything needing live visual-regression or contrast-ratio measurement as a residual risk requiring live-runtime verification, not asserted from static analysis alone.
    - Flag attribute-selector-plus-background-image patterns (e.g. `input[value^="a"] { background: url(...) }`) as a potential CSS-based data-exfiltration vector — they can leak user-controlled attribute values via network requests.
    - Flag third-party `@import` rules with no accompanying Subresource Integrity or CSP `style-src` consideration as a supply-chain risk, not a performance nitpick.
    - Never execute, build, or run application code, and never fetch live pages to "see how it renders" without the user's explicit ask; this is a static-review skill augmented only by documentation lookups (Read/Grep/Glob plus scoped `git diff` and `WebFetch` for docs/spec grounding).
    
    ## References
    
    Load these only when needed:
    
    - [Cascade layer strategy](references/cascade-layer-strategy.md) — use when establishing or auditing a `@layer` order for a codebase, or resolving a specificity conflict between two legitimate rules.
    - [Design token conformance patterns](references/token-conformance.md) — use when auditing hardcoded-value drift against an existing custom-property token system, including token-tier (primitive vs. semantic vs. component) conventions.
    - [Responsive strategy decision guide](references/responsive-strategy.md) — use when deciding container query vs. media query, or auditing reflow/resize-text compliance at 400%/200% zoom.
    
    ## Response minimum
    
    Return, at minimum:
    
    - the specificity/cascade verdict per flagged selector, with its computed specificity value when relevant,
    - a token-conformance report distinguishing token-referenced values from hardcoded ones,
    - the responsive-strategy verdict (container query vs. media query appropriateness) for any new responsive rule,
    - the recommended cascade-layer placement for new rules,
    - residual risk notes for anything requiring live visual-regression or contrast-checker verification beyond this static review.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related