# Class extraction guard

> Class extraction guard is an open-source agent skill for developer tools. Flags the same long utility-class string repeated across files so it gets extracted. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ivy00johns/Skill-Madness/tree/main/skills/workflows/class-extraction-guard
- **Repository:** https://github.com/ivy00johns/skill-madness
- **GitHub stars:** 12
- **License:** MIT
- **Skill name:** class-extraction-guard
- **Collection:** https://github.com/ivy00johns/Skill-Madness
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

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".

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs Python scripts](https://github.com/ivy00johns/Skill-Madness/tree/HEAD/skills/workflows/class-extraction-guard)
- [Asks for: Bash, Read, Write, Edit, Glob, Grep](https://github.com/ivy00johns/Skill-Madness/blob/HEAD/skills/workflows/class-extraction-guard/SKILL.md)
- [No network calls found in its scripts](https://github.com/ivy00johns/Skill-Madness/tree/HEAD/skills/workflows/class-extraction-guard)
- [License: MIT](https://github.com/ivy00johns/Skill-Madness/tree/HEAD/skills/workflows/class-extraction-guard)

## Features

- **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

## Install

### Claude Code

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

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

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

```sh
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.

### Codex

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

```sh
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.

### Cursor

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

```sh
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.

### Gemini CLI

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

```sh
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.

### VS Code

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

```sh
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.

### Other agents

Get the folder:

```sh
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.

## 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.

## Alternatives

- [Design token guard](https://ai-powered.com/skills/design-token-guard): Design token guard is an open-source agent skill for developer tools.
- [Code simplifier](https://ai-powered.com/skills/code-simplifier): Code simplifier is an open-source agent skill for developer tools.
- [Odylith code hygiene guard](https://ai-powered.com/skills/odylith-code-hygiene-guard-odylith): Odylith code hygiene guard is an open-source agent skill for developer tools.
- [Constraint driven development](https://ai-powered.com/skills/constraint-driven-development): Constraint driven development is an open-source agent skill for developer tools.
- [Code](https://ai-powered.com/skills/code): Code is an open-source agent skill for developer tools.
- [Dead code audit](https://ai-powered.com/skills/dead-code-audit): Dead code audit is an open-source agent skill for developer tools.
- [Clean code](https://ai-powered.com/skills/clean-code): Clean code is an open-source agent skill for developer tools.
- [Dead code cleanup edho ferdian](https://ai-powered.com/skills/dead-code-cleanup-edho-ferdian): Dead code cleanup edho ferdian is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/class-extraction-guard
