Skip to content
Skill

Class extraction guard

Flags the same long utility-class string repeated across files so it gets extracted

Class extraction guard is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
Python
Platforms
Claude Code, Codex, Cursor
GitHub stars
12
Last commit
License
MIT
Listing updated

Similar skills

About Class extraction guard

Class extraction guard is a source-level check for frontend code that repeats long runs of utility classes inline across many files instead of pulling them into a named class, CSS component or shared UI component. It runs a Python detector that normalizes the order of class tokens in class attributes and class-string helpers, then reports combos of four or more utilities that appear at three or more call sites. The default setup reports only at warning severity, and the detector can also be configured to flag duplicated CSS declaration blocks, single overly long class strings and extra utilities added to elements that already have a named class.

The skill describes how to use the detector in a project. It supports a JSON output mode with exit codes for gating, a staged-files mode for pre-commit hooks, and a baseline snapshot so an existing codebase only reports new duplication. It also includes a shared-layout check for copied header, nav and footer markup, and it explains how to fall back to a manual grep-based scan when no shell is available, marking any check that cannot run as blocked rather than passed.

The skill expects Python 3.9 or newer, using only the standard library, and it works alongside a design token guard that checks which values styling uses. Its bundled resources include a starter config, a pre-commit hook, a CI step and reference notes on the extraction convention.

When your agent uses it

Source-level gate for utility-class soup: the same long run of utility classes copy-pasted across files instead of extracted into a named class or component. Use when frontend work touches class markup, before calling UI work done, or as a wave gate. Sibling of design-token-guard (that checks which values; this checks how they're organized). Trigger on "utility soup", "repeated tailwind classes".

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 11 files (58 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the skill-madness plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add ivy00johns/Skill-Madness
/plugin install skill-madness@skill-madness

Or copy only this skill to ~/.claude/skills/class-extraction-guard:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/class-extraction-guard &&
cp -R "$tmp/skills/workflows/class-extraction-guard" ~/.claude/skills/class-extraction-guard &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/class-extraction-guard inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/class-extraction-guard to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/class-extraction-guard &&
cp -R "$tmp/skills/workflows/class-extraction-guard" ~/.agents/skills/class-extraction-guard &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/class-extraction-guard inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/class-extraction-guard to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/class-extraction-guard &&
cp -R "$tmp/skills/workflows/class-extraction-guard" ~/.cursor/skills/class-extraction-guard &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/class-extraction-guard inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/ivy00johns/Skill-Madness.git --path skills/workflows/class-extraction-guard

Or copy the folder to ~/.gemini/skills/class-extraction-guard yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/class-extraction-guard:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/class-extraction-guard &&
cp -R "$tmp/skills/workflows/class-extraction-guard" ~/.copilot/skills/class-extraction-guard &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/class-extraction-guard inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git

Then copy Skill-Madness/skills/workflows/class-extraction-guard into your agent's skills folder as class-extraction-guard. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Repeated class detection
Finds the same order-normalized utility combo appearing at several call sites in a codebase.
Configurable thresholds
Sets minimum utility counts and repeat counts, and can enable extra rules per project.
CSS duplicate blocks
Optionally groups simple class rules that share identical ordered declarations.
Baseline ratchet mode
Records today's duplication so only newly introduced repeats are reported.
Staged and CI modes
Scans only git-staged files for pre-commit hooks and emits JSON for CI gates.
Shared layout check
Flags copied header, nav and footer markup across authored source files.

Good for

  • Scan a frontend repo for Tailwind class strings copied across many components
  • Check staged files for repeated utility classes before committing
  • Set up a baseline so an existing project only fails on new class duplication
  • Extract a repeated button or card class combo into a shared component
  • Review CSS for duplicate declaration blocks across stylesheets

Class extraction guard FAQ

What does the skill need to run the detector?

It requires Python 3.9 or newer. The scripts use only the standard library.

When does the skill trigger?

It is meant for frontend work that touches class markup, before calling UI work done, or as a wave gate. Trigger phrases include utility soup and repeated tailwind classes.

Does Class extraction guard change my code?

The detector reports findings. Its description says it reads source and produces reports, with optional baseline and config files written to the project.

How does Class extraction guard differ from design-token-guard?

Design-token-guard checks which values styling uses, while this skill checks how utility classes are organized across files.

How do I install Class extraction guard in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/class-extraction-guard to use it in all your projects, or to .claude/skills/class-extraction-guard in one project. Or install the skill-madness plugin, which includes it: /plugin marketplace add ivy00johns/Skill-Madness, then /plugin install skill-madness@skill-madness.

Does Class extraction guard run scripts?

Yes. It runs Python scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Class extraction guard?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Class extraction guard?

The closest alternatives to Class extraction guard are Design token guard, Code simplifier, Odylith code hygiene guard, Constraint driven development and Code.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from ivy00johns/Skill-Madness

  1. Finds merged and stale git branches, then deletes them only after your confirmation

    • Open source
    • 12 GitHub stars
    • Developer tools
  2. Finds and removes git worktrees whose changes are already merged into main

    • Open source
    • 12 GitHub stars
    • Developer tools
  3. Bulk-scans a skill ecosystem for consistency, quality gaps and ownership conflicts

    • Open source
    • 12 GitHub stars
    • Developer tools
  4. Runs a single-skill quality review covering structure, triggering and output checks

    • Open source
    • 12 GitHub stars
    • Developer tools
  5. Turns skill review or audit reports into a prioritized list of concrete SKILL.md fixes

    • Open source
    • 12 GitHub stars
    • Developer tools
  6. Applies planned edits to SKILL.md files, validates them, and offers to sync

    • Open source
    • 12 GitHub stars
    • Developer tools