Guard Rails for Agents That Work Near Production
Agents that can run shell commands, write files and call MCP tools can also refresh a model over and over. These are the rails I run around mine, in my own home lab.
The Guard Hook
A hook runs before every shell command, file write and MCP call. It sorts each one into a tier:
- lockdown
- self-protection, so the agent cannot edit the guard, its settings or its configs
- writes to the workspaces I treat as production
- capacity changes (deny)
- tenant and permission changes
- bulk refresh (deny)
- SQL that changes data or schema
- printing tokens (deny)
- sends
- cloud deletes and force pushes
- changes to scheduled tasks
- script scanning
Where the tier says ask, it asks when I am at the keyboard and denies when nothing is attended.
If you build one, start it in shadow mode: have it log what it would have blocked, read the audit log, and only then turn enforcement on. Replaying your real command history through it first will show you what it would have stopped.
An open-source version of the guard hook is coming.
The Kill Switch
One script creates a LOCKDOWN flag that stops all agent missions. Only my own terminal turns it back on, so an agent cannot lift its own lockdown.
The Headless Launcher
Unattended runs start through a launcher with a budget cap and a turn cap, with no permission prompts.
Unattended routines run in auto mode with the classifier as a backstop. Writes to production stay blocked in auto mode.
Refreshes: Serial, Counted
The platform skills that wrap the vendor command line tools all carry one hard rule: never mass-trigger refreshes. Run them one at a time and count the jobs in flight. A loop that fires every refresh at once is the fastest way I know to hurt a capacity.
The Order Matters
Shadow mode before enforcement is the part I’d recommend first. A guard you have never watched run will either block everything or catch nothing, and you will not know which until it matters.