/css-development:refactorfrom css-development
Converts inline styles or repeated Tailwind utility strings in markup to semantic component classes, and adds missing dark-mode variants. Use when markup contains repeated utility chains, inline styles, or components that lack dark: variants.
Ships in css-development. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Transforms existing CSS into semantic component patterns:
@apply compositionsThis is a sub-skill of css-development - typically invoked automatically via the main skill.
Use when:
See the css-development skill for the canonical pattern reference (semantic naming, @apply, dark mode, composition, testing).
When this skill is invoked, create a TodoWrite checklist and refactor systematically.
Use the TodoWrite tool:
Refactoring CSS:
- [ ] Analyze existing CSS (identify what needs refactoring)
- [ ] Find repeated patterns (look for duplicated utility combinations)
- [ ] Check existing components (see if patterns already exist)
- [ ] Extract to semantic classes (create new classes using @apply)
- [ ] Include dark mode (add dark: variants to new classes)
- [ ] Update markup (replace inline/utility classes with semantic names)
- [ ] Add tests (write static CSS and rendering tests)
- [ ] Document components (add usage comments)
- [ ] Verify behavior unchanged (ensure visual output matches original)
Action: Read and understand the CSS that needs refactoring
Look for:
Example patterns to refactor:
// Inline styles
<button style={{ background: 'indigo', padding: '1.5rem 2rem' }}>Click</button>
// Repeated utilities in markup
<button class="bg-indigo-500 hover:bg-indigo-700 px-6 py-3 rounded-lg text-white">
Click me
</button>
<button class="bg-indigo-500 hover:bg-indigo-700 px-6 py-3 rounded-lg text-white">
Submit
</button>
// Non-semantic CSS
.btn-blue {
background: blue;
padding: 12px 24px;
}
Capture:
Action: Identify duplicated utility combinations that should become semantic classes
Use Grep tool to search for repeated patterns:
# Search for common utility combinations
grep -r "bg-indigo-500 hover:bg-indigo-700 px-6 py-3" .
grep -r "rounded-lg shadow-md p-6" .
Categorize patterns:
For each pattern:
Action: Read styles/components.css to see if patterns already exist
Before creating new classes, check:
Example:
Pattern found: bg-indigo-500 hover:bg-indigo-700 px-6 py-3 rounded-lg text-white
Check: Does .button-primary already exist? YES
Solution: Use .button-primary instead of creating new class
Decision for each pattern:
Action: Create new semantic classes in styles/components.css for patterns that need extraction
For each pattern being extracted:
@applyExample extraction:
Before (in markup):
<button class="bg-indigo-500 hover:bg-indigo-700 px-6 py-3 rounded-lg text-white transition-all duration-200">
Click me
</button>
After (in components.css):
/* Primary button - Main call-to-action button with hover states
Usage: <button className="button-primary">Click me</button> */
.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;
}
Use Edit tool to add each new class to components.css
Action: Ensure all new/refactored classes have dark: variants
For each class created in Step 4:
dark: variants for backgroundsdark: variants for text colorsdark: variants for bordersPattern:
.component {
@apply bg-white dark:bg-gray-800;
@apply text-gray-900 dark:text-white;
@apply border-gray-200 dark:border-gray-700;
}
Action: Replace inline styles and utility classes with semantic class names
For each file using the old pattern:
Example:
Before:
<button class="bg-indigo-500 hover:bg-indigo-700 px-6 py-3 rounded-lg text-white">
Click me
</button>
After:
<button class="button-primary">
Click me
</button>
Handle custom classes:
<!-- If there were additional custom classes, preserve them -->
<button class="button-primary w-full mt-4">
Click me
</button>
Track changes:
Action: Add test coverage for refactored components
Static CSS test in styles/__tests__/components.test.ts:
it('should have button-primary class', () => {
const content = readFileSync('styles/components.css', 'utf-8');
expect(content).toContain('.button-primary');
});
it('should have dark mode variants in button-primary', () => {
const content = readFileSync('styles/components.css', 'utf-8');
expect(content).toContain('dark:bg-indigo');
});
Component rendering test (if applicable):
it('applies button-primary class after refactor', () => {
render(<Button variant="primary">Click</Button>);
expect(screen.getByRole('button')).toHaveClass('button-primary');
});
Run tests to ensure they pass:
npm test
Action: Ensure all refactored classes have documentation
Documentation includes:
Example:
/* Primary button - Main CTA button (refactored from inline utilities)
Usage: <button className="button-primary">Click me</button>
Replaces: bg-indigo-500 hover:bg-indigo-700 px-6 py-3 rounded-lg text-white */
.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;
}
Action: Ensure visual output and behavior match the original
Verification steps:
Run tests (if project has them):
npm test
Visual inspection (if possible):
Check for regressions:
If behavior changed:
Behavior must be preserved - refactoring should be visually neutral
When all checklist items are completed:
Generate a refactoring summary. The report must include these sections (use real data from the actual files changed — never invent numbers):
dark: variantsSuggest next steps:
Offer validation: "Would you like me to validate the refactored CSS using the css-development:validate skill?"
What SKILL.md sets; muted values are Claude Code's defaults
css-development@2389-research is listed by 2389-research/claude-plugins — review the source before installing
npx claudepluginhub 2389-research/claude-plugins --plugin css-development4 skills in this plugin
/create-componentcss-development:create-componentCreates new styled UI components using semantic Tailwind class names, @apply composition, dark mode variants, and test coverage. Use when adding a new CSS component, creating a styled button/card/form-field, or wiring up dark mode for a new UI element./css-developmentHandles CSS and Tailwind development — semantic class naming, @apply composition, dark mode by default, component creation, refactoring inline/utility styles, and CSS audits. Use when working with CSS, Tailwind, @apply, component styling, or dark mode. Sub-skills available: css-development:create-component, css-development:refactor, css-development:validate./