Guard the code VS Code AI agents write
VS Code’s agent integrations write to your repository with your local privileges. The model deciding what to write has no knowledge of which secrets are live, which auth checks matter, or what your team has decided must not change.
The Mergen extension checks each edit against the same deterministic detectors every other surface uses, on your machine, and reverts the ones that break policy. VS Code offers no pre-write hook, so this is detect-and-revert: the edit lands briefly, then is undone.
What is covered, precisely
- Plain VS Code has no AI-agent hook at the platform level, so the Mergen VS Code extension watches every text-document change directly and reverts a flagged edit right after it lands: a detect-and-revert, not a pre-write block.
- The extension does not see commands. Terminal commands, and commands an agent runs, are outside this surface: use an agent with a pre-execution hook (Claude Code, Cursor, Windsurf, Codex) or `mergen-server exec -- <cmd>`.
- Because the extension cannot tell a person’s keystrokes from an agent’s, rules you author for specific files apply to agent edits on the hooked surfaces, not here.
- The extension also adds status, account sign-in, and approvals for the local server.
Set up in two minutes
Install the server
npm install -g mergen-serverStart the gate
mergen-server startInstall the Mergen extension
code --install-extension OmerTahtaci.mergenWhat gets stopped
An edit adding a live API key (sk_live_…)Structural secret: reverted right after it lands.
An edit removing an authorization checkHeld before the write on Claude Code and Windsurf; in VS Code, reverted.
An edit that deletes or skips testsHeld on the pre-write surfaces; in VS Code, reverted.
Human-in-the-loop approvals
In VS Code a flagged edit is reverted, not held: there is nothing to approve before the write. The panel shows what was reverted and why, and every decision lands in the audit ledger.