css-workflow
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
CSS Workflow
Tool Grid
| Task | Tool | Command |
|---|---|---|
| Lint | Stylelint | npx stylelint "**/*.css" |
| Format | Prettier | npx prettier --write "**/*.css" |
| Dead code | PurgeCSS | npx purgecss --css *.css --content *.html |
Tailwind CSS
RECOMMENDED over custom CSS for consistency and maintainability.
- SHOULD use utility classes for most styling needs
- MUST configure
tailwind.config.jsfor project design tokens - SHOULD use
@applysparingly - prefer utilities in markup - MUST NOT use arbitrary values (
[123px]) when design token exists - SHOULD extend theme rather than override
Class order: Layout > Sizing > Spacing > Typography > Colors > Effects > Interactivity
Native CSS Features
SHOULD prefer native CSS over Sass/preprocessors.
/* CSS Variables */
:root { --color-primary: #3b82f6; }
.component { color: var(--color-primary, #3b82f6); }
/* Native Nesting */
.card {
& .title { font-weight: bold; }
&:hover { box-shadow: 0 4px 6px rgb(0 0 0 / 0.1); }
}
/* Container Queries */
.card-container { container-type: inline-size; }
@container (min-width: 400px) { .card { display: grid; } }
Naming Conventions
SHOULD use BEM for custom CSS:
.card { } /* Block */
.card__title { } /* Element */
.card--featured { } /* Modifier */
- MUST use lowercase
kebab-case - SHOULD use semantic names (
btn-primarynotbtn-blue) - MUST prefix utilities with
u-, JS hooks withjs-
Organization
Property order: Positioning > Display/Box Model > Typography > Visual > Misc
Mobile-first: MUST use min-width media queries.
.component {
padding: 1rem;
@media (min-width: 768px) { padding: 2rem; }
}
Modern Features
/* Grid - 2D layouts */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
/* Flexbox - 1D layouts */
.flex { display: flex; align-items: center; gap: 1rem; }
/* Logical properties - i18n support */
.component { margin-inline: auto; padding-block: 1rem; }
Dark Mode
MUST support via prefers-color-scheme:
:root { --color-bg: #fff; --color-text: #1a1a1a; }
@media (prefers-color-scheme: dark) {
:root { --color-bg: #1a1a1a; --color-text: #fff; }
}
Optional class toggle: [data-theme="dark"] { --color-bg: #1a1a1a; }
Performance
- SHOULD inline critical above-the-fold CSS
- MUST NOT use
@importin production (blocks parallel downloads) - MUST remove unused CSS (PurgeCSS, Tailwind purge)
- SHOULD limit selector specificity (max 3 levels)
- MUST NOT use
!importantexcept for utilities
Accessibility
Focus States (REQUIRED)
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
Reduced Motion (REQUIRED)
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
Color & Visibility
- MUST meet WCAG 2.1 AA contrast (4.5:1 text, 3:1 large text)
- SHOULD NOT rely on color alone to convey information
.visually-hidden {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
More from ilude/claude-code-config
code-documentation
Guidelines for self-explanatory code and meaningful documentation. Activate when working with comments, docstrings, documentation, code clarity, API documentation, JSDoc, or discussing code commenting strategies. Guides on why over what, anti-patterns, decision frameworks, and language-specific examples.
12claude-code-workflow
Claude Code AI-assisted development workflow. Activate when discussing Claude Code usage, AI-assisted coding, prompting strategies, or Claude Code-specific patterns.
10api-design-patterns
Language-agnostic API design patterns covering REST and GraphQL, including resource naming, HTTP methods, status codes, versioning, pagination, filtering, authentication, error handling, and schema design. Activate when working with APIs, REST endpoints, GraphQL schemas, API documentation, OpenAPI/Swagger, JWT, OAuth2, endpoint design, API versioning, rate limiting, or GraphQL resolvers.
7python-workflow
Python project workflow guidelines. Triggers: .py, pyproject.toml, uv, pip, pytest, Python. Covers package management, virtual environments, code style, type safety, testing, configuration, CQRS patterns, and Python-specific development tasks.
6nextjs-workflow
Next.js framework workflow guidelines. Activate when working with Next.js projects, next.config, app router, or Next.js-specific patterns.
6typescript-workflow
TypeScript/JavaScript project workflow guidelines using Bun package manager. Triggers on `.ts`, `.tsx`, `bun`, `package.json`, TypeScript. Covers bun run, bun install, bun add, tsconfig.json patterns, ESM/CommonJS modules, type safety, Biome formatting, naming conventions (PascalCase, camelCase, UPPER_SNAKE_CASE), project structure, error handling, environment variables, async patterns, and code quality tools. Activate when working with TypeScript files (.ts, .tsx), JavaScript files (.js, .jsx), Bun projects, tsconfig.json, package.json, bun.lock, or Bun-specific tooling.
6