/harness-claude:harness:align-design-system runs instead · from harness-claude
Replaces hex, font-family, and px literals with design token references via codemods for DRIFT-T001/T002/T003 findings. Emits suggestions for DRIFT-T004 and DRIFT-P. Fix step in design drift remediation.
This skill never runs in Claude Code
It ships in harness-claude at agents/, but /harness-claude:harness:align-design-system (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
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 drift-remediation sub-project, 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) 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 applyThese are common rationalizations that sound reasonable but lead to incorrect results. When you catch yourself thinking any of these, stop and follow the documented process instead.
| Rationalization | Why It Is Wrong |
|---|---|
| "The token import is missing, but I can just add the import line and then apply the codemod." | Adding an import is its own ambiguity surface — named vs default vs barrel vs relative alias. The classifier deliberately downgrades to a suggestion when no import is present; synthesizing one turns a safe replacement into an unverified edit. |
"This literal is 13px and the nearest spacing token is 12px — close enough to snap it." | Non-exact px matches are a design decision, not a mechanical fix. T003 is safe-codemod only when the px matches a spacing token's $value EXACTLY. Rounding invents intent the tool has no authority to invent. |
"This raw <button> obviously maps to the registered <Button> — I'll translate the props and apply it." | Prop translation across <button> ⇄ <Button> is genuinely ambiguous (event handlers, ref forwarding, class merging). v1 ALWAYS emits a suggestion for DRIFT-P*; there is no codemod path, and auto-applying one produces broken markup. |
| "Two tokens share this hex value, but the brand one is clearly intended — I'll pick it and apply." | When multiple tokens match a value the classifier downgrades to a suggestion by design. Choosing "the obvious one" is exactly the judgment call the pre-flight gate refuses to make; the resolution belongs in DESIGN.md or the source, not a guess. |
| "The file changed since detect ran, but the finding's line still looks right — I'll apply anyway." | Applying against content that moved risks mutating the wrong span. The contract is to skip with skipped-unsafe / reason: file changed since finding; re-run detect to get fresh line positions instead of trusting a stale offset. |
Input:
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 initiative (align half) in docs/roadmap.mddetect-design-drift (detect half)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claude793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job