According to recent reports, it's late, the agent has been working well for an hour, and you have started approving things on reflex. The next command in the queue is this:.

Maybe that is what you asked for. Maybe the agent read "clean up the old deployment" more broadly than you meant. Either way, the moment to notice is before it runs, and by hour two your attention is the weakest part of the setup. (Related: Understanding BigBird's Block Sparse Attention...)

The risk hook is a small Node script that makes that moment hard to miss. It reads every Bash command Claude Code is about to run, sorts risky ones into three tiers, and denies them until the agent has written a plain risk flag in the chat and re-run the command with an explicit acknowledgement. This post indicates how to install it, what a flag looks like, how to tune it, and where it stops. (Related: Hugging Face Reads, Feb. 2021 - Long-range Transformers...)

The hook sits on two Claude Code events:.

Some examples of what lands where:.

A hit on something environment-touching escalates to HIGH when the command carries a prod or staging marker. A local operation on a file that merely has "prod" in its name is not escalated.

Sources indicate that the parser is quote-aware. It follows bash -c, eval and $(...) up to two levels down, normalises the command name (path, case, quotes), and skips the body of a heredoc that only writes a file.

When the agent tries the kubectl command from the top of this post, the hook denies it and Claude Code shows the agent this reason:.

The agent then writes something like this in the chat:.

๐ŸŸฅ HIGH RISK delete the api deployment in the production namespace.

It has been revealed that the diff fence is there for colour: lines starting with - render red in most viewers, so the block stands out from normal output. You read four lines and decide. That is the whole point.

A paid API call gets the WARNING version:.

๐ŸŸง WARNING run the enrichment backfill against the OpenAI API.

A CAUTION is a single line, for example: ๐ŸŸจ CAUTION git reset --hard HEAD~3 drops the last three commits ยท undo: git reflog then reset back.

Once the flag is written and you have said yes (or you asked for exactly that step), the agent re-runs the command with the tier as a leading assignment:.

A trailing comment works too, which is handy for multi-line commands:.

The hook then lets it through and demonstrates ๐ŸŸฅ HIGH RISK acknowledged [infra]: kubectl mutates a cluster.

Sources indicate that the ack must be at or above the detected tier. RISK_ACK=caution on a HIGH command is denied again with a message saying it was acked too low. The values are high, warn and caution.

Everything lives in the one file, as plain regex tables near the top:.

In a recent development, after an edit, run the hook against a command by piping a payload into it, for example {"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"git reset --hard"}}. An empty output means allowed; a JSON deny means flagged.

This is a guardrail against inattention, not a security boundary.

According to recent reports, the risk hook stops the dangerous command. It can't stop your API key landing in the model's context.

According to recent reports, most key leaks are not attacks. They are ordinary debugging steps that print a value where the model reads it:.

Industry observers note that once a value is in context it can end up in transcripts and logs too. None of these is a risky command, so no risk rule fires.

Sources indicate that sometimes the agent needs to use a real key, not only check it exists. That is the case we built EnvSecure for. It is a Claude Code mod for macOS: the value sits in Keychain, the agent writes $NAME in a Bash command, you approve the command in a side pane, and the model gets back envsecure: ok or envsecure: failed. The output goes to the pane, not the chat.

If the habits above don't cover your setup, it's at https://envsecure.syncoderslabs.com/.

โ†’ Read original article