agentleFS
LeonxLJXLeonxLJX/web-engineer-skills/skills/css-architecture/SKILL.md

css-architecture

Skill0 starsChanged 2 months agoMITView on GitHub

CSS that scales past 10k lines — design tokens, cascade layers, dark mode, container queries, and when to reach for utility classes vs components. Use when building styling systems or reviewing CSS for large frontends.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every color, spacing, radius, font-size, z-index lives in a token.

    line 10
  2. Distinctive:

    Test shadows/borders in dark mode — the classic broken spots.

    line 54
  3. Distinctive:

    If you repeat a utility combo 3+ times, promote it to a component class.

    line 60

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CSS architecture for grown-ups

Tokens are the API

Every color, spacing, radius, font-size, z-index lives in a token; components consume tokens, never literals:

:root {
  --space-1: 4px; --space-2: 8px; --space-4: 16px;
  --color-bg: #fff; --color-fg: #111;
  --z-modal: 100; --z-toast: 200;
}
[data-theme='dark'] {
  --color-bg: #0b0d10; --color-fg: #e7ebf0;
}
  • New visual tweak = new/changed token, reviewed like API. Hardcoded hex in components is a review blocker.
  • Z-index is a token ladder (dropdown < sticky < modal < toast) — never z-index: 9999.

Layers to win specificity wars

@layer reset, tokens, base, components, utilities;

Third-party styles import into base; utilities win without !important; components stay mid-cascade. This one line ends most "why isn't my style applying" archaeology.

Scope by component, not by page

  • One class per element (.card__title or co-located module class). Descendant selectors 4+ deep are a smell.
  • Global element selectors only in reset/base. Anything else belongs to a component file.

Responsive: container over viewport when it's a component

Media queries for layout; container queries for reusable components that must adapt to where they're placed:

.card-wrap { container-type: inline-size; }
@container (min-width: 480px) {
  .card { display: flex; }
}

Dark mode without drift

  • Tokens carry the theme (above). Components never branch on theme.
  • Support prefers-color-scheme and manual override via data-theme; persist the choice.
  • Test shadows/borders in dark mode — the classic broken spots.

Utilities vs components

  • Utilities (flex, mt-2) for layout glue and one-offs.
  • Component classes for anything reused with meaning (.btn, .card).
  • If you repeat a utility combo 3+ times, promote it to a component class.

Motion

  • Transitions on transform/opacity only (compositor-friendly).
  • Wrap decorative animation in @media (prefers-reduced-motion: no-preference).

Definition of done (agent checklist)

  • No raw hex/px outside token files
  • Cascade layers declared; utilities import into their layer
  • Every interactive state has hover and focus-visible styles
  • Dark mode verified on the touched surfaces
  • No !important outside layers rationale
  • Container queries for component-local responsiveness

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.