css-architecture
БесплатноБез исполняемых скриптовНе проверенOrganize CSS at scale using cascade layers, scoping strategies, and specificity budgets — preventing specificity wars, enabling safe deletion, and making CSS…
от eugenelim★ 35 звёзд на GitHubОб этом скилле
Skill: css-architecture
Load this skill when setting up CSS architecture for a new codebase, or
auditing and refactoring CSS in an existing one where specificity conflicts,
hard-to-predict cascade behavior, or unsafe deletion are active problems.
Do not load it for routine component styling on a codebase that already has
a working architecture. Load css-architecture when:
- Starting a new project and deciding the CSS organization strategy
- A codebase has accumulated specificity conflicts that produce unpredictable cascades
- Engineers cannot safely delete a CSS rule because they don't know what will break
- The codebase has grown beyond one developer and CSS changes produce unexpected regressions
Cascade layers
@layer (Cascade Layers) is Baseline Widely Available as of 2022. It makes
the cascade explicit and controllable: a rule in a higher layer always wins
over a rule in a lower layer, regardless of specificity.
Canonical layer order:
/* Declare all layers upfront — this is the only place layer order is defined */
@layer reset, base, theme, components, utilities, overrides;
| Layer | Contents | Notes |
|---|---|---|
reset |
Browser default reset (e.g., box-sizing, margins) | No project-specific styles |
base |
HTML element defaults (body font, heading scale, link style) | Unclassed element selectors only |
theme |
Design token custom properties (:root {} token block) |
No component styles |
components |
Component class selectors (.btn, .card, .modal) |
The main application CSS lives here |
utilities |
Single-purpose utility classes (hidden, sr-only, spacing helpers) |
High-frequency reuse; should have low specificity |
overrides |
Escape hatch for third-party library overrides, print styles | Rarely used; document every rule added here |
Why ordering is the invariant: a rule in utilities always beats a rule
in components, regardless of how specific the component rule is. This means
utilities are reliable (you can always use a utility to override a component
style), but components cannot override utilities. The layer order must be
declared once at the top of the main stylesheet — never redeclare it in
component files.
Importing into layers:
@layer reset {
@import url('/css/reset.css');
}
@layer components {
@import url('/css/button.css');
@import url('/css/card.css');
}
Scoping strategy
Choose one scoping strategy for the project. Mixing strategies in the same codebase produces conflicting specificity assumptions.
CSS Modules: class names are hashed at build time (button_abc123);
guaranteed uniqueness per module. Appropriate for component-based frameworks
(React, Vue, Svelte) where each component file has its own CSS module.
- Strengths: zero naming collisions, dead code is detectable by the bundler.
- Weakness: no global shared classes unless explicitly exposed; requires a bundler.
BEM (Block-Element-Modifier): naming convention that encodes component
structure in the class name: .block__element--modifier.
- Strengths: portable, no build tools required, self-documenting.
- Weakness: class names become verbose; convention is manually enforced.
Utility-first CSS: all styling done with single-purpose utility classes. No component-level CSS; styles are composed in HTML.
- Strengths: no dead CSS, highly predictable, fast iteration.
- Weakness: HTML becomes verbose; component abstraction is in JS, not CSS.
CUBE CSS (Composition, Utility, Block, Exception): a hybrid that combines global composition (layout), utilities, block-level component styles, and per-instance exception overrides.
Selection criteria:
| Criterion | CSS Modules | BEM | Utility-first | CUBE |
|---|---|---|---|---|
| Framework-based (React/Vue) | Best | Works | Works | Works |
| No build tools | No | Best | Requires CDN build | Works |
| Small team, fast velocity | Works | Works | Best | Works |
| Large team, strict naming | Works | Best | Works | Works |
| Design-system-driven | Works | Works | Works | Best |
Specificity budget
The rule of thumb: no selector should exceed specificity 0-2-0
(two class names). Selectors with higher specificity are hard to override
without writing even-higher-specificity selectors, producing a cascade war.
/* Right: specificity 0-1-0 */
.button { color: var(--btn-text); }
/* Right: specificity 0-2-0 */
.button.is-active { color: var(--btn-text-active); }
/* Wrong: specificity 0-3-0 — already too high */
.nav .button.is-active { }
/* Wrong: ID selector — specificity 1-0-0 — overrides all class selectors */
#submit-button { }
ID selectors in CSS are banned. IDs have specificity 1-0-0 — they beat
every class-based selector regardless of how specific. Use IDs for JavaScript
hooks and accessibility (aria-labelledby, <label for="...">), never for
styling.
To audit current specificity: paste a stylesheet into a specifici
Установить css-architecture в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл css-architecture?
Organize CSS at scale using cascade layers, scoping strategies, and specificity budgets — preventing specificity wars, enabling safe deletion, and making CSS that other engineers can reason about. Triggers on "design the CSS architecture for this new codebase", "fix the specificity wars in our stylesheet", "refactor our cascade so rules can be deleted safely".
Как установить скилл css-architecture?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл css-architecture запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic