DEV Community

Cover image for My coding agent almost wiped my git repo. Here's what I built to stop it.

My coding agent almost wiped my git repo. Here's what I built to stop it.

LOI CHIANG HAO on November 09, 2026

Recently, I made the mistake of trusting an autonomous coding agent with full terminal permissions on a personal open-source project. I had over a...
Collapse
 
alexcodebytes profile image
Oleksandr •

The anti-thrashing watchdog is the piece I haven't seen anywhere else, and it's solving the most expensive failure mode. An agent that oscillates is burning tokens and your trust in the tool, and "same patch proposed three times" is a clean signal that it has no model of the problem.

One question about the firewall: how are you handling compound commands? rm -rf ./build is usually fine, rm -rf / is not, but curl ... | bash or a script that internally does a git reset won't match a pattern — does the harness intercept at the shell level, or is it catching what it can and trusting the rest?

Also genuinely nice to see zero telemetry on something that has to sit between an agent and a repo. That's the right default for a tool this invasive.

Collapse
 
hao610 profile image
LOI CHIANG HAO •

Thanks Oleksandr! Thrashing truly is the most expensive money-pit in autonomous agent workflows.

On your firewall question for compound commands (curl ... | bash, subshells, && chains):
Regex matching was completely insufficient for this. In v1.0.5, the execution firewall uses shlex lexical decomposition to tokenize pipeline chains, subshells ($(...)), and process substitutions before execution. If a command stream contains piped execution sinks (like curl/wget | sh/bash) or compound traversal (rm -rf with un-sanitized root target paths), the entire execution graph is halted before touching the OS.

And on zero telemetry: 100% agreed. A safety harness sitting between an LLM and production source code has zero business phoning home. git-oops remains pure Python, zero-dependency, and strictly air-gapped on your local machine.

Detailed the full v1.0.5 pipeline here if you're curious: dev.to/hao610/i-posted-a-v020-cli-...

Collapse
 
alexcodebytes profile image
Oleksandr •

Using shlex lexical decomposition instead of regex for an execution firewall is such a pro move. Regex will always fail on complex subshells and chained commands—trying to parse bash with regex is a losing battle. Catching curl | bash before it ever touches the OS is exactly what autonomous agents need. And "zero telemetry" with an air-gapped local machine? Instantly sold.

Thread Thread
 
hao610 profile image
LOI CHIANG HAO •

Thanks Oleksandr! That means a ton coming from you.

Parsing bash with regex really is a fool's errand once agents start chaining subshells and pipes, so getting shlex lexical analysis in place was non-negotiable for v1.0.5. And keeping it strictly air-gapped with zero telemetry is a promise we'll never compromise on.

Appreciate the validation and feedback — it directly shaped this architecture!

Thread Thread
 
alexcodebytes profile image
Oleksandr •

You're very welcome! You're absolutely right—trying to parse bash with regex is a ticking time bomb once agents start getting creative. shlex gives you the deterministic control you need to actually understand the command graph before it hits the OS. And the air-gapped, zero-telemetry approach is a massive selling point. Excited to see how v1.0.5 handles edge cases!

Thread Thread
 
hao610 profile image
LOI CHIANG HAO •

Spot on! "Command graph" is the exact mental model we designed it around—treating agent executions as structured intent rather than arbitrary string blobs.

Really appreciate the great dialogue, Oleksandr. If you run into any wild edge cases while experimenting with v1.0.5, issues and PRs are always welcome on GitHub: github.com/Hao610/git-oops

Thanks again for the awesome exchange!

Collapse
 
max_quimby profile image
Max Quimby •

"Context window asphyxiation" is a great name for a failure I've watched happen more than once — a single command dumps a 3,800-line stack trace and the agent's judgment just dissolves in the noise. Structuring and truncating tool output is one of the most underrated safety levers there is; a tool that returns "187 failures, here are the 3 distinct root errors" instead of the raw wall changes the agent's behavior completely, before any firewall is involved.

The 18-turn edit-revert oscillation is the one I'd dig into most. How does the watchdog decide it's a loop versus slow-but-real progress? We've had reasonable luck hashing the (file, diff) pairs and tripping when the same state recurs N times, but it's fragile — the agent makes a cosmetically different edit that's semantically the same and the hash misses it. Curious whether git-oops keys on the command, the resulting tree state, or something about the test outcomes. And did you consider snapshotting to a shadow ref before any reset --hard rather than blocking it outright?

Collapse
 
hao610 profile image
LOI CHIANG HAO •

Hey Max, really appreciate this sharp insight. You hit the exact failure mode that kept me awake after v0.2.0.

In v1.0.5, we evolved this in two major ways:

  1. Semantic vs. Cosmetic Oscillation: Exact (file, diff) hashing indeed failed when agents changed variable names or spacing. In v1.0.5, the watchdog parses and hashes the normalized AST (Abstract Syntax Tree) alongside a sliding window of test outcome signatures. If the AST delta cycles back to a topologically identical state within 3 turns, it trips regardless of cosmetic formatting changes.
  2. Shadow Refs over Outright Block: You called it. Blocking reset --hard outright broke legitimate agent cleanup. We introduced --shadow workspace isolation and an automated flight recorder snapshot mechanism. Every touch to a file now drops an ephemeral blob into a local snapshots directory, and git-oops --salvage performs an automated reflog autopsy to resurrect any orphaned tree state instantly.

I just wrote up the full technical breakdown in our v1.0.5 release post if you'd like to check out the architecture: dev.to/hao610/i-posted-a-v020-cli-...