Guides
Agents
Coding agents make up values like p-[13px] when they don't know your tokens. Plumber gives an agent your tokens and their reasons before it writes, then checks its edits and either names the change to make or tells it to stop and ask you.
Set it up
npx plumber install --agent claude
For Claude Code this writes two files, and keeps what is already in your settings:
.claude/skills/plumber/SKILL.md: how to use Plumber, written for agents.- A hook in
.claude/settings.jsonthat runs Plumber after every edit:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [{ "type": "command", "command": "npx --no-install plumber check --changed --agent --strict-ledger" }]
}
]
}
}
Other agents get instructions in the place they read them:
| Agent | --agent | Writes | Hook after edits |
|---|---|---|---|
| Claude Code | claude | .claude/skills/plumber/SKILL.md | yes |
| Cursor | cursor | .cursor/rules/plumber.mdc | yes |
| Codex, and any other | codex, generic | a block in AGENTS.md | no |
| Copilot | copilot | a block in .github/copilot-instructions.md | no |
| Gemini CLI | gemini | a block in GEMINI.md | no |
| Windsurf | windsurf | .windsurf/rules/plumber.md | no |
To add only the hooks for Claude Code and Cursor, run npx plumber install --hooks. Pass --agent more than once to set up several agents. npx plumber install --list shows what it would write without writing it.
The loop
-
Before writing styles, the agent looks up your tokens (
npx plumber decisions --family spacing), and can try a snippet without touching a file:sh echo '<div className="gap-10 text-gray-500" />' | npx plumber try --agent -
After each edit,
plumber check --changed --agentlists only new problems in the files it changed, each as one instruction. It repeats until the output is0 new.
Here's that output for a 13px gap:
1 new
## 1 of 1 gap 13px isn't on your spacing scale
Rule: provenance/spacing
Why: Off-scale spacing makes layouts drift apart and can't be changed from the theme.
Tokens:
- 8px: use gap-related or gap: var(--spacing-related); why: Related items use eight pixels.
- 16px: use gap-group or gap: var(--spacing-group); why: (no reason recorded)
Sites: src/new.css:1:8
- src/new.css:1:8 `gap: 13px`
Compiles to: gap: 13px (via stylesheet)
Choose a token using its reason, then edit at src/new.css:1:8:
replace `gap: 13px` with `gap: var(--spacing-related)` (8px)
replace `gap: 13px` with `gap: var(--spacing-group)` (16px)
Each site ends in one of four instructions:
| Instruction | Means |
|---|---|
| Edit | one token fits: make exactly that edit |
| Choose a token using its reason | several fit: pick by the reasons and what the element is for |
| NEEDS-DECISION | nothing fits: stop and tell you the sites and the value it wanted |
| Fix | a habit or other finding: follow the instruction |
The agent uses your why: comments to choose between tokens.
What agents are told not to do
The skill gives agents these limits, and --agent output repeats the main ones:
- Never edit the config, the ledger or the theme to make a finding pass. A new token or an exception is your decision.
- Never run
plumber accept,accept-decisionsorbaselineunless you ask. If something should be an exception, it gives you theplumber accept … --whyline to run. - Never invent a nearby value, like
p-[13px]orp-3.25, to get around a finding.
The hook runs with --strict-ledger, so the check fails if an agent adds to the ledger. A hook runs after the edit and can't undo it.