CSS conventions, layout systems, and modern patterns: predictable styles through low specificity and explicit cascade control. Invoke whenever task involves any interaction with CSS code — writing, reviewing, refactoring, debugging, or understanding stylesheets, SCSS, layout, or responsive design.
Applies modern CSS conventions for predictable styling, responsive layouts, and low-specificity architecture when writing or reviewing stylesheets.
npx claudepluginhub xobotyi/cc-foundryThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/layout.mdreferences/methodologies.mdreferences/modern-css.mdreferences/responsive.mdreferences/scss.mdPredictability is the highest CSS virtue. If your styles require !important
to work, restructure the cascade.
CSS rewards explicit, low-specificity selectors and intentional cascade ordering. Prefer boring, readable patterns over clever one-liners.
| Topic | Reference | Contents |
|---|---|---|
| Layout | references/layout.md | Flex shorthand values, grid details (subgrid, implicit rows, alignment), layout patterns |
| Modern CSS | references/modern-css.md | Extended modern CSS patterns and examples |
| SCSS | references/scss.md | @forward patterns, module configuration, built-in modules, file organization |
| Responsive | references/responsive.md | Extended responsive design patterns and examples |
| Methodologies | references/methodologies.md | Methodology patterns and architecture details |
.error not div.error!important — use cascade layers or restructure selectors instead;
only valid use is in a low-priority reset layer for truly essential styles:where() to zero-out specificity when needed —
:where(.card) .title has 0-0-1 specificity:is() with awareness — it takes the highest specificity of its arguments| Use Case | System |
|---|---|
| One-dimensional flow (row or column) | Flexbox |
| Two-dimensional layout (rows AND columns) | Grid |
| Content-driven sizing | Flexbox |
| Layout-driven sizing | Grid |
| Component internals (nav items, card content) | Flexbox |
| Page-level structure, complex arrangements | Grid |
| Items need to wrap naturally | Flexbox |
| Precise placement on named lines/areas | Grid |
Both work together — a grid item can be a flex container and vice versa.
flex shorthand — it sets intelligent defaults.
See references/layout.md for the full shorthand value tableflex-flow: row wrap combines flex-direction and flex-wrapflex-wrap with a flex basis for responsive layouts without media queries:
flex: 1 1 300px wraps items when they can't maintain 300px minimumdisplay: flex; align-items: center; justify-content: center
or margin: auto on a flex childgap over margin hacks — works in both flexbox and gridjustify-content: space-between with wrap — causes orphan gaps;
prefer gap + flex-wraprepeat(auto-fit, minmax(250px, 1fr)) is the canonical responsive grid — no media
queries neededauto-fit over auto-fill — auto-fit expands columns to fill space;
auto-fill keeps empty trackspx widths on grid items — use fr, minmax(), or autogrid-auto-flow: dense fills visual holes — use carefully, it breaks
visual/source order alignment (a11y concern)order in ways that break logical reading orderreferences/layout.md for subgrid, implicit rows, alignment shorthands,
and negative line numbersfloat for layout — floats are for wrapping text around imagesflex-wrap, min(), max(), clamp() before
reaching for media queriesgap over margin hacks in both flexbox and grid& for pseudo-classes/elements and compound selectors —
&:hover, &::before, &.active& for descendant selectors — .card { .title {} } works& is required when the nested selector starts with a type selector —
& p {} not p {}@media, @supports, @container) nest directly inside rules:is() wrapping applies in nesting — be aware that specificity
may differ from the equivalent unnested selector@layer)@layer reset, defaults, themes, components, utilities;!important reverses layer order — !important in the lowest layer wins over
!important in higher layers@import url('vendor.css') layer(vendor.bootstrap);revert-layer to roll back to the previous layer's value!important in low layers is intentional — it means "this style is essential,
don't override"@layer components { @layer buttons, cards; } —
access via @layer components.buttons@layer { }) can't be appended to latercontainer-type: inline-size on the wrappercontainer: card / inline-size@container card (width > 400px) { }| Unit | Meaning |
|---|---|
cqw / cqh | 1% of container width / height |
cqi / cqb | 1% of container inline / block size |
cqmin / cqmax | Smaller / larger of cqi or cqb |
Use cqi instead of vw for container-scoped fluid values:
font-size: clamp(1rem, 2.5cqi + 0.5rem, 2rem)
Design from the inside out — use the right tool for each level:
| Level | Tool | When |
|---|---|---|
| Content-driven | Flexbox wrapping, min()/max()/clamp() | Always — baseline |
| Container-driven | Container queries, cqi/cqw units | Component adapts to parent |
| Viewport-driven | Media queries, vw/vh/dvh | Page-level layout changes |
| User preference | prefers-* media queries | Color scheme, motion, contrast |
rem for breakpoints: @media (width >= 45rem) not (min-width: 768px)@media (768px <= width < 1024px)margin-inline-start not margin-leftprefers-reduced-motion, prefers-color-scheme,
prefers-contrastwidth: min(100% - 2rem, 75rem); margin-inline: auto — avoid multiple max-width values at different breakpointsclamp(min, preferred, max) for fonts, spacing, and container widths--step-0: clamp(1rem, 0.5rem + 1.5vw, 1.25rem)vw alone for font size — it blows up on large screens;
always pair with clamp() and remcqi instead of vw for container-scoped fluid valuesUse logical properties for layout-sensitive values (margins, padding, borders, text alignment, positioning offsets). Physical properties are fine for visual effects not affected by writing direction (e.g., box-shadow offsets).
| Physical | Logical |
|---|---|
left / right | inline-start / inline-end |
top / bottom | block-start / block-end |
width / height | inline-size / block-size |
margin-left | margin-inline-start |
padding-top | padding-block-start |
text-align: left | text-align: start |
Shorthands: margin-block: 1rem 2rem (block-start, block-end);
margin-inline: auto (both inline directions).
color-scheme: light dark on :root and use
@media (prefers-color-scheme: dark) for overridesprefers-reduced-motion: reduce or
add motion only in prefers-reduced-motion: no-preference (progressive
enhancement approach)@media (prefers-contrast: more)@media (hover: hover) for hover effects on capable devices;
@media (pointer: coarse) for touch targets (min 44px)img { max-width: 100%; height: auto; display: block; }aspect-ratio + object-fit: cover for hero images:has() SelectorSelect elements based on descendants or siblings — the "parent selector."
body, :root, or * — broad anchors
force expensive re-evaluation on every DOM change>) or sibling (+, ~) combinators inside :has()
to limit traversal scope:has() inside :has():has().layout:has(> .sidebar-open) (good) not body:has(.sidebar-open) (bad):root — scope overrides to components--color-text-primary not --dark-gray--color-, --spacing-, --font-var(--button-bg, var(--color-primary))--my-color differs from --My-Color@property for typed, animatable custom properties — enables type checking
(invalid values fall back to initial-value), controlled inheritance
(inherits: false), and transitions on custom propertiesview-transition-name must be unique per page at transition timeprefers-reduced-motion: reduce for view transitionsdocument.startViewTransition(() => { /* update DOM */ })@view-transition { navigation: auto; }::view-transition-group(name)box-sizing: border-box globally via resetrem for font sizes and breakpoints — respects user preferencesem for component-relative spacing (padding that scales with font size)clamp() — replace manual breakpoint laddersaspect-ratio over padding hacks for maintaining proportionsmargin: 0 not margin: 0px
(except where required: flex: 0 0 0px)opacity: 0.5 not opacity: .5#ebc not #eebbcc@use and @forward only — @import is deprecated (Dart Sass 1.80.0),
removed in 3.0.0@use must appear before any rules except @forwardvariables.$primary not global $primary@use 'variables' as * — use sparingly, only for own filesmath.div() for division — the / operator is deprecated- or _@extend — more predictable output; @extend produces
unexpected selectors and doesn't work across media queries@forward re-exports modules, supports prefixing and visibility control.
Module configuration uses !default variables and @use ... with ().
See references/scss.md for @forward patterns, configuration passthrough,
built-in module usage, and file organization conventions.
Use the official migrator: sass-migrator module --migrate-deps entrypoint.scss.
For built-in functions only: sass-migrator module --built-in-only entrypoint.scss.
.card, .nav, .form.card__title, .card__image.card--featured, .card__title--bold.card__header__title is wrong — flatten to .card__title
or create a new blockclass="card card--featured"composes: resetButton from './shared.module.css':global(.utility-class) when neededOrganize styles by specificity, low to high: Settings → Tools → Generic →
Elements → Objects → Components → Utilities. Maps naturally to cascade layers:
@layer settings, generic, elements, objects, components, utilities;
color: red not color:redWhen writing CSS:
When reviewing CSS:
Bad review comment:
"According to CSS best practices, you should avoid using ID selectors
for styling because they have high specificity."
Good review comment:
"`#header` -> `.header` -- IDs create specificity 1-0-0, difficult to override."
The coding skill governs workflow; this skill governs CSS implementation choices. For SCSS, this single skill covers both CSS and SCSS conventions.
Predictability is the highest CSS virtue. When in doubt, keep specificity low and cascade explicit.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.