tailwind-optimizer

Optimize Tailwind CSS usage — detect unused classes, identify opportunities for @apply extraction, audit responsive design, and reduce bundle size.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "tailwind-optimizer" with this command: npx skills add charlie-morrison/tailwind-optimizer

Tailwind Optimizer

Optimize Tailwind CSS usage by detecting unused utilities, identifying extraction opportunities, auditing responsive design consistency, and reducing CSS bundle size. Analyzes config, class usage patterns, and design system adherence.

Usage

"Optimize my Tailwind CSS setup"
"Find unused Tailwind classes"
"Audit responsive design coverage"
"Check my Tailwind config for issues"

How It Works

1. Configuration Audit

cat tailwind.config.js 2>/dev/null || cat tailwind.config.ts 2>/dev/null
cat postcss.config.js 2>/dev/null

Check:

  • Content paths cover all template files
  • Theme extension vs override (prefer extend)
  • Unused plugins loaded
  • Custom colors/spacing consistency
  • Dark mode strategy (class vs media)
  • Prefix configured for embedding in existing CSS

2. Class Usage Analysis

# Most used utilities
grep -roh 'class[Name]*="[^"]*"\|className={[^}]*}' src/ | sort | uniq -c | sort -rn | head -20
# Find long class strings (extraction candidates)
grep -rn 'class[Name]*="[^"]*"' src/ | awk -F'"' '{print NF-1, length($2), $0}' | sort -rn | head -10

Detect:

  • Classes used only once (potential dead code)
  • Repeated class combinations (extract to @apply or component)
  • Conflicting utilities (e.g., text-red-500 text-blue-500)
  • Arbitrary values that should be in theme config
  • !important overrides indicating specificity issues

3. Design System Adherence

  • Using theme values vs arbitrary values (w-[137px] vs w-36)
  • Consistent spacing scale usage
  • Color palette adherence (no off-brand colors)
  • Typography scale consistency
  • Border radius consistency

4. Responsive Design

  • Mobile-first approach (base styles for mobile, md: for desktop)
  • Missing breakpoints on layout components
  • Inconsistent responsive patterns across pages
  • Hidden elements that should use sr-only for accessibility
  • Container width and padding consistency

5. Bundle Optimization

  • Purge/content configuration catching all files
  • JIT mode enabled (v3+ default)
  • Unnecessary variants enabled
  • Large custom plugins adding unused CSS
  • Component library classes not tree-shaken

6. Extraction Recommendations

When a class combination appears 3+ times:

/* Before: repeated in 5 components */
<button className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium">

/* After: extracted */
@layer components {
  .btn-primary {
    @apply px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium;
  }
}

Output

## Tailwind CSS Optimization Report

**Version:** Tailwind 4.0 | **Unique classes:** 847
**CSS output:** 34KB (gzipped: 8KB)

### 🟡 Improvements (5)
1. **12 extraction candidates** — repeated class combos (3+ times)
   Top: `flex items-center gap-2` (23 times) → extract to `.flex-row-center`
2. **34 arbitrary values** could use theme tokens
   `text-[#1a1a1a]` → `text-gray-900` (already in palette)
3. **Missing responsive on 8 layout components** — desktop-only layouts
4. **3 conflicting utilities** — `p-4 px-6` (px overrides p's horizontal)
5. Content config missing `*.mdx` files (MDX pages unstyled)

### ✅ Good Practices
- JIT mode with proper content paths
- Consistent use of theme spacing scale
- Dark mode via class strategy (allows user preference)
- CSS output is small (8KB gzipped)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

TailwindCss Complete Documentation

Complete Tailwind CSS documentation. Use when working with Tailwind CSS utility classes, responsive design, dark mode, animations, custom configurations, plugins, or styling questions. Covers all utility classes, modifiers, configuration options, and best practices.

Registry SourceRecently Updated
2K0Profile unavailable
Coding

Frontend Architecture Pro

Provide technical UX architecture and CSS systems to establish design tokens, layout frameworks, component structure, responsive breakpoints, and theme toggles.

Registry SourceRecently Updated
1580Profile unavailable
Coding

UI Designer

Design and improve UI components and systems with pixel-perfect, accessible, scalable designs including tokens, libraries, theming, and handoff specs.

Registry SourceRecently Updated
1890Profile unavailable
Security

Frontend Design Pro — 专业前端设计规范

前端设计质量提升 skill。让 AI 生成的 UI/前端代码更专业,避免常见设计反模式。 参考 impeccable 项目的设计语言规范,提供 audit/polish/critique 等设计审查命令。 触发词:/audit /polish /critique /colorize /animate /bold...

Registry SourceRecently Updated
5.8K11Profile unavailable