/claudemd:claudemd-design-adoptfrom claudemd
Generate a fact-based DESIGN.md from a UI project's existing design tokens and wire it into project CLAUDE.md, so agents stop inventing colors and spacing. Use when the user asks to configure design specs for agents (配置设计规范 / 设计规范), or a UI project has design tokens but no DESIGN.md. Modes — check, remove.
Ships in claudemd. Installing the plugin adds it to Claude Code.
Usage: /claudemd-design-adopt | /claudemd-design-adopt check | /claudemd-design-adopt remove
Run: node ${CLAUDE_PLUGIN_ROOT}/scripts/design-detect.js --json (add --cwd=PATH to target another dir). The detector is stateless — it reads the filesystem and prints a verdict, writing nothing.
If --cwd is passed and names something that is not an existing directory (or is empty), the detector exits 2 with a stderr line instead of printing a verdict. That is not a finding about the project — report the bad path and stop; do not relay it as no-ui.
no-ui / ui-no-tokens → report one line (nothing to adopt: <verdict>) and STOP. Never create DESIGN.md for a token-less project — generation would require inventing values, which this command forbids.configured → report "already wired" + the DESIGN.md path. Offer check instead; regenerate only if the user explicitly asks.adoptable / unwired → continue.error → report the failure; do not write anything.check mode (no writes)Read the existing DESIGN.md; for every repo-file reference in it, verify the file exists. Report resolvable vs broken pointers, then STOP.
remove modeDelete the <!-- claudemd-design:begin … <!-- claudemd-design:end --> block from project CLAUDE.md (everything else untouched; show the diff first). Do NOT delete DESIGN.md — report that it stays for the user to remove.
Read every tokenSources[].path from step 0 (first ~200 lines each), plus — when present — whatever injects them (vite css.preprocessorOptions.additionalData, tailwind content, the main.* style import chain). You are extracting FACTS: token names, semantic-color variables, spacing scale, radii, fonts, dark-mode mechanism, reusable mixins / utility classes, contrast annotations.
Contract — every line must trace to something Read in step 1:
Header: values live in the source files ("以 <file> 为准"); DESIGN.md never duplicates full value tables (single source of truth, no drift).
事实源与加载机制: each token-source path + its load mechanism only if verified (e.g. vite additionalData global injection ⇒ "$vars/mixins are available in every SFC — do not @use the file again").
硬规则 — evidence-gated menu. Include ONLY rules whose evidence appeared in step 1:
html.dark / prefers-color-scheme / darkMode: 'class') + "develop and verify in that theme"No rule without its evidence. No generic boilerplate — naming conventions, import order, commit rules do NOT belong in DESIGN.md.
Identity table (≤8 rows) of parsed brand values, with the "values live in <file>" disclaimer.
Domain color semantics are not derivable (e.g. finance 红涨绿跌): append <!-- TODO: 领域色彩语义(如涨跌色)请人工确认 --> — unless a source comment states the rule, in which case cite it.
Write the doc in the language of the project's existing CLAUDE.md (fall back to the user's language).
Insert — or replace, if a prior block exists — next to the project's CLAUDE.md content:
<!-- claudemd-design:begin v1 -->
## Design context
- Token source of truth: <paths> — read before any UI change; entry point: `DESIGN.md`.
- <top 1–2 hard rules from step 2>
<!-- claudemd-design:end -->
No CLAUDE.md → create one containing only this block. Placement: repo root; when step 0 reported monorepoPkg, put DESIGN.md in that package root and the block in the CLAUDE.md nearest to it.
Show the full DESIGN.md draft + the CLAUDE.md diff BEFORE writing, ask once, then write both files in the same turn. This gate always applies — these files steer every future session (LLM-visible context).
Re-run node ${CLAUDE_PLUGIN_ROOT}/scripts/design-detect.js --json and cite verdict: configured as the completion evidence. Report: files written, token sources cited, rules included vs skipped (with the missing-evidence reason), and whether the domain-semantics TODO was left for the user.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
11 commands in this plugin
/claudemd-auditAggregate claudemd rule-hits over the last N days. Shows top banned patterns, hook deny counts, per-spec-section heatmap, and bypass-escape-hatch usage./claudemd-clean-residueFind and remove claudemd leftovers — test sentinels and sandboxes in $TMPDIR, tool-exhaust in ~/.claude/tmp older than TMP_RETENTION_DAYS (default 7), orphaned per-session state files, and headless-probe project dirs. Dry-run by default; `--apply` deletes./claudemd-doctorHealth check of the claudemd install — dependencies, spec and hook drift, settings.json, backups, hook fail-opens and memory hygiene. Supports --prune-backups=N and --ack-fail-open.npx claudepluginhub sdsrss/claudemd --plugin claudemd