A Claude Code skill that tells you how far your codebase has drifted from its design system.
Type /ds-drift and get a report: an alignment score, a pass/review/fail gate, every finding with a file and line, and a comparison with your last report. It is built to catch the drift a coding agent introduces: components that do not exist, props that are made up, hex values that duplicate a token, controls with no accessible name.
It runs static checks only. No model calls, no API keys, no cost, and the same code gives the same result every time.
The HTML report is a local, self-contained file. Download summary image saves the card above as a PNG, and Download report as markdown saves the whole report, with every finding, as a .md file.
Every finding has a file, a line and a suggested fix. When a hardcoded value matches an existing token, the fix names the token.
It follows your system's light or dark setting.
A coding agent can write code that compiles, looks right in the browser, and still ignores your design system. It imports Modal from your UI package when the package has no Modal. It passes tone="danger" to a Button that has no such prop. It writes #2F6B4F when --color-brand already exists. Nothing breaks, so nobody notices, and a few weeks later the product no longer matches the system.
Linters do not know your components. Code review catches some of it. ds-drift checks the code against what your design system really exports and defines, and tells you exactly where it differs.
ds-drift is not tied to one design system, but it is not universal either. It works when:
- The app is React, in TypeScript or JavaScript (
.tsx,.ts,.jsx,.js). - The design system is imported from a module: an npm package (
@mui/material,@chakra-ui/react,@your-org/ui), a workspace package, or a path alias to a folder in the same repo. - That module ships TypeScript types, so the compiler can list its exports and read component props. If it does not, point
catalogFileat a JSON catalog instead (see docs/configuration.md).
Color and size checks do not depend on which design system you use, and token matching reads CSS custom properties and object-literal color tokens.
It does not cover Vue, Svelte, Angular or web components, design systems that are only a Tailwind config or CSS classes with no component package, or styling written in template strings (styled-components, Emotion css tagged templates).
| Dimension | Weight | What it finds |
|---|---|---|
| API fidelity | 25 | Components or types imported from your design system package that it does not export. Props passed to a component that it does not declare. |
| Token discipline | 15 | Hardcoded hex/rgb colors, hardcoded px/rem sizes (including unitless numbers such as padding: 20), and arbitrary utility values like w-[137px], in className, style, MUI sx props and .css/.scss files. |
| Imports | 10 | Imports from a competing UI library (MUI, Chakra, Ant Design, Radix and others) when your design system is something else. |
| Accessibility (static) | 10 | Controls without an accessible name, images without alt, click handlers on non-interactive elements, labels not tied to a control, invalid aria-*, positive tabIndex, bad anchors. |
It also reports design system adoption: the share of UI files that use your design system at all. A file that ignores the system is the worst case, because it passes every other check. Adoption only counts the folders the config scans, so the report lists which folders it counted and which UI folders it left out (see Where your components live).
The score is narrower than "how far the whole design system has drifted". It compares code with the design system package's component list and token values. It does not look at:
- documentation, design rules or guidelines
- Figma files, or whether Figma and code agree
- Storybook
- hand-built components that imitate a design system one (a custom button made from a
divis not recognised as a duplicate ofButton) - duplicate components
Treat it as one signal alongside keeping your docs, rules and Figma library in sync.
ds-drift works out the design system from componentsPkg, and counts adoption over the folders in the config. A project with shared components in several folders may need a config change:
- Check it: the report has a "Folders counted for adoption" section. It lists each folder with its UI files and how many use the design system, plus UI folders that were left out and why.
- Fix it: add folders to
includeif they were left out. Add the design system's own folders tocomponentsSrc(a list is fine) if they show up as consumers with 0% adoption. Or run/ds-driftfollowed by a sentence such asour shared components are in src/ui and src/shared, and Claude will update the config. - Or keep it simple: put shared components under one parent folder (
src/ui/,packages/ui/). People, tools and coding agents all find them more easily, and the config stays short.
Details and examples for every rule are in docs/checks.md.
You need Claude Code and Node.js 20 or newer.
git clone https://github.com/JDebDesign/ds-drift.git ~/.claude/skills/ds-driftThen open Claude Code in any project and run:
/ds-drift
On the first run in a project, the skill:
- Installs its own dependencies (a one-off
npm installinside the skill folder). - Inspects your repo and writes a
ds-drift.config.json(design system package, token file, allowed imports). It shows you what it wrote, and you can edit it. - Scans, then writes the reports to
docs/ds-drift/and opens the HTML.
Your project's own dependencies must be installed (node_modules present) so the design system package can be resolved and read.
| Command | What it does |
|---|---|
/ds-drift |
Scan the whole codebase. |
/ds-drift --since main |
Scan only the files changed since main. Use it right after an agent session. |
/ds-drift --label after-agent |
Add a suffix to the report file names. |
/ds-drift our components live in packages/shared-ui and src/components |
Add anything you want after the command, in plain words. Claude reads it and applies it: it updates ds-drift.config.json for layout or scope notes, and uses focus notes when it writes the interpretation. It shows you what it changed. |
You can mix flags and a note: /ds-drift --since main ignore the marketing folder.
--since reports are only compared with other --since reports, never with full scans, so the numbers stay comparable.
Everything is written to docs/ds-drift/ in your project. Commit it, and your drift history lives in git.
| File | Purpose |
|---|---|
<date>.md |
The report. Summary, interpretation, per-dimension table, what changed, hotspots, every finding. |
<date>.html |
A local page with filters and two download buttons: the summary as a PNG, and the full report as markdown. Never published or uploaded anywhere. |
<date>.json |
The data both are rendered from, and the baseline for the next comparison. |
Reports contain only paths relative to the project root, so they are safe to commit.
See a complete example in examples/demo/app/docs/ds-drift.
- Score (0 to 100) is a weighted mean of the dimensions that could be measured. A dimension that cannot be measured (for example no component catalog) shows
n/aand is left out, never counted as a pass. - Gate is the worst result across dimensions, not the average. Any component or type that does not exist makes it
fail. Any other finding makes itreview. No findings ispass. One invented component should not hide behind a high average. - Adoption is shown next to the score, not inside it.
- The score and the gate can disagree. A 94 with a
failgate means the average is high but at least one component or type does not exist. That is intentional: one invented component should never hide behind a good average. Open the report to see which finding failed the gate. Because each dimension score is a mean over files, a large codebase with a few findings can still round to 100 in that dimension, so read the finding counts next to the scores. - Change since the last report compares findings by a stable id (rule, file and symbol, never the line number), so moving code around does not make an old finding look new.
ds-drift.config.json lives in your project root. The only required field is componentsPkg.
{
"name": "pantry-shifts",
"componentsPkg": "@mui/material",
"tokensFile": "src/theme.ts",
"allow": { "imports": ["react", "react-dom"] },
"a11y": { "formContext": ["FormControlLabel"] }
}For a design system that lives in the same repo, or a CSS-variable token file, see the examples in docs/configuration.md, which also lists every field.
The repo ships with a tiny design system and an app with planted drift, plus the reports from a clean run and a drifted run.
git clone https://github.com/JDebDesign/ds-drift.git
cd ds-drift
npm install
cd examples/demo/app
../../../node_modules/.bin/tsx ../../../scripts/cli.ts scan --root .The new report is compared with the committed 2026-10-24-after one, so you will see a change of zero.
The scanner is a plain command line tool. Everything except the written interpretation works the same.
node_modules/.bin/tsx scripts/cli.ts detect --root /path/to/project # hints for writing a config
node_modules/.bin/tsx scripts/cli.ts scan --root /path/to/project # scan and write the reports
node_modules/.bin/tsx scripts/cli.ts report --root /path/to/project --interpretation notes.md # re-render with textIt does not set a failing exit code on findings yet, so it is not a CI gate out of the box.
- Collect. Files come from
git ls-files(so.gitignoreis respected), minus tests, stories, build output and your design system's own source. - Catalog. The TypeScript compiler resolves your design system package the way your own
tsconfigdoes, lists its real exports and reads the props of the components your code imports. A component whose props cannot be read cleanly is skipped for prop checks, never failed. - Tokens. CSS custom properties and color values in your token file are read, so a raw hex can be matched to the token that already holds it.
- Check. Each file is parsed once with Babel and run through the checks.
- Score and compare. Per-file results become dimension scores, then the overall score and gate. Findings are matched against the previous report.
- Report. Markdown, HTML and JSON are rendered from one data object. Claude then reads the numbers and writes the interpretation. It never recomputes them.
- React with TypeScript or JavaScript. Web components and Vue/Svelte templates are not parsed.
- Prop checks need the compiler to read the component's props. Heavily generic components may be skipped.
- Styling written outside
className,style,sxand.css/.scssfiles (for example styled-components template strings) is not checked for hardcoded values. - The accessibility checks are a static subset. They do not replace testing with a screen reader or a tool such as axe.
- Token matching covers colors. Sizes are flagged but not matched to a spacing token.
- Folders are grouped two levels deep (three inside
packages/,apps/,libs/,modules/,services/) in the coverage section. Only.tsxand.jsxfiles are listed as not counted. - It does not check documentation, rules, Figma, Storybook, hand-built lookalike components or duplicate components.
SKILL.md what Claude reads when you run /ds-drift
scripts/
cli.ts detect, scan and report commands
scan.ts runs the checks, scores, compares with the last report
catalog.ts design system exports and props via the TypeScript compiler
tokens.ts token extraction
collect.ts which files get scanned
imports.ts competing-library check
report-md.ts markdown report
report-html.ts HTML report and summary image
vendor/ checks adapted from open-design-system-bench
docs/ configuration and checks reference, screenshots
examples/demo/ sample design system, sample app, sample reports
Typecheck after changes with npm run typecheck.
The API fidelity, token discipline and accessibility checks are adapted from open-design-system-bench by Christoph Hellmuth (MIT), which benchmarks how well coding agents follow a design system. See NOTICE.md for exactly what was taken and what was changed.



