Tailwind cleanup

From berkcangumusisik/claude-code-practices · View interactive version

Tailwind cleanup is an AI agent skill from the GitHub repository berkcangumusisik/claude-code-practices. Removes unused Tailwind classes, extracts repeated class patterns into components

How to use this skill

Skill file

Tailwind CSS Cleanup

Target: $1 (or src/ if not specified)

1. Find Unused Classes

npx tailwindcss --content "./src/**/*.{ts,tsx}" --input ./src/styles/globals.css --dry-run 2>/dev/null | grep "Removing"

2. Find Repeated Class Combinations

grep -rn 'className="' ${1:-src/} --include="*.tsx" | grep -oP 'className="[^"]+"' | sort | uniq -c | sort -rn | head -20

3. Extract Repeated Patterns

When the same 5+ class combination appears 3+ times, it should become:

4. Check for Anti-Patterns

5. Verify PurgeCSS config covers all dynamic class patterns:

// ❌ Dynamic classes get purged
const color = isError ? 'red' : 'green'
<div className={`text-${color}-500`} />

// ✅ Full class names are safe
const className = isError ? 'text-red-500' : 'text-green-500'

Report: N unused classes removed, N patterns extracted.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.