A jevhook

Ask before a consequential command

You use Claude Code, and you want to be asked before a force push but not before cargo test. This does that for Bash commands: running the tests or making a commit goes through with no permission prompt, and a force push or a deploy stops and asks you, with the reason. A small model called Jev sorts each command into one of eight kinds of act, and a plainly read-only command like git status is never sent to it at all.

It is on from the start. In a session whose permission mode is auto, dontAsk or bypassPermissions, where Claude Code or nobody answers for you, it only watches unless your config says otherwise. It acts at PreToolUse.

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.

Exactly what it does

  • Jev is asked which of eight kinds of act the command is, from only reading to running code nobody has read.
  • When Jev is sure the command deletes data, rewrites version-control history, changes the machine, publishes something or runs code nobody has read, you are asked, with the reason; ordinary work that is easily undone runs without a prompt.

Its switch

  • At PreToolUse it is PreToolUse/actstarts on
    Say something

A jevhook is off, in shadow or on. To change this one, put this in ~/.config/jevhooks/config.toml:

[jevhooks.PreToolUse]
act = "shadow"

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 commands would have run unasked, and which you would have been asked about.

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.

A command, before it runs

The rules these cases run through

Before a Bash command, a fetch or another server's tool runs, 27 rules decide what happens to it, from 33 things known about the call. The first rule whose conditions all hold decides. 16 of the things known are Jev's answers, each read against a threshold. 9 are your own switches, one for each check: a rule starts with its check's switch, so Jev is not asked about a check that is off. A few the plugin knows itself: whether the command would switch the plugin off, whether you have said what the assistant may not do, and whether a check has refused as often as one session allows. Two are the machine's: whether memory has room, measured when the first rule says to, and whether the command may still wait for it. Three rules refuse, each on an answer of 90% or more and three times a session at most. After that the rule beneath it asks you instead. The rules named β€œasked: …” come before the rules that ask you, and let through what you asked for in so many words.

The same rules serve undo, memory, leaves, argues, origin, scope, forbidden, self, calls.

cargo test allow

Jev is sure this builds or tests, one command would undo it, and the machine has memory free for it. It runs, and you are not asked.

Jev, in one requestactonundoonmemoryonleavesoffarguesofforiginoffscopeoffforbiddenoffselfofftouches jevhooksnosomething forbiddennoleaves: refusednoorigin: refusednoforbidden: refusednoconsequential0%hard to undo0.9ordinary work100%easy to undo0.9load1.8reads a secretsends outsurely readssurely sendsarguesplantedasked forbeyond the taskoutside projectcrosses ita change countsnochanges a fileroom7.8 GBpatienceleft= yesis known= yes= yes= yes= no= yes= yes= yes= no= yes= yes= yes= yes= yes= no= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= short= left= yes= yes= no= no= yes= yes&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&look for room β†’ measure1switches jevhooks off β†’ askplanted by what it read β†’ denyplanted, cap spent β†’ askreads a secret and sends it β†’ denyreads and sends, cap spent β†’ askdoes what the user forbade β†’ denyforbidden, cap spent β†’ askargues for itself β†’ askasked: a consequential act β†’ passasked: hard to put back β†’ passasked: reads a secret β†’ passasked: sends data out β†’ passasked: beyond the task β†’ passasked: outside the project β†’ passa consequential act β†’ askhard to put back β†’ askreads a secret β†’ asksends data out β†’ askbeyond the task β†’ askoutside the project β†’ askno room yet β†’ holdno room β†’ askordinary and easily undone β†’ allow2not surely ordinary β†’ passnot easily undone β†’ passchanges a file β†’ book a change

Open this drawing at its own size

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

✻ Working…
command: Jev: builds or tests (97%); undone by one command (0.9 of 3); allowed Β· 150 ms Β· $0.0002 this session       [-]

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏸ manual mode on · esc to interrupt
git push --force origin main ask

Jev is sure this rewrites version-control history, which is one of the consequential kinds. You are asked, with the reason. It is not made to wait for free memory first: the rules on what a command does come before the rules on memory.

Jev, in one requestactonundoonmemoryonleavesoffarguesofforiginoffscopeoffforbiddenoffselfofftouches jevhooksnosomething forbiddennoleaves: refusednoorigin: refusednoforbidden: refusednoconsequential93%hard to undo2.4ordinary work1%easy to undo2.4load0.4reads a secretsends outsurely readssurely sendsarguesplantedasked forbeyond the taskoutside projectcrosses ita change countsnochanges a fileroom7.8 GBpatienceleft= yesis known= yes= yes= yes= no= yes= yes= yes= no= yes= yes= yes= yes= yes= no= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= short= left= yes= yes= no= no= yes= yes&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&look for room β†’ measure1switches jevhooks off β†’ askplanted by what it read β†’ denyplanted, cap spent β†’ askreads a secret and sends it β†’ denyreads and sends, cap spent β†’ askdoes what the user forbade β†’ denyforbidden, cap spent β†’ askargues for itself β†’ askasked: a consequential act β†’ passasked: hard to put back β†’ passasked: reads a secret β†’ passasked: sends data out β†’ passasked: beyond the task β†’ passasked: outside the project β†’ passa consequential act β†’ ask2hard to put back β†’ askreads a secret β†’ asksends data out β†’ askbeyond the task β†’ askoutside the project β†’ askno room yet β†’ holdno room β†’ askordinary and easily undone β†’ allownot surely ordinary β†’ passnot easily undone β†’ passchanges a file β†’ book a change

Open this drawing at its own size

❯ squash the last three commits and update the branch

● Bash(git push --force origin main)
  ⎿  Running…

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Bash command
 Force-push the squashed history to origin
β•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œ
 git push --force origin main
β•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œ
 β”‚ Hook PreToolUse:Bash requires confirmation for this command:
 β”‚ Jev: discards or rewrites version-control state (93%); hard to undo (2.4 of 3)
 settings.json to update hooks

 Do you want to proceed?
 ❯ 1. Yes
   2. No

 Esc to cancel Β· Tab to amend

Band:

command: Jev: discards or rewrites version-control state (93%); hard to undo (2.4 of 3) Β· 150 ms Β· $0.0002 this session
a long command that reads some figures and calls another program pass

A real answer from the plugin's log: 56% only reads, 39% changes the machine. Not sure enough to wave through, not sure enough to stop. The plugin steps aside, and Claude Code's own permission rules decide, as if it were not there.

Jev, in one requestactonundoonmemoryonleavesoffarguesofforiginoffscopeoffforbiddenoffselfofftouches jevhooksnosomething forbiddennoleaves: refusednoorigin: refusednoforbidden: refusednoconsequential39%hard to undo0.4ordinary work61%easy to undo0.4load1.3reads a secretsends outsurely readssurely sendsarguesplantedasked forbeyond the taskoutside projectcrosses ita change countsnochanges a fileroom7.8 GBpatienceleft= yesis known= yes= yes= yes= no= yes= yes= yes= no= yes= yes= yes= yes= yes= no= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= yes= short= left= yes= yes= no= no= yes= yes&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&look for room β†’ measure1switches jevhooks off β†’ askplanted by what it read β†’ denyplanted, cap spent β†’ askreads a secret and sends it β†’ denyreads and sends, cap spent β†’ askdoes what the user forbade β†’ denyforbidden, cap spent β†’ askargues for itself β†’ askasked: a consequential act β†’ passasked: hard to put back β†’ passasked: reads a secret β†’ passasked: sends data out β†’ passasked: beyond the task β†’ passasked: outside the project β†’ passa consequential act β†’ askhard to put back β†’ askreads a secret β†’ asksends data out β†’ askbeyond the task β†’ askoutside the project β†’ askno room yet β†’ holdno room β†’ askordinary and easily undone β†’ allownot surely ordinary β†’ pass2not easily undone β†’ passchanges a file β†’ book a change

Open this drawing at its own size

❯ plot the twenty slowest imports

● Bash(sort -k3 -n figures.tsv | tail -n 20 | xargs -n 1 ./plot)
  ⎿  Wrote 20 plots to plots/

✻ Working…
command: Jev: only reads (56%); nothing to undo (0.4 of 3); left to the usual permission check Β· 150 ms Β· $0.0002    [-]
this session

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ⏸ 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.