From harness-claude
Applies codemods to replace hex, font-family, and px-spacing literals with design token references based on DRIFT findings. Dry-run support included.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:align-design-systemThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Apply codemods for safe DRIFT-T001/T002/T003 token-bypass findings (replace hex / font-family / px-spacing literals with token references) and emit precise suggestions for DRIFT-T004 (deprecated tokens) and all DRIFT-P\* (primitive adoption). The FIX half of design-pipeline sub-project #1, paired with detect-design-drift.
Apply codemods for safe DRIFT-T001/T002/T003 token-bypass findings (replace hex / font-family / px-spacing literals with token references) and emit precise suggestions for DRIFT-T004 (deprecated tokens) and all DRIFT-P* (primitive adoption). The FIX half of design-pipeline sub-project #1, paired with detect-design-drift.
--dry-run) and review the diff before writingRead project configuration. Check harness.config.json for:
design.strictness — passes through to detect-design-driftdesign.audit.driftDetection.* — passes through to detectIn standalone mode (default): invoke detect-design-drift internally with the same project root + strictness; receive the full DriftFinding[].
In pipeline mode: read .harness/handoff.json and pull pipeline.driftFindings (pre-classified by the orchestrator). Honor pipeline.fixBatch if present to limit application to a specific subset of findings (the orchestrator may apply fixes in batches across iterations).
For each finding, the pre-flight classifier inspects file context and chooses:
$value EXACTLY (no rounding) AND not in an arithmetic expression. Otherwise → suggestion.$description.<button> ⇄ <Button> is genuinely ambiguous (event handlers, ref forwarding, class merging) — codemods deferred to v1.x.Token import discovery recognizes three forms:
import { tokens } from '...'import tokens from '...'const tokens = require('...')For each finding classified as safe-codemod:
line + evidence.snippet..ts / .tsx / .js / .jsx → tokens.<dotted.path>.css / .scss → var(--<dotted-path-as-kebab>)FixOutcome.applied with a structured diff (file / line / before / after).--dry-run: compute the diff but DO NOT write to disk.kind: 'skipped-unsafe', reason: 'file changed since finding'.For each finding classified as suggestion: emit a human-readable description plus a preview of the suggested change. No file mutation.
FixOutcome[] into a summary: counts by kind (applied / suggestion / skipped / failed) plus files modified and duration.catalog of finding codes that produced codemods and codes that produced suggestions.pipeline.fixesApplied: FixOutcome[] back to .harness/handoff.json so the orchestrator can re-verify only the affected findings on the next loop iteration.harness align-design-system — the CLI entry point. --dry-run for preview; --write is the default. Standard --json / --verbose / --quiet flags.harness align-design-system --mode pipeline — orchestrator-driven mode. Reads pre-classified findings from handoff.json; writes outcomes back.harness align-design-system --revert — inverse-applies the most-recent batch recorded at .harness/align/last-batch.json. Skips files edited externally since the apply (content-hash check). Idempotent: a second revert on the same batch is a no-op because the file no longer matches the recorded post-apply text.mcp__harness__align_design_system — MCP tool for agent consumption. Same input/output shape as the function call.detect-design-drift — soft dependency. Standalone mode invokes detect internally; pipeline mode trusts the orchestrator to have done it.harness check-design — composes detect (as 3rd verifier) into a single-pass design check. align is the matching FIX step; together they form the DETECT → FIX cycle that the (future) #5 orchestrator will loop.DesignConstraintAdapter — align does NOT write to the graph. The graph already tracks VIOLATES_design edges (the findings). Re-running detect after align shows the delta — no separate fix-edge needed.See docs/changes/design-pipeline/align-design-system/proposal.md for the full 34 success criteria. Highlights:
safe-codemodpipeline.driftFindings from handoff.json; standalone mode runs detect internallypipeline.fixesApplied back to handoff.json--dry-run produces identical FixOutcome shapes but never writes files--revert re-applies the inverse of the most-recent fixesApplied batch; no-op when the file has been edited externally since the applyInput:
design-system/tokens.json has:
{ "color": { "brand": { "primary": { "$type": "color", "$value": "#0066cc" } } } }
src/Card.tsx has:
import { tokens } from '@/design-system/tokens';
const styles = { color: '#0066cc' }; // raw literal where token exists
Output:
src/Card.tsx
✓ DRIFT-T001:2 — Hex color "#0066cc" should use a token reference instead of a raw literal
before: const styles = { color: "#0066cc" };
after: const styles = { color: tokens.color.brand.primary };
Summary: 1 applied, 0 suggestions, 0 skipped, 0 failed (1 files modified, 5ms)
Same finding as above, but src/Card.tsx does NOT import tokens. align emits a suggestion instead:
src/Card.tsx
? DRIFT-T001:2 — Hex color "#0066cc" should use a token reference instead of a raw literal
Summary: 0 applied, 1 suggestions, 0 skipped, 0 failed (0 files modified, 3ms)
(Run with --verbose to see the suggestion text and the classifier's reason for downgrading.)
Input:
design-system/DESIGN.md registers Button in ## Component Registry. src/SaveButton.tsx has:
export const S = () => <button onClick={() => save()}>Save</button>;
Output:
src/SaveButton.tsx
? DRIFT-P001:1 — Raw <button> element where the registered component "Button" should be used
(use --verbose to see prop-translation suggestion)
v1 never auto-applies primitive adoption — prop translation across <button> ⇄ <Button> is the kind of judgment-call that benefits from a human or LLM review.
After a write run, the applied diffs (plus a SHA-256 of each post-apply file) are persisted to .harness/align/last-batch.json. Running harness align-design-system --revert reads that batch and inverse-applies each diff:
src/Card.tsx
✓ DRIFT-T001:2 — Hex color "#0066cc" should use a token reference instead of a raw literal
before: const styles = { color: tokens.color.brand.primary };
after: const styles = { color: "#0066cc" };
Summary: 1 reverted, 0 suggestions, 0 skipped, 0 failed (1 files modified, 4ms)
If the file has been edited externally between apply and revert (the SHA-256 doesn't match), every entry for that file is skipped with skipped-unsafe / reason: file changed externally since apply. A second revert on the same batch is a no-op for the same reason — the file's post-revert content no longer matches the recorded post-apply text.
classifyFinding. If the classifier returns suggestion, NO file write occurs — even for the same finding code in the same file.pipeline.driftFindings field is present. Empty handoff = empty run.## Token Primary Resolution Overrides (v1.x), OR pick one in the source manually and re-run.git checkout <file>. If the same input repeatedly corrupts, report the case — pre-flight classifier rules are conservative by design.pipeline.driftFindings field: align exits cleanly with empty outcomes. The orchestrator's contract is to write the field BEFORE invoking align.--dry-run shows fixes you don't want applied: scope with --files <glob> to apply only specific files, or invoke align in pipeline mode with a curated pipeline.fixBatch list.harness align-design-system --revert. It reads .harness/align/last-batch.json, content-hash-checks each file, and inverse-applies. Files edited since the apply are skipped (no silent corruption); recover via git checkout <file> if the content-hash check blocks revert and the prior commit is still in history.v1 — in implementation. See:
docs/changes/design-pipeline/align-design-system/proposal.mddesign-pipeline sub-project #1 (align half) in docs/roadmap.mddetect-design-drift (detect half — shipped PR #396)npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeDetects hardcoded values where design tokens exist and raw HTML primitives where registered components should be used. Reports findings without modifying source.
Audits web projects for design drift in colors, spacing, typography; extracts values to tokens and refactors Tailwind, CSS Modules, styled-components, MUI, Chakra UI codebases to use design system.
Identifies system-wide drift in design systems: components diverging from specs, local token overrides, forked patterns across teams. Classifies severity, origins, and generates response recommendations.