Repair code so it follows a StyleKit style
stylekit_repair_codeRewrite code that drifts from a style, using the style's own tokens as replacements. Use this instead of hand-editing class names after stylekit_lint_code reports violations.
Every applied rewrite comes from the style's tokens, never from a guess: variants (dark:, md:, hover:) are preserved, multi-class replacements are deduplicated, and string literals inside cn()/clsx() expressions are rewritten while variable references and interpolation spans are left untouched. JSX/HTML class attributes, template literals, and a bare class string are all handled. Spacing, layout and structure are never changed.
Args:
slug (string): style identifier.
code (string, 1-100000 chars): source to repair.
Returns JSON: { slug, code, edits: [{ from, to, line }], unfixed: [{ className, line, reason }], before, report, origin, contentSource, fallbackReason? }. Apply the returned code as-is, then review any entries in unfixed yourself — the rules flagged them but no concrete replacement exists.
Examples:
"make this hero match neo-brutalist" -> slug: "neo-brutalist", code: "<section className="rounded-2xl shadow-2xl">"
If edits is empty and before.status is "pass", the code already matched. Do not invent further changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Source code or class string to repair | |
| slug | Yes | Style slug, e.g. 'glassmorphism' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| slug | Yes | ||
| edits | Yes | ||
| before | Yes | ||
| origin | Yes | ||
| report | Yes | ||
| unfixed | Yes | ||
| contentSource | Yes | ||
| fallbackReason | No |