A jevhook

Refuse a key written into a file

This keeps API keys and tokens out of your files. Each time the assistant writes or edits a file, the plugin searches the new text on your machine for keys in the formats providers issue them in, such as a GitHub token in a .env file. If it finds one it refuses the change, so the key is never written. Nothing is sent anywhere to decide this, not even to Jev, the model the plugin asks about most other things.

It is on from the start. 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

  • The plugin searches the new text of every Write, Edit and NotebookEdit call, on your machine, for keys in 29 known formats.
  • When it finds one it refuses the change, and tells the assistant to keep secrets out of files.
  • The key is sent nowhere, and Jev is not asked.

Its switch

  • At PreToolUse it is PreToolUse/secretstarts on
    Say something

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

[jevhooks.PreToolUse]
secret = "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 the change would have been refused.

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

New text for a file, before it is written

The rules these cases run through

Before Write, Edit or NotebookEdit changes a file, 11 rules decide whether the new text goes in, from 17 things known about it. 3 are Jev's answers: whether a string that looks random is a real secret, whether the change breaks a rule the project wrote down, and whether it does what you said not to do. Jev gives a yes or no for every string, rule file or thing you said, and the rules read the likeliest one, never a sum. The first two rules need no answer: a key in a format the plugin knows, and a change to the plugin's own files. A broken written rule sends one file back at most 2 times in a turn, and changes at most 3 times in a session whatever the files. The rule that counts runs before the one that sends back, and past either limit a note is all that is left.

The same rules serve self, secret-like, rules.

a .env file with a GitHub token in it deny

The token has a format the plugin knows, so the plugin finds it itself, on your machine. The change is refused, Jev is not asked, and the token goes nowhere.

Jev, in one requestsecretonsecret-likeonrulesonforbiddenonselfona known keyyestouches jevhooksnohas candidatesnohas rule filesnosomething forbiddennosecret: refusednoforbidden: refusednorules: refusednolooks a secretbreaks a rulecrosses itpush-backs= yes= yes= yes= yes= yes= yes= no= yes= yes= yes= yes= no= sure= yes= yes= yes= yes= no= left= yes= maybe= spent&&&&&&&&&&&&&&&&&&&&&&a key in a known format β†’ deny1one of jevhooks' own files β†’ aska change the user forbade β†’ denyforbidden change, cap spent β†’ asksurely a secret β†’ denya secret, cap spent β†’ askcount the push-backs β†’ countbreaks a written rule β†’ denybreaks a rule, cap spent β†’ note itmay be a secret β†’ aska rule out of push-backs β†’ note it

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.

❯ set up the GitHub client so the importer can fetch issues

● Write(.env)
  ⎿  Error: jevhooks: the new text holds a key in a known format (GitHub token), so it was not written. Keep secrets out
     of files: read them from the environment or a secrets tool. If it is a placeholder or a test fixture, say so to the
     user.

✻ Working…
tool call: jevhooks: the new text holds a key in a known format (GitHub token), so it was not written. Keep secrets  [-]
out of files: read them from the environment or a secrets tool. If it is a placeholder or a test fixture, say so to
the user. Β· 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.