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.

0
selectors to maintain
objectives are plain English
5
bugs JSDOM passes
3 dead clicks · 1 hidden control · 1 stale read
2
viewports per run
1920×1080 · 800×1000 (mobile layout)
1
hook closes the loop
Claude Code Stop → Kane → fix
…
objectives passing in the last run
reading kane-traces/
engine · Kane CLI 0.10browser · real Chromeagents · Claude Code, Gemini CLIevidence · kane-traces/*.ndjson
01
The blind spot

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.

fig. 1
div.toastz-50 · visiblediv.fixed.inset-0z-50 · transparent← receives the clickbutton#deploy-key-btnnever sees the eventJSDOM: no layout,no hit-testing —both states pass.
02
Two verdicts

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/.

vitest · jsdom · regression injected
✓ 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)
kane-cli run --agent · chrome
reading kane-traces/…
03
Bug zoo

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/…

04
The loop

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.

  1. 01npm run agent

    The 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.

  2. 02Stop hook

    Kane 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.

  3. 03decision: block

    The 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.

  4. 04≤ 3 attempts

    Green 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

claude -p · DRIFTOR_HOOK=1 · kane-traces/agent-sessions/

reading kane-traces/…

05
The evidence

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.

kane-traces/failing event
reading kane-traces/…
driftor.js → claudeheal prompt
reading kane-traces/…

every gate run, newest first

whentriggered byinjectedunitdesktopnarrowfrom taskgate
reading kane-traces/…

Every run’s traces are on the Traces page.

06
Under the hood

Six parts, one direction.

Objectives go in at one end; a change Kane has passed in real Chrome comes out the other.

  1. 01→
    driftor.config.json
    plain-English objectives + viewports
  2. 02→
    Claude Code Stop hook
    fires when the agent tries to finish
  3. 03→
    kane-cli run --agent
    drives Chrome, streams NDJSON
  4. 04→
    kane-traces/
    one trace per objective, every run archived
  5. 05→
    driftor.js --hook
    blocks the stop, writes the bug report
  6. 06↺ 03
    claude, same session
    patches the source, stops again

↺ 03 when Claude stops again, the hook re-runs the same Kane objectives.

filewhat it does
driftor.config.jsonYour objectives, viewports, app URL, state-reset endpoint and unit command. Point Driftor at another app by editing this file.
.claude/settings.jsonRegisters 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.jsThe CLI: gate (default), --hook, --heal, --watch, --accept "<task>", init, and the bug zoo (--inject <bug>, --list, --reset).
driftor_test.jsRuns 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.jsChange-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.jsHands 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.jsTurns failing NDJSON events into the agent’s bug report. The Traces page uses it too, so it shows the exact prompt.
lib/regressions.jsThe 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/unitVitest + JSDOM suite for CloudScale. It stays green with every bug in the zoo, which is the point.
specs/PRD.mdThe CloudScale requirements. Every gate check maps to a use case here.
app/appCloudScale, the demo app under test, with a real backend in app/api/cloudscale.
app/api/tracesReads kane-traces/ for the Traces page and the live panels on this page.
scripts/init.jsdriftor init: sets Driftor up in another Next.js or Vite repo, with the runtime, a starter config and the Stop hook.
.github/workflows/driftor.ymlThe 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).
07
What it checks

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.

idinvariantviewport
UC-01Gateway loads with the primary CTA visible1920×1080
UC-02“Generate Production API Key” receives the click and adds a key1920×1080
UC-03Quota top-up stays reachable in the mobile layout and updates the balance800×1000
08
Run it

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
09
Questions

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:heal runs a one-shot fix with claude -p, falling back to gemini. 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 init in a Next.js or Vite repo (or copy driftor.config.json), write your critical flows as plain-English objectives, and set url (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.