DEV Community

JEONSEWON for Boxdawn

Posted on

My pre-run check for Claude Code lets rm -rf src through. Since 0.4.18, it keeps a copy first.

I build guard, a pre-run check for the shell commands Claude Code runs. Before a command runs, guard denies it with a reason, asks you, or gives no decision. With no decision, your own Claude Code permission settings decide.

Some deletes get no decision on purpose. Run inside the project folder, these all pass guard without a word:

rm -rf src
rm -rf ./src ./tests
Remove-Item -Recurse -Force src
Enter fullscreen mode Exit fullscreen mode

Deleting inside your own project is ordinary work, so guard leaves it to your permission settings. But that leaves a gap: if the agent deletes the wrong folder inside the project, guard had nothing to say.

0.4.18: undo, on by default

Before each Bash or PowerShell command in Claude Code, guard copies the project folder's files on this PC, including ignored files like .env. The copies stay on this PC.

If something inside the project goes missing:

  1. Run /boxdawn-guard:undo. It lists the copies.
  2. Pick one. guard asks you to approve its own undo restore line; that's the approval.
  3. guard saves the current state first, then restores. So a restore can be undone too.

To turn it off, use the undo option in /plugin.

What it costs

On the projects I measured, under a second per command: 57 MB took 0.3 s, 632 MB took 0.75 s. The most is about 5 seconds. A folder with tens of thousands of subfolders takes about 3.5 s per command, and its copies are often not ready in time. A large project makes its first copy when the session starts (632 MB took 82 s), and commands before that aren't covered.

What it doesn't cover

  • Only files inside the project folder.
  • Not .git (commits, branches, stash), not node_modules and similar, not files over 50 MB.
  • Not databases, cloud resources, or anything outside the folder.
  • A session opened directly in your home folder, a drive root, Desktop, Documents, Downloads or OneDrive makes no copies. A project folder inside them works.
  • It's for agent mistakes, not for an agent working against you. An agent can read and damage the copies too.
  • The Copilot CLI edition makes no copies.

If you turned undo on before 0.4.18

The option that makes guard ask less about git reset --hard and similar commands is now separate and off by default. Turn on undo_instead_of_git_asks if you want it.

0.4.19: a line per deny and ask

Each time a guard rule denies or asks, guard writes one line on this PC: when, which tool (Bash or PowerShell), the decision, the rule name, and whether the target was inside or outside the project. No command, no path, no reason text. This record is sent nowhere, on any plan.

/boxdawn-guard:log shows the last 30 days counted by rule, plus the last 20 lines. This is the raw output from an isolated test; in a session, Claude explains it in your language:

Boxdawn guard: 2 deny and ask decisions on this machine, last 30 days.
No command or path is kept: only when, which tool, the decision and the guard's rules.

By reason (a decision with several reasons counts under each):
      2  deny  dd.outside  dd writing outside the project  (last 2026-11-25 11:53)

Last 2:
  2026-11-25 11:53  deny  Bash        dd.outside
  2026-11-25 11:53  deny  Bash        dd.outside
Enter fullscreen mode Exit fullscreen mode

It's on by default; the judgment_log setting turns it off. Daily files older than 30 days are deleted either way. Read and Grep decisions aren't logged. The Copilot CLI edition keeps no log.

0.4.19 changes no rule and no judging code. The rules are byte-for-byte the same as 0.4.18. It doesn't make guard safer. It makes what guard did visible.

Repo and install: https://github.com/boxdawn/guard

When an agent deleted something of yours, was it inside the project folder or outside?

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.