Skip to Content
AutoMode

Architecture

How the AutoMode mod is built: one register function binds every Claude Code event, wiring files own engine calls, and pure modules decide routes.

hooks/hooks.json names one module, hooks/register.ts. Its register function binds every engine event. The guardian sees each prompt first, and then the router decides the route.

hooks.json
register.ts
v4.ts
guardian.ts
config.json
LayerFilesRole
Wiringhooks/v4.ts, hooks/guardian.tsOwn all $ engine calls and module state. They move values between the engine and the pure modules.
Pure logichooks/lib/*.tsNo $ and no I/O. Each file opens with a comment that states its contract. lib/io.ts is the one exception.
UIhooks/ui/publish.ts writes the automode.view atom, and every drawing reads it. A drawing never calls publish.
Workflowworkflows/run.js, agents/*.mdThe automode:run workflow and its agents. It runs in a different runtime from the hooks and shares no imports with them.
User scriptsscripts/*.mjsRun through a user's node, which may be older than 23.6.
Evidencebench/Benchmarks and offline transcript tools. Most of bench/external/ is vendored upstream code with checksums.

Where a route is decided

v4PromptSubmit runs decideAuto under policy auto, the shipped policy. Policy legacy is the interval optimizer in lib/optimizer.ts.

StepFile
The effortless judgelib/effortless.ts, a verbatim port. Changes go in lib/effortless-adapt.ts.
The AutoMode judgelib/classify.ts
Quality floorslib/consequence.ts, lib/risk.ts
The weakest eligible modeloptimizeAuto in lib/auto.ts
Authority orderresolve in lib/authority.ts
The switch checklib/policy.ts
Pinslib/pins.ts
Failure evidence and the ladderescalation() in lib/failures.ts, ladderStep in lib/bands.ts
Route learninglib/learn.ts
Delegated readsgateRead in lib/delegation.ts

v4TurnStep applies the route to each request. tests/golden/decisions.json pins optimizer and switch-check behavior.

See How a route is decided for the behavior these files produce.

Last updated on

On this page