plugins/style-agent/skills/css-to-class/SKILL.md
Use when the developer wants to extract CSS utility classes from an HTML element into a single named class — collapsing utility soup into one semantic selector.
npx skillsauth add shawn-sandy/acss-plugins css-to-classInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Convert a multi-class HTML element or plain class string into a single, semantically named CSS class. Resolves each utility token to its actual property/value declarations by grepping all .css files in the user's project — works with plain CSS, SCSS output, Tailwind, or any other utility-first workflow.
| Form | Example |
|---|---|
| HTML element | <div class="testimonial flex-grid py-8 items-center" data-flex-grid> |
| Plain class list | testimonial flex-grid py-8 items-center |
| Quoted string | "flex py-4 items-center justify-between" |
[a-z][a-z0-9-]*).name is supplied, apply this sanitisation pipeline in order:
-.[a-z0-9-].[a-z].AskUserQuestion for a valid name instead of emitting an invalid identifier. Warn the user whenever any coercion occurred.name is omitted: auto-generate via the algorithm below. When the result is ambiguous (all-utility list, or generated name is a single token under 4 chars), ask via AskUserQuestion with the generated name pre-filled as the suggestion rather than silently picking.py-, px-, pt-, pb-, pl-, pr-, mt-, mb-, ml-, mr-, mx-, my-, m-, p-, gap-, text-, bg-, border-, rounded-, w-, h-, min-, max-, flex-, grid-, col-, row-, items-, justify-, self-, place-, order-, z-, opacity-, shadow-, ring-, sr-, not-sr-.flex, hidden, block, inline) also count as utility.-N numeric suffix.-, lowercase. Collapse any double -. Strip leading/trailing -.custom-class and warn.Parse input. Accept a pasted HTML snippet or a bare class string (with or without surrounding quotes). Use a regex to extract the class="…" value when HTML is present. Tokenise and deduplicate.
Determine the class name. Apply the Name rules above. When auto-generating and the class list is all-utility or the generated name is ambiguous, use AskUserQuestion with the suggestion pre-filled.
Discover CSS files. Run:
find . -name "*.css" -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*"
Collect the resulting file list. If no .css files are found, note this and all tokens will be unresolved.
Resolve declarations. For each class token, apply CSS identifier escaping rules to build its selector form before grepping:
: → \:, & → \&, . → \., % → \%, etc.2xl:flex becomes \32 xl\:flex in its selector form, where \32 is the hex escape for 2 and the space terminates the escape sequence.
This correctly handles Tailwind variant tokens (hover:bg-red-500 → .hover\:bg-red-500) and breakpoint-prefixed tokens (2xl:* → .\32 xl\:*). Then grep the discovered files for a selector containing .<escaped-token> followed by any of: whitespace, {, ,, or :. Extract the property/value declarations from the matching block.Emit the CSS class block. Output a single class with:
@media, @supports, @layer) in the source file must be emitted with their at-rule wrapper preserved as a nested block — do not strip the context, or the declarations will stop working at the intended breakpoint or feature query. Group multiple tokens that share the same at-rule condition into one nested block./* <token>: add declarations manually */ placeholder comment, preserving its relative position.Example for <div class="testimonial flex-grid py-8 items-center">:
/* extracted: testimonial flex-grid py-8 items-center */
.testimonial-grid {
/* testimonial: add declarations manually */
/* flex-grid: add declarations manually */
padding-block: 2rem;
align-items: center;
}
Emit the refactored HTML. Replace the full class="…" value with the new single class name. Preserve all other attributes unchanged (including data-*, id, aria-*).
Print a summary:
development
Internal orchestrator for /kit-create, /kit-list, /kit-sync, /kit-update and Form/HTML/Style-Tune modes. Per-component generation lives in component-<name> skills; do not auto-trigger for component requests.
data-ai
Use when the user asks to generate, create, or scaffold a Table — accessible data table with caption, scope headers, responsive scroll wrapper, and sortable column support.
tools
Use when the user asks to generate, create, or scaffold a Popover — accessible tooltip/popover using the Popover API with focus trap, aria-expanded, and light-dismiss.
tools
Use when the user asks to generate, create, or scaffold a Nav — accessible navigation landmark with aria-label, current-page link marking, and horizontal/vertical layout.