A jevhook
Tell a turn it has lost its way
A long turn can go wrong with no single step being wrong: the assistant reruns one failing test over and over, or wanders into work you never asked for. Every thirty actions a Claude Code agent takes, a small fast model called Jev checks whether the agent is still doing what you asked or has got stuck or wandered off, and if it has, it slips the agent a warning note but does not stop it.
It starts in shadow: it writes down what it would have done and changes nothing, until you switch it on. It acts at PostToolUse.
Jev is the small, fast model jevhooks asks. It writes nothing: it is handed a question whose answers are already written down, and says how likely each one is, in about a quarter of a second. jevhooks is a plugin for Claude Code that asks it at the moments Claude Code lets a plugin step in, and a jevhook is one such question with what is done about the answer.
- Every 30 tool calls of a turn (a number you can set), Jev is shown what you asked for and the latest calls in brief (the tool and the start of what it was called with, never what it returned), and picks one of four: on track, stuck in a loop, going beyond what you asked, or working around something only you can settle.
- At 75% or more for one of the last three, the assistant gets a note saying so: once in a turn, at most 3 times in a session and not within 60 seconds of the last.
Say something
A jevhook is off, in shadow or on. To change this one, put this in ~/.config/jevhooks/config.toml:
[jevhooks.PostToolUse] drift = "on"
In shadow Jev is asked and nothing is changed. The log (jevhooks recent, or /jev in a session) then says what would have been done: for this one, that the assistant would have been told.
4 worked cases, each an answer Jev could give, the rules that decide on it, and the screen you would see. The ones you would meet most come first, and the 3 at the edges last: a switch that is off, a cap that is spent, an answer Jev is not sure of.
The rules these cases run through
9 rules decide whether the assistant is told its turn has left what you asked. They test 3 things, and 1 of them is Jev's answer: which of 4 directions the turn is going in, from what you asked for and its latest calls in brief. The assistant is told when one of the three that are not “on track” is 75% likely alone. The rest are the switch and the limits, known before Jev is asked: once in a turn, 3 times in a session, and not within 60 seconds of the last.
thirty calls in: the same test run again and again, failing the same way tell it
Jev is 90% sure the turn is stuck in a loop. The assistant is told so beside the result it has just been given: stop repeating it, and say what is in the way.
How to read a drawing
Jev answers with numbers. What happens next is decided by a few rules, in order: of the rules that hold, the first decides. They are compiled into one small network, and these pictures are drawn from that network, not beside it, so they cannot show a rule the plugin does not have.
Read one left to right: what can be known, the tests on it, where a rule's tests meet, and the rules. Black is what a rule that holds stands on, and dashed is a test that failed. A pink rule holds; more than one can, and the numbered ones are those that decided, in order. The framed facts are Jev's, and are asked for together, in one request.
❯ find why the importer sometimes loses rows ● Bash(cargo test importer) ⎿ test result: FAILED. 40 passed; 1 failed; 0 ignored ✻ Working… result: Jev: the turn looks stuck in a loop (90%); the assistant was told · 150 ms · $0.0002 this session [-] ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
The assistant reads beside the result:
jevhooks: 30 tool calls into this turn, the latest ones look like a loop: the same thing tried again without getting further (Jev: 90%). Stop repeating it. Say what you have tried and what is in the way, or take a different approach.
thirty calls in, and Jev cannot say where it is going say nothing
31%, 30% and 30% on the three answers that are not “on track” add up to 91% that something is off, but Jev cannot say what. One of them has to reach 75% by itself, so the assistant is told nothing.
❯ find why the importer sometimes loses rows ● Search(pattern: "skip", path: "src") ⎿ Found 9 files ✻ Working… ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
sixty calls in, when the turn was told at thirty say nothing
The assistant is told about a turn only once, and this turn was told at thirty calls. The plugin knows that already, so Jev is not asked.
❯ find why the importer sometimes loses rows ● Read(src/importer.rs) ⎿ Read 212 lines ✻ Working… ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
a turn stuck in a loop, before you have switched this on say nothing
In shadow Jev is still asked, and the log records that the assistant would have been told. The plugin then acts as if this one were off: the assistant is told nothing.
❯ find why the importer sometimes loses rows ● Bash(cargo test importer) ⎿ test result: FAILED. 40 passed; 1 failed; 0 ignored ✻ Working… ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
What this site keeps about a visit, and how to refuse it, is said in one place: what is kept.