Your tests clicked
the button.
Your users can’t.
Driftor is a pre-merge gate for UI changes written by AI agents. It runs your critical flows in a real Chrome through Kane CLI, catches the clicks that never land, and hands the evidence back to the agent to fix.
JSDOM can’t see what’s on top.
Coding agents check their work by running the test suite, and most UI suites run in JSDOM. JSDOM builds the DOM but never lays it out: no boxes, no z-index, no hit-testing. So button.click() always reaches the button, even when a transparent full-screen wrapper sits above it in the browser.
The agent sees green, opens the pull request, and the bug ships. Toggle the figure to see the same click before and after the fix.
Same commit. Two answers.
The regression from figure 1, run through both. The left is the real output of npm run test:unit with the bug in place. The right is the latest failing Kane run from kane-traces/.
✓ renders the gateway with two seeded keys and $4,500.00 quota ✓ “Generate Production API Key” adds a key ✓ top-up adds $250 to the quota ✓ shows the maintenance notice ✓ 23 more: run isolation, change selection Tests 27 passed (27)
Five one-line bugs. The unit tests pass every one.
Each is a change an agent could plausibly make, and each ships into the demo app with npm run driftor:inject -- <bug>. Driftor doesn’t look for them by name: Kane uses the app the way a person does, so a click that never lands, a control missing from the narrow layout, or a page that keeps showing the old balance after a successful write all end in a failed step. Every verdict below is read from an archived run in kane-traces/runs/.
reading kane-traces/…
Break it, catch it, fix it, prove it.
One Claude Code hook closes the loop. No selectors, no second terminal, no human between the failure and the fix.
- 01
npm run agentThe agent changes the UI
Claude Code runs with Driftor’s Stop hook armed. Ask for a feature; it edits the app and says it’s done. Its unit tests pass.
- 02
Stop hookKane drives real Chrome
Before the turn can end, Driftor runs the objectives the changed files can affect through Kane CLI, on a wide screen and a narrow one. Kane also designs new tests from the agent’s task, so the new feature gets checked too.
- 03
decision: blockThe failure goes back to the agent
If any check fails, the hook refuses the stop and hands Claude Kane’s failing steps and raw NDJSON. Same session, no human in between.
- 04
≤ 3 attemptsGreen only counts in Chrome
Claude fixes it and stops again; Kane re-runs. The turn ends when the real browser passes, or after three tries, when a human gets the evidence.
a real session, replayed from its transcript
reading kane-traces/…
The agent gets a bug report, not a red X.
Each objective writes an NDJSON trace. When a step fails, driftor:heal pulls out what went wrong, where, and a suggested fix, and builds the agent’s prompt from it. The run log also shows the tests Kane designed from the agent’s task, in the “from task” column.
every gate run, newest first
| when | triggered by | injected | unit | desktop | narrow | from task | gate |
|---|---|---|---|---|---|---|---|
| reading kane-traces/… | |||||||
Every run’s traces are on the Traces page.
Six parts, one direction.
Objectives go in at one end; a change Kane has passed in real Chrome comes out the other.
- 01→driftor.config.jsonplain-English objectives + viewports
- 02→Claude Code Stop hookfires when the agent tries to finish
- 03→kane-cli run --agentdrives Chrome, streams NDJSON
- 04→kane-traces/one trace per objective, every run archived
- 05→driftor.js --hookblocks the stop, writes the bug report
- 06↺ 03claude, same sessionpatches the source, stops again
↺ 03 when Claude stops again, the hook re-runs the same Kane objectives.
| file | what it does |
|---|---|
| driftor.config.json | Your objectives, viewports, app URL, state-reset endpoint and unit command. Point Driftor at another app by editing this file. |
| .claude/settings.json | Registers driftor.js --hook as Claude Code’s Stop hook. Opt-in: it only acts when the session runs with DRIFTOR_HOOK=1 (npm run agent). |
| driftor.js | The CLI: gate (default), --hook, --heal, --watch, --accept "<task>", init, and the bug zoo (--inject <bug>, --list, --reset). |
| driftor_test.js | Runs each selected objective through kane-cli run --agent at its viewport, with its own app state (/app?run=<id>), runs the unit suite once, and archives everything to kane-traces/runs/. --changed or --files a,b runs only what those files can affect. |
| lib/select.js | Change-based selection: each objective lists the files it covers. Shared or unknown files run everything; files that can’t touch the page run nothing, and the run says why. |
| lib/acceptance.js | Hands the agent’s task and the app’s starting data to Kane’s assurance commands, which design acceptance tests from it, then runs them next to the gate. A test with an empty variable is skipped as no verdict. |
| lib/heal.js | Turns failing NDJSON events into the agent’s bug report. The Traces page uses it too, so it shows the exact prompt. |
| lib/regressions.js | The bug zoo: five one-line UI regressions (dead clicks, a control hidden on narrow screens, a stale cached read), each an exact, reversible swap in the demo app’s source. |
| tests/unit | Vitest + JSDOM suite for CloudScale. It stays green with every bug in the zoo, which is the point. |
| specs/PRD.md | The CloudScale requirements. Every gate check maps to a use case here. |
| app/app | CloudScale, the demo app under test, with a real backend in app/api/cloudscale. |
| app/api/traces | Reads kane-traces/ for the Traces page and the live panels on this page. |
| scripts/init.js | driftor init: sets Driftor up in another Next.js or Vite repo, with the runtime, a starter config and the Stop hook. |
| .github/workflows/driftor.yml | The CI gate: runs Kane headless on each pull request, judges the evidence pack against policies/driftor-gate.yaml and keeps one sticky PR comment (scripts/ci.js, docs/ci.md). |
Every check traces back to a requirement.
The gate’s objectives come from the use cases in specs/PRD.md, so a failure names the requirement it breaks. The core invariant: primary actions stay reachable and clickable in both the desktop and the mobile layout.
| id | invariant | viewport |
|---|---|---|
| UC-01 | Gateway loads with the primary CTA visible | 1920×1080 |
| UC-02 | “Generate Production API Key” receives the click and adds a key | 1920×1080 |
| UC-03 | Quota top-up stays reachable in the mobile layout and updates the balance | 800×1000 |
locally
# terminal 1 npm install && npm run dev # terminal 2 npm run kane:login # once npm run driftor:preflight # checks kane, app, agent npm run driftor:inject -- overlay # ship a bug from the zoo npm run driftor:gate # Kane catches it npm run agent # Claude Code, hook armed npm run driftor:reset # undo any inject
as a CI gate
# .github/workflows/driftor.yml, on every PR - run: npm ci && npx vitest run - run: npm run build && npx next start -p 3000 & - run: npx kane-cli login --username … --access-key … - run: node driftor.js gate --headless - run: node scripts/ci.js verdict <run> --policy policies/driftor-gate.yaml # one sticky PR comment; secrets KANE_USERNAME, KANE_ACCESS_KEY
Fair questions.
- Why not write a Playwright test?
- You can, and it would catch this bug. Driftor’s objectives are plain English tied to the PRD, so there are no selectors to keep in sync while an agent rewrites the markup, and Kane returns a structured verdict the agent can read directly.
- Does it replace unit tests?
- No. Unit tests still cover logic. Driftor covers the part JSDOM can’t: whether a real user can click the thing.
- What do I need to run it?
- Node, Chrome and Kane CLI with a TestMu AI login (
npm run kane:login). Every result on this site comes from real Kane runs; there is no offline or mock mode. - Which coding agents can heal?
- The Stop hook is Claude Code’s. For other agents,
driftor:healruns a one-shot fix withclaude -p, falling back togemini. Either way the agent gets only the Kane evidence, not the answer, and only a Kane re-run in Chrome counts as fixed. - Does it only work with this demo app?
- No. Run
driftor initin a Next.js or Vite repo (or copydriftor.config.json), write your critical flows as plain-English objectives, and seturl(or pass--url). The runner, hook, trace handling and heal prompt don’t know anything about CloudScale. - What stops the agent looping forever?
- The hook counts attempts per session. After three failed Kane runs it lets the turn end and tells you, with the evidence in kane-traces/. It also skips Kane entirely when the source hasn’t changed since the last green run.
See the click fail,
then watch it heal.
The demo app is a small API-key dashboard with a real backend. Run npm run driftor:inject, then try clicking its main button yourself.