A jevhook
Send a turn back when it ends against your rules
If you have a rule for how the assistant should finish a turn, write it in a file in plain words, one to a line: “never end on a question you could have answered yourself”. Each time a turn is about to end, the end is checked against every rule. If one is broken the turn does not end: the assistant is given your rule, in your words, and carries on. A subagent's end and a task marked complete are checked the same way.
It starts in shadow: it writes down what it would have done and changes nothing, until you switch it on. It acts at SubagentStop, TaskCompleted, Stop.
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.
- You write the rules in plain words, one to a line and 12 at most, in turn-rules.md beside the config file and in a project's .claude/jevhooks-turn-rules.md.
- For each rule Jev is asked whether this end breaks it, and is shown what you asked for, a short list of the turn's tool calls and the end of the assistant's last message.
- When Jev is 90% sure a rule is broken, the turn does not end and the assistant is given your rule as the reason, at most twice a rule in a session and within the one budget shared by the three jevhooks that can send an end back.
A subagent's end is checked against the same rules. When Jev is 90% sure one is broken, the subagent is sent back to its work with your rule as the reason. In shadow until you switch it on.
Say something
When the assistant marks a task complete, the same rules are checked against the task as it was written down and the turn's tool calls. When Jev is 90% sure one is broken, the completion is refused once, with your rule as the reason. In shadow until you switch it on.
Say something
Say something
A jevhook is off, in shadow or on. To change this one, put this in ~/.config/jevhooks/config.toml:
[jevhooks.SubagentStop] kept = "on" [jevhooks.TaskCompleted] kept = "on" [jevhooks.Stop] kept = "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, which rule the end would have been sent back for.
3 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.
The rules these cases run through
Before a turn ends, 15 rules decide whether it ends or goes back to the assistant with a reason. Three switches share them, and one limit on how often an end is sent back. The rules test 14 things. 4 are Jev's answers: which of five endings this is, whether the last message claims the work is done, whether you said not to run checks, and whether the end breaks one of your own rules for it. The other 10 are known before Jev is asked: the three switches, whether a limit has been reached, whether work is still running, whether there is anything to judge, whether files were changed and a check passed since, whether you forbade anything, and whether you have rules. When those settle it, Jev is not asked. The same rules judge a subagent's end and a task marked complete.
The same rules serve unverified, stopped-early.
a turn that ends with no summary, when your rules ask for one send it back
You wrote “End with a one-line summary of what changed.” and the assistant's last message is only “The tests pass.” Jev is asked about each of your rules and is 94% sure this end breaks that one. The turn does not end: the assistant is given your rule and carries on. This one is at Stop.
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.
❯ add a --json flag to the export command ● Bash(cargo test) ⎿ test result: ok. 41 passed; 0 failed; 0 ignored ● The tests pass. ✻ Working… turn end: Jev: this end breaks a rule of yours (94%): "End with a one-line summary of what changed." · 150 ms · [-] $0.0002 this session ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
The turn is sent back, and the assistant reads:
jevhooks: The end of this turn looks to break a rule for how one ends: the user's own rule "End with a one-line summary of what changed." (Jev: 94%). Put it right before ending, or say plainly why it does not apply. This is said once for this end.
a subagent that ends with no summary, when your rules ask for one send it back
A subagent's end is checked against the same rule. Its report is only “The check passes.”, Jev is 91% sure that breaks the rule, and the subagent is sent back with your rule as the reason.
❯ rename Client to HttpClient everywhere ● Bash(cargo check) ⎿ Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.31s ● The check passes. ✻ Working… subagent end: Jev: this end breaks a rule of yours (91%): "End with a one-line summary of what changed." · 150 ms · [-] $0.0002 this session ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
The subagent's end is sent back, and it reads:
jevhooks: The end of this subagent's work looks to break a rule for how one ends: the user's own rule "End with a one-line summary of what changed." (Jev: 91%). Put it right before ending, or say plainly why it does not apply. This is said once for this end.
a task marked complete with no summary, when your rules ask for one send it back
The assistant marks a task complete with “Task 2 is complete.” and no summary. Jev is 90% sure the rule is broken, and the completion is refused with your rule as the reason. This one is at TaskCompleted.
❯ work through the three tasks for the --json flag ● Bash(cargo test) ⎿ test result: ok. 41 passed; 0 failed; 0 ignored ● Task 2 is complete. ✻ Working… task: Jev: this end breaks a rule of yours (90%): "End with a one-line summary of what changed." · 150 ms · $0.0002 [-] this session ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⏸ manual mode on · esc to interrupt
The completion is refused, and the assistant reads:
jevhooks: The end of this task looks to break a rule for how one ends: the user's own rule "End with a one-line summary of what changed." (Jev: 90%). Put it right before ending, or say plainly why it does not apply. This is said once for this end.
What this site keeps about a visit, and how to refuse it, is said in one place: what is kept.