Snapif
Snapif scores one tool call. The score is Auto, Review, or Escalate.
Getting started
Build the snapif binary. The cli feature includes http.
From this repo, cargo run --features cli -- --help prints the same commands.
Gate
Write one tool call to call.json:
SNAPIF_BACKEND=fake
The process prints one word and exits:
| Exit | Word | Meaning |
|---|---|---|
| 0 | auto |
The call may proceed. |
| 10 | review |
A person should look first. |
| 11 | escalate |
Do not run the call. |
script is only for SNAPIF_BACKEND=fake. A live score uses typesafe or compatible.
Hook
snapif hook is a Claude Code PreToolUse hook. It reads one JSON object on stdin and prints a permission decision on stdout. A bad body still exits 0 and denies the call, because a hook error would otherwise let the call proceed.
| SNAPIF_BACKEND=fake
Example
This run uses a scripted fake scorer and prints auto:
Live score
SNAPIF_BACKENDistypesafeorcompatible.SNAPIF_BASE_URLis required forcompatibleand must be a URL.SNAPIF_API_KEYis required when the base URL is not a loopback address.