r/OpenSourceAIAllowed • u/samc621 • 18d ago
Made an open-source tool that stops coding agents from running the commands you can't undo. Would love feedback
So this started because my coding agent ran prisma db push --force-reset on a database to get past a migration error. Its reasoning was basically "it's only dev data." Which, fair, but still.
That's the thing with agents like Claude Code, Cursor and Codex. They run shell commands with your permissions, way faster than you can check them, and 99% of the time that's great. The other 1% is git reset --hard over a day of work, or rm -rf on the wrong path, or casually reading your .env.
So we built AgentTrail Guard. It's open source (Apache-2.0), runs locally, and checks each command before the agent runs it. If it matches one of the rules, it gets blocked, or it asks you first, or it just warns you. Everything else goes through like normal.
npm install -g @agenttrail/guard
agenttrail-guard init --agent claude # or cursor, or codex
It's plain rule matching, not another AI, so you can actually read every rule and see why something fired. We put all 74 of them in a browsable list here if you want to see what it catches without installing anything: https://www.agenttrail.sh/guardrails
The bit I'd actually try first is agenttrail-guard scan --agent claude. It goes through your old sessions and shows what would have been caught. Kind of eye-opening.
It's not perfect. It only sees what goes through the agent's hooks, and if it crashes it lets things through rather than blocking your work. It'll definitely miss stuff, which is why I'm posting.
If you try it, I'd love to hear what it flagged that it shouldn't have, or what your agent has done that it didn't catch. PRs for new rules are very welcome.
Code's here: https://github.com/agenttrailhq/guard
2
u/Benjino16 15d ago
Hi, really cool project I may test it if I find the time to. Besides I would have these 3 questions:
What setup were you running when the prisma reset happened (agent, model, permission mode)? in my experience claude code catches this kind of thing pretty well when I am using auto mode, before stuff like database resets or force pushes happens, since a classifier model already detects critical tool calls and specifically asks the user...
Where does this add the most over those built-in checks? Is it mainly a predictable, rule-based layer on top of a probabilistic classifier?
I think the more fundamental fix (that I want to raise awareness) is isolation: run agents in a devcontainer with a dedicated DB, plus branch protection that blocks force pushes and requires CI (https://code.claude.com/docs/en/devcontainer). Same goes for secrets: a
.envin a dev environment generally shouldn’t hold production, staging or critical infrastructure keys in the first place, just scoped dev credentials that are cheap to rotate. Would you see this as a complement to that? I could see it covering things that isolation doesn’t but it could also slow down or make fast dev more annoying since it not context based.One example: I had a project where I locally often reset my db and fill it with seed data for dev purposes but the agent continued to flag it and I had to manually approve it most of the time (but for the same session it remembered my decision). Does "guard" have something like this? Can I allow a command for a session?
On thing I noticed so far:
-
dropdb devdbget flagged-
rm database.db(sqlite) does not get flaggedbut isn’t the purpose of the tool mostly to prevent harming tool calls in the local environment?