# CSS Development Skill Design **Date:** 2025-11-13 **Author:** Claude (code_wizard) **Status:** Design Approved ## Overview A comprehensive Claude Code skill system for CSS development following the Tailwind + Semantic Component pattern established in the oneonone/hosting codebase. ## Purpose Enable Claude Code to automatically guide, validate, and refactor CSS following these patterns: - Semantic component classes using Tailwind's `@apply` directive - Framework-agnostic markup integration (React, Vue, vanilla HTML) - Dark mode support by default - Test-driven development for CSS components - Atomic design principles (atoms → molecules → organisms) ## CSS Development Pattern ### Core Principles 1. **Semantic Naming:** Use descriptive class names (`.button-primary`, `.card-header`) not utility names (`.btn-blue`, `.card-hdr`) 2. **Tailwind Composition:** Leverage Tailwind utilities via `@apply` directive 3. **Dark Mode by Default:** Include `dark:` variants for all colored/interactive elements 4. **Composition Over Creation:** Reuse existing classes before creating new ones 5. **Test Coverage:** Static CSS tests + component rendering tests 6. **Documentation:** Usage comments above each component class ### Component Class Pattern ```css /* Button component - Primary action button with hover states Usage: */ .button-primary { @apply bg-indigo-500 hover:bg-indigo-700 dark:bg-indigo-600 dark:hover:bg-indigo-800; @apply px-6 py-3 rounded-lg font-medium text-white; @apply transition-all duration-200 hover:-translate-y-0.5; } ``` **Key characteristics:** - Group related utilities logically (background, spacing, typography, transitions) - Include hover/focus/active states - Include dark mode variants - Use Tailwind's built-in color scales (indigo-500, gray-800, etc.) ### File Structure ``` styles/ ├── components.css # All semantic component classes └── __tests__/ └── components.test.ts # CSS and component tests ``` ### Markup Integration Pattern Framework-agnostic approach that works with React, Vue, Svelte, or vanilla HTML: ```tsx // React const classes = `button-primary ${className}`.trim(); ``` ```html ``` ```vue ``` **Key principle:** Semantic class + ability to add additional classes for customization. ### Atomic Design Levels - **Atoms:** Basic building blocks (`.button`, `.input`, `.badge`, `.spinner`) - **Molecules:** Composed components (`.card`, `.form-field`, `.empty-state`) - **Organisms:** Complex components (`.page-layout`, `.session-card`, `.conversation-timeline`) ### Testing Requirements **Static CSS Tests:** ```typescript it('should have button component classes', () => { const content = readFileSync('styles/components.css', 'utf-8'); expect(content).toContain('.button-primary'); }); ``` **Component Rendering Tests:** ```typescript it('applies semantic class and custom className', () => { render( ``` ```css /* components.css - New semantic class extracted */ .button-primary { @apply bg-indigo-500 hover:bg-indigo-700 dark:bg-indigo-600 dark:hover:bg-indigo-800; @apply px-6 py-3 rounded-lg text-white; @apply transition-all duration-200; } ``` ## Design Decisions ### Why Main + Sub-Skills Architecture? **Chosen over:** - Single skill with mode selection (would be too long) - Context-aware smart skill only (would have complex branching logic) **Benefits:** - Modularity: Each sub-skill focused on one workflow - Maintainability: Easy to update individual workflows - Clarity: Clear separation of concerns - Composability: Can invoke sub-skills directly if user knows which they need ### Why Semantic Classes Over Pure Utility-First? **Rationale:** - Maintainability: Centralized styling in CSS files vs. scattered in markup - Consistency: One source of truth for component appearance - Framework-agnostic: Works with any framework or vanilla HTML - Easier refactoring: Change once in CSS vs. finding all usages in markup - Better code review: CSS changes visible in dedicated files **Trade-off:** Slight indirection, but offset by improved maintainability ### Why Dark Mode by Default? **Rationale:** - Modern web expectation: Users increasingly expect dark mode - Easier to add upfront: Retrofitting dark mode is more work - Consistent UX: All components support theming from start - Tailwind makes it easy: `dark:` prefix is low overhead **Trade-off:** Slightly more verbose CSS, but worth the UX benefit ### Why Test Coverage Required? **Rationale:** - Prevents regressions: CSS refactors don't break existing components - Documents expected behavior: Tests serve as usage documentation - Aligns with TDD philosophy: From CLAUDE.md user instructions - Low overhead: Static CSS tests are simple `toContain()` checks **Trade-off:** Additional files, but minimal effort with clear value ## Implementation Approach ### Phase 1: Main Skill - Create orchestrator skill with pattern documentation - Implement context detection and routing logic - Define skill description for auto-detection ### Phase 2: Create Component Sub-Skill - Implement TodoWrite checklist workflow - Add composition checking logic - Create example component templates ### Phase 3: Validate Sub-Skill - Implement pattern checking logic - Create feedback formatting - Add prioritization of issues ### Phase 4: Refactor Sub-Skill - Implement pattern detection in existing code - Add extraction logic for semantic classes - Create before/after examples ### Phase 5: Testing & Iteration - Test each sub-skill independently - Test full workflows (orchestrator → sub-skill) - Refine based on real usage ## Success Criteria - Claude Code automatically invokes skill for CSS-related work - Create workflow results in well-formed, tested components - Validate workflow provides specific, actionable feedback - Refactor workflow preserves behavior while improving code structure - All generated CSS includes dark mode support - All generated components have test coverage - Skills work with React, Vue, and vanilla HTML equally well ## Future Enhancements - Animation component patterns - Accessibility checking (color contrast, focus states) - Performance optimization patterns (critical CSS, purging) - Style guide generation from components.css - Integration with design systems (Figma tokens, etc.) ## References - Source codebase: `/Users/dylanr/work/2389/oneonone/hosting` - Tailwind CSS v4: https://tailwindcss.com/docs - Atomic Design Methodology: https://bradfrost.com/blog/post/atomic-web-design/