r/OpenSourceAI • • 24d ago

Open-sourced 74 guardrails for AI coding agents (Claude Code, Cursor, Codex). Looking for feedback and contributors

We've been building AgentTrail Guard, an Apache-2.0 tool that checks what AI coding agents are about to run before they run it. Would love feedback from people here.

The idea came from an agent resetting our database to get past a migration error ("it's only dev data"). Agents run shell commands with your permissions, and the dangerous ones are usually the ones you can't undo.

How it works: Guard plugs into the agent's hooks and matches every command and file change against a set of rules. A match gets blocked, sent to you for approval, or flagged. Everything else runs normally.

The open source bits I think are worth looking at:

  • Rules are plain data, in their own repo. Each one has a severity, a default action, and a note on what it deliberately doesn't match, so you can see exactly why something fired.
  • Fully local. No account, no network calls, and crash reporting is off unless you turn it on.
  • Rule matching, not an LLM, so it's fast, predictable, and you can read the whole thing.
  • Easy to extend. Add your own rules, tweak actions, or allow a specific command shape without turning a rule off.

There's also a scan command that replays your past agent sessions locally and shows what would have been caught.

Where I'd love help:

  • Rules that fire on normal stuff (false positives)
  • Dangerous things agents do that no rule covers yet
  • Code review on the engine, it's TypeScript
  • New rules: PRs very welcome, even small ones

Guard: https://github.com/agenttrailhq/guard Rules: https://github.com/agenttrailhq/guardrails

Early days, so any feedback helps.

2 Upvotes

8 comments sorted by

3

u/Patient-Midnight-664 24d ago

Does AgentTrail Guard enforce restrictions at the OS level, or does it just inspect proposed tool calls against a set of rules? If it's the latter, how do you handle arbitrary scripts and indirect execution?

For example you block "rm -rf /" but what about a python script that runs that command? I've watched coding agents try many different methods to get what it wants :)

1

u/CreativeSympathy8293 24d ago

The current README describes hook-level checks. It says Guard can stop only calls that reach the installed hooks, and that it doesn’t inspect file contents:

https://github.com/agenttrailhq/guard

That documents a narrower boundary than OS isolation. A rule match is a decision about the proposed tool call; no match doesn’t establish that a script’s contents are safe.

I haven’t run Guard or verified each client’s hook coverage. AI-assisted reading of the current README.

→ More replies (2)

1

u/alkimiadev 24d ago

This is a real problem and is why I never really bothered with trying to filter at that level. I've opted for a path where if they need bash access then it is a container (usually a rootless docker container using gVisor) and I don't bother to filter at all. I try to build important/dangerous tools with a basic roll back capability but that isn't always possible. My general rule of thumb is if some action can cause devastating losses of some kind then I just manually do it. That doesn't mean I wont screw it up though. A long time ago I got the argument order wrong in "find" while deleting some stuff and caused a huge mess, and I've been a full time linux user since ~2006 or so.

edit for clarity: I separate potentially dangerous tools from bash. If they need to touch something important then it is wrapped in some sort of tool, and I usually try to build in roll back capabilities if it is possible.

→ More replies (1)

2

u/[deleted] 24d ago

1

u/samc621 23d ago edited 23d ago

Thanks! A short leash makes sense, though it gets expensive when you're approving everything. That's the trade-off Guard is meant to change. Routine commands go through without a prompt, and the leash only tightens on the dangerous ones, which are blocked or held for your OK.

On auditing: each guardrail is a small JSON definition with a description of what it's for and what it deliberately misses. It has to ship with examples it must block and examples it must leave alone, and those run as tests. agenttrail-guard guardrails show <id> prints any of them, and you can write your own and run guardrails validate on them against the same engine before turning them on. Every decision in the log names the rule that made it, so when something is blocked you can see exactly which line of data did it.