Self-hosted safety layer for AI agents

An undo button
for AI agents.

Your agent edits files, writes to your database, runs commands and calls paid APIs. gmonk records what every change replaced, so a bad run can be undone exactly — and blocks the actions that nothing could undo.

  • Database changes rows it inserted, updated or deleted
  • Files anything it created, edited or removed
  • Shell commands and it pauses the dangerous ones first
  • Cloud storage objects it put or deleted in S3
  • Charges reversed by a refund you define
  • Self-hosted
  • Postgres & MySQL
  • Nothing leaves your network
run 8f3a mode block
# every action the agent takes, judged as it happens
✓ capture  file  src/api/billing.ts       snapshot
✓ capture  sql   UPDATE accounts SET balance = balance - 30
✓ capture  s3    PUT invoices/2026-07.pdf by version
  shell rm -rf ~/.config         outside workspace
  extl  stripe.createCharge      compensation declared
✗ block    sql   TRUNCATE audit_log       no undo exists

# the run went sideways — preview the undo, drift-checked
$ gmonk reverse-run 8f3a --dry-run
✓ ready    file  src/api/billing.ts       restore snapshot
✓ ready    sql   accounts (id=1)          +30, concurrency-safe
  sql   users (id=5)             changed since — skipped
✗ blocked  extl  stripe.charge            needs a human

$ gmonk reverse-run 8f3a
↩ reversed 9 · drift untouched · 1 held for review

How it works

gmonk sits in the connection.

The agent thinks it's talking to your database. It's actually talking to gmonk, which records how to undo each write before passing it through — and refuses the writes it couldn't undo.

Your agent
UPDATE accounts SET balance = balance - 30 WHERE id = 1 TRUNCATE audit_log
gmonk — in the connection
reversibility oracle
can this be undone? ✓ reversible — capture first ✗ no undo exists — refuse
Postgres / MySQL
accounts id=1
balance 120 balance 90
Journal — append-only, hash-chained
waiting… accounts(id=1).balance = 120  ·  undo ready

Every statement is classified before it runs. Reversible writes are journalled with their before-image and then forwarded; irreversible ones are refused at the wire. Step through it below.

Your agent's connection string points at gmonk, not at the database. Every statement arrives here first.

The reversibility oracle parses the statement and asks one question — can this be undone?

Reversible. Before anything runs, gmonk reads the exact rows the statement will touch and records their before-image.

Only now is the statement forwarded. The capture and the write commit together, so a journal entry can never go missing.

A statement with no possible undo — TRUNCATE, DROP, a DELETE with no WHERE — is refused at the wire. It never reaches the database.

On reverse-run, gmonk re-reads the live row, confirms nothing else has changed it, then writes the before-image back.

Two channels, one timeline

The diagram above is the database channel. There's a second one, and both land in the same run with the same undo.

Channel 1 · your database

The wire proxy

gmonk protect

Postgres and MySQL. Sits in the connection, so it both prevents and captures. The main path.

  • Can't run a proxy? gmonk protect-db captures out-of-band via WAL or triggers. Undo, but no prevention — they're not in the write path.
  • Close the door. gmonk enforce revokes the agent's direct write grants, so the proxy is the only way in.

Channel 2 · your agent

The capture hook & MCP gateway

gmonk install-hook · gmonk run

Everything the agent does outside the database: file writes, shell commands, MCP tool calls.

  • Files are snapshotted, so an edit or delete restores exactly.
  • Shell commands that gmonk couldn't undo — reaching outside the workspace, or dd/mkfs — are paused for your approval before they run.

External effects are different again. A charge has no before-state to restore, so it's reversed by a compensating call you declare — and gmonk never calls a third party on its own. Undeclared, it's flagged for a human.

The agent doesn't need to be malicious to wreck production.

Three failure modes, again and again. None of them require bad intent.

  1. 01

    One bad query

    A confused or prompt-injected agent runs a DELETE with no WHERE. It commits before anyone reviews it.

  2. 02

    Backups are the wrong tool

    A snapshot restore throws away every legitimate write since. You want the damage gone, not the whole database back.

  3. 03

    You can't see what it did

    The run is over by the time you notice. What changed? Which rows? Can it be undone at all?

What gmonk is

Two things a backup can't do: prevent, and precisely reverse.

Not "is this allowed?" but "can this be undone?" — a property of the action itself. That one question drives both halves.

Prevention

The reversibility gate

The reversibility oracle scores every write before it runs. block mode refuses what it can't undo; guarantee mode rolls the write back unless the undo is provable.

  • Blocks DROP, TRUNCATE, no-WHERE deletes at the wire
  • Pauses shell commands it couldn't undo
  • Holds risky actions — approve or deny from Slack

Recovery

Drift-aware, per-action undo

The before-state is captured as each change happens. Before undoing, gmonk checks the live system and refuses to clobber anything a human changed since.

  • A whole run, or one action and only its dependents
  • Undoes the operation, so concurrent writes survive
  • Every reversal is itself recorded

Not just your database

Every action an agent takes — captured, gated, reversible.

Not just SQL — files, shell commands, object storage and paid APIs.

Database rows Postgres & MySQL INSERT, UPDATE, DELETE — with the before-image Restore by primary key, or replay the inverse — which keeps concurrent writes.
Files the agent's workspace Create, modify, delete — content snapshots Restore, recreate or delete, exactly.
Shell commands gated before they run Every invocation, scored for recoverability The ones it couldn't undo pause for approval instead.
Object storage S3 / MinIO Put and delete, by version Restore the prior version, after a drift check.
External effects charges, SaaS resources The call, plus the fields you declare A compensating call you define. Undeclared → flagged.
Schema changes DROP · TRUNCATE · ALTER Refused before they run No undo exists. That is why the gate blocks them.

See what can and can't be reversed

Why reversibility

Anyone can block on a rule. gmonk blocks on whether it can put things back.

Policy engines answer "is this allowed?" — a list someone has to keep correct. gmonk answers "can this be undone?" — a property of the action itself. That's a guarantee you don't have to author, and it welds prevention to recovery: the same engine that scores an action pre-flight is the one that reverses it after.

Reversible

Before-state captured, system unchanged. One-click undo, exactly.

Reversible but drifted

Something changed since. gmonk preserves the concurrent write and flags the conflict rather than clobbering it.

Irreversible

No safe undo exists. This is exactly what the gate refuses to run in the first place.

In the image

What ships when you pull gmonk.

Two capture channels
A wire proxy for the database; a hook or MCP gateway for the agent.
Pre-flight gate
Advise, block, or prove-then-commit. Risky actions hold for approval in Slack.
Drift-aware undo
A live check before every reversal. Never clobbers a change it didn't make.
Causal excise
Undo one action and only its dependents. Independent work is untouched.
Tamper-evident audit
A hash chain. Every reversal is itself recorded, and a write that skips the gate is still caught.
Self-hosted
One Docker image and your Postgres. Nothing leaves your network.
Review UI
Browse runs, inspect diffs, preview an undo, apply it.

Quick start

Protect a database in one command.

  1. Put your database URL in an env var.
  2. Run gmonk in front of it with capture on.
  3. Point the agent at gmonk instead of the database.
Full install guide
bash
# your database URL lives in an env var (never passed on the CLI)
export APP_DB_URL=postgres://user:pw@db-host:5432/appdb

# run gmonk in front of your DB with undo capture ON
gmonk protect --backend-ref APP_DB_URL --listen 6432

# then point your agent at gmonk instead of the database:
#   postgres://agent@localhost:6432/appdb

Questions

Before you install.

Deeper detail lives in the documentation — capture modes, the gate, drift semantics, and the CLI.

What is gmonk?

gmonk is a self-hosted safety and disaster-recovery layer for AI agents. It sits in front of an agent's actions on your database, files, and external APIs, records each one, blocks the ones that can't be undone, and lets you reverse a run — per action and drift-aware — when the agent misbehaves.

How is gmonk different from a database backup?

Backups are all-or-nothing and blind to individual agent actions. gmonk captures the before-state of every single write as it happens, so you can undo exactly the damage — one action, or one action plus only its dependents — without rolling the whole database back to a snapshot. It also checks live drift first and refuses to clobber changes it didn't make.

Does gmonk send my data anywhere?

No. gmonk is fully self-hosted. It runs as a Docker image inside your own infrastructure against your own Postgres or MySQL database. Your code, prompts, and data never leave your network.

How does gmonk attach to my system?

Through two separate channels. For a database — the main use — gmonk runs as a wire proxy in the connection: the agent thinks it is talking to Postgres or MySQL but is actually talking to gmonk, which gates each statement and records how to undo it before passing it through. If you cannot run a proxy in front of the database, gmonk can instead capture out-of-band from the write-ahead log or from in-database triggers, which gives you undo but not prevention. Separately, for what an agent does outside the database — file writes, shell commands and MCP tool calls — gmonk installs a capture hook into Claude Code, or runs as an MCP gateway for agents that speak tool calls. In gmonk, the word proxy always means the database one; the MCP gateway is a different interception point and is not a proxy.

Can gmonk stop an agent from running a destructive query?

Yes. gmonk's reversibility oracle scores how recoverable each action is before it runs. In block or guarantee mode it refuses statements it can't undo — DROP, TRUNCATE, a DELETE with no WHERE clause — at the wire, before they reach the database.

Give your agents write access.
Keep the undo button.