published fresh until

How do I stop my coding agent running destructive commands: rm, reset, prune, sandbox?

Summary When an agent may run destructive commands or delete work, combine permission rules, tested blocks, a sandbox, recovery steps, and container guardrails. Recovering deleted untracked files has no tested answer yet.

Not for leaked keys, see case-leaked-secret-env-committed-agent-reads-env-git-protection; database resets, see case-database-schema-change-production-prisma-postgres-neon-locks

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The case

Your agent ran a command that deleted files, reset changes or pruned containers. Success looks like: risky commands blocked or asked about, a block you tested, a sandbox for the agent, and a recovery path when it happens anyway. Stack: Claude Code, OpenCode, Copilot CLI, Docker.

This is a map, not new advice: every row points to an existing WhatWorks thread. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report, and none of the linked threads has one yet.

Parts, in the order people do them

PartWhat to useStatusLink
Allow, ask and deny rulesPermission rules in the agent settingsDocumented: vendor or primary source, not tried (no linked trial)How do I stop OpenCode running risky commands without approval?
Prove the block worksTest a permission hook with a canaryUntried: community post or suggestion only, no linked trialHow do I check my Claude Code permission hook really blocks?
Run it somewhere safeWhere the agent should run instead of your home folderDocumented: vendor or primary source, not tried (no linked trial)My agent wiped my home folder or drive: where should it run instead?
Sandbox the commandsLocal sandbox for agent commandsDocumented: vendor or primary source, not tried (no linked trial)How do I sandbox the commands GitHub Copilot CLI runs on my machine?
After a hard resetRecover and block itDocumented: vendor or primary source, not tried (no linked trial)My agent ran git reset --hard and wiped my changes: recover and block
Rewind misses files only Bash changedWhat to add before agent editsDocumented: vendor or primary source, not tried (no linked trial)Can /rewind undo what Claude Code deleted? What to add
Container cleanup commandsGuardrails for prune and composeDocumented: vendor or primary source, not tried (no linked trial)Stop your agent running docker system prune on a whim, and get saner Compose files, with Docker's official skills
Recover untracked files that were deletedNo tested answer yetNo tested answer yetnone (see open request)

Where it breaks

Open questions

  • Parts marked "No tested answer yet" are gaps in WhatWorks; ask for them with the request tool so an editor can look: recovering deleted files that were never committed.

Sources

Each linked WhatWorks thread cites its own primary sources; this page adds none of its own. Status labels were read from the linked thread pages on 19 October 2026.

As of October 2026. leaked secrets, see case-leaked-secret-env-committed-agent-reads-env-git-protection; database reset commands, see case-database-schema-change-production-prisma-postgres-neon-locks.

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I stop my coding agent running destructive commands: rm, reset, prune, sandbox?
Summary: When an agent may run destructive commands or delete work, combine permission rules, tested blocks, a sandbox, recovery steps, and container guardrails. Recovering deleted untracked files has no tested answer yet.
Copy for agent
get the whatworks thread case-stop-agent-destructive-commands-rm-reset-prune-permissions-sandbox and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-stop-agent-destructive-commands-rm-reset-prune-permissions-sandbox
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks