joabgonzalez/ai-agents-skills/css-best-practices
Claude Code and agent skill by joabgonzalez/ai-agents-skills
- community
Checking that the SKILL.md file is still in the repository.
CSS quality patterns: naming, specificity architecture, dark mode, and layout. Trigger: When reviewing CSS quality or stylesheet architecture.
Install
npx vskill@latest install joabgonzalez/ai-agents-skills/css-best-practicesSKILL.md
The same SKILL.md was published earlier as joabgonzalez/ai-agents-skills/css-best-practices.
CSS Best Practices
Quality patterns for CSS architecture, specificity management, theming, and layout. Applies to plain CSS, SCSS, and CSS Modules.
When to Use
- Reviewing CSS or SCSS for scalability and maintainability
- Evaluating naming conventions (BEM, utility, custom properties)
- Designing dark mode or theming strategy
- Diagnosing specificity conflicts or cascade issues
Don't use for:
- Tailwind utility class patterns (use tailwindcss)
- CSS-in-JS patterns (use relevant framework skill)
- Animation performance (use web-performance)
Critical Patterns
✅ REQUIRED [CRITICAL]: Custom Properties for Design Tokens
Define semantic tokens, not raw values. One change point, consistent everywhere.
✅ REQUIRED: Specificity Budget
Single class selectors maximum. Avoid ID selectors and !important. If you need !important, the architecture is broken.
✅ REQUIRED: Cascade Layers
Use @layer to establish explicit cascade order: reset → base → components → utilities.
✅ REQUIRED: Dark Mode via Custom Properties
Override custom properties at the theme level. Never duplicate color values per-component.
✅ REQUIRED: Layout with Modern Primitives
Grid for 2D layout, Flexbox for 1D alignment. No floats, no percentage hacks.
❌ NEVER: Magic Numbers
Unexplained values become unmaintainable. Extract to custom properties with naming that communicates intent.
❌ NEVER: Mixed Naming Conventions
BEM and utility classes in the same component scope cause naming chaos. Pick one per scope.
Symptom → Solution
| Symptom | Cause | Fix | |
|---|---|---|---|
Style needs !important to apply | Specificity war | Flatten with single-class selectors + @layer | |
| Dark mode colors duplicated across components | Class-based overrides | Custom properties + media/data-theme override | |
| "Why is this 23px?" | Magic number | Extract to custom property with comment | |
| Cascade breaks when file order changes | No explicit layer ordering | Add @layer declaration | |
| BEM + utility classes mixed in same element | Inconsistent convention | Pick one pattern per component scope | |
| Colors wrong in one theme but not another | Raw values, not tokens | Replace with semantic custom properties |
Decision Tree
Example
Edge Cases
Legacy browser support: Use @supports (--foo: bar) for feature detection rather than static compilation. For environments without custom property support, define fallback values inline before the var() call: color: #3b82f6; color: var(--color-brand-primary);
CSS Modules and custom properties: Custom properties defined in :root are global even in CSS Modules — tokens still work. Component-scoped variables must be defined on the component's root element.
SCSS variables vs custom properties: SCSS variables are compile-time (no runtime theming); custom properties are runtime (theme switching works). Prefer custom properties for any value that changes with theme, viewport, or user preference.
Specificity in third-party overrides: When overriding a third-party library with high specificity, use @layer to wrap the library styles — then your layer-less styles automatically win without !important.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/css-best-practices/SKILL.md
Popularity
- Repository stars
- 9
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/joabgonzalez/ai-agents-skills/css-best-practices)