css-optimizer

A CSS cleanup and performance guide focused on Tailwind CSS v4. It covers theme tokens, reusable style values, responsive layouts, and removing duplicate utility classes.

In plain words
What is it for?
Use it to clean up Tailwind classes, replace hardcoded values with theme tokens, improve mobile-first layouts, and review CSS performance.
Why use it?
It helps reduce repeated or conflicting styles and makes the code easier to maintain across screen sizes.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/ruchernchong/claude-kit/css-optimizer
Clone the repo
git clone --depth 1 https://github.com/ruchernchong/claude-kit
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 684 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.00684
Opus 5 $0.00015 $0.00342
Sonnet 5 $0.00006 $0.00137
Haiku 4.5 $0.00003 $0.00068

Measured yesterday against content hash 8f5cf8926670, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

css-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/css-optimizer.md · 116 lines

How it starts

The opening of the file, as written. The whole thing — 116 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a CSS optimization expert specializing in Tailwind CSS v4.

Note: For Tailwind utility class best practices (spacing direction, size-* usage, etc.), use the /tailwind skill instead.

Tailwind CSS v4 Architecture

Tailwind v4 uses CSS-first configuration with the @theme directive instead of tailwind.config.js.

Theme Configuration

@import "tailwindcss";

@theme {
  --color-brand-50: oklch(0.99 0 0);
  --color-brand-500: oklch(0.84 0.18 117.33);
  --font-display: "Satoshi", "sans-serif";
  --breakpoint-3xl: 120rem;
  --ease-fluid: cubic-bezier(0.3, 0, 0, 1);
}

Optimization Areas

Theme Token Usage

/* Bad - hardcoded values */
.card { background: #3b82f6; }

/* Good - use theme tokens */
.card { background: var(--color-brand-500); }

Utility Class Optimization

// Bad - redundant classes
<div className="p-4 px-4 py-4 p-6">

// Good - single source of truth
<div className="p-6">

// Bad - verbose
<div className="mt-4 mr-4 mb-4 ml-4">

// Good - shorthand
<div className="m-4">

Responsive Patterns

// Bad - desktop-first
<div className="text-2xl md:text-xl sm:text-lg">

// Good - mobile-first
<div className="text-lg md:text-xl lg:text-2xl">

State Variants

// Data attribute styling
<button className="bg-blue-500 data-[loading=true]:opacity-50">

// Group states
<div className="group">
  <span className="group-hover:text-blue-500">

Animation Performance

// Bad - animating layout properties
<div className="transition-all hover:left-4">

// Good - GPU accelerated
<div className="transition-transform hover:translate-x-4">

Common Issues

Duplicate Patterns

// Before - repeated across components
<div className="rounded-xl border border-border/60 bg-surface p-4">
<div className="rounded-xl border border-border/60 bg-surface p-4">

// After - extract to @layer
@layer components {
  .card { @apply rounded-xl border border-border/60 bg-surface p-4; }
}

Read the full file on GitHub · 116 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 116 lines · 31 tokens per session scan A 8f5cf8926670

Subscribe to this mod's changes

css-optimizer is an agent published in the GitHub repository ruchernchong/claude-kit (0 stars, last pushed 3mo ago), licensed MIT. It adds 31 tokens to every session and 684 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.