A jevhook

Ask before what is hard to undo

Some shell commands cannot be taken back once they have run. Before Claude Code runs one, this check has a small model rate how hard it would be to undo, and asks you first when that is hard: sed -i over data files in no repository waits for your yes, though editing files is everyday work. The rating goes in a request the plugin already sends for the command, so it adds no request of its own.

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 rates how hard it would be to put everything back, on four levels: nothing to undo, undone by one command, hard to undo, cannot be undone.
  • You are asked before anything hard to put back runs, even when the command is an ordinary kind such as an edit.

Its switch

  • At PreToolUse it is PreToolUse/undostarts on
    Say something

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

[jevhooks.PreToolUse]
undo = "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, that you would have been asked about the command.

One worked case: an answer Jev could give, the rules that decide on it, and the screen you would see.

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 act, memory, leaves, argues, origin, scope, forbidden, self, calls.

sed -i over data files that are not in version control ask

The command only edits files, which is ordinary work. But these files are in no repository, and Jev rates the command 2.5 of 3 for how hard it would be to put back. Anything that hard to undo waits for your yes, however ordinary the command.

Jev, in one requestactonundoonmemoryonleavesoffarguesofforiginoffscopeoffforbiddenoffselfofftouches jevhooksnosomething forbiddennoleaves: refusednoorigin: refusednoforbidden: refusednoconsequential0%hard to undo2.5ordinary work100%easy to undo2.5load0.2reads 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 β†’ ask2reads 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

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.

❯ the importer wants commas, fix the sample data

● Bash(sed -i 's/;/,/g' data/*.csv)
  ⎿  Running…

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Bash command
 Replace semicolons with commas in the data files
β•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œ
 sed -i 's/;/,/g' data/*.csv
β•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œβ•Œ
 β”‚ Hook PreToolUse:Bash requires confirmation for this command:
 β”‚ Jev: edits files in a way version control can undo (95%); cannot be undone (2.5 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: edits files in a way version control can undo (95%); cannot be undone (2.5 of 3) Β· 150 ms Β· $0.0002 this session

What this site keeps about a visit, and how to refuse it, is said in one place: what is kept.