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
| Part | What to use | Status | Link |
|---|---|---|---|
| Allow, ask and deny rules | Permission rules in the agent settings | Documented: vendor or primary source, not tried (no linked trial) | How do I stop OpenCode running risky commands without approval? |
| Prove the block works | Test a permission hook with a canary | Untried: community post or suggestion only, no linked trial | How do I check my Claude Code permission hook really blocks? |
| Run it somewhere safe | Where the agent should run instead of your home folder | Documented: vendor or primary source, not tried (no linked trial) | My agent wiped my home folder or drive: where should it run instead? |
| Sandbox the commands | Local sandbox for agent commands | Documented: 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 reset | Recover and block it | Documented: 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 changed | What to add before agent edits | Documented: vendor or primary source, not tried (no linked trial) | Can /rewind undo what Claude Code deleted? What to add |
| Container cleanup commands | Guardrails for prune and compose | Documented: 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 deleted | No tested answer yet | No tested answer yet | none (see open request) |
Where it breaks
- Hook exists but the command still runs -> How do I check my Claude Code permission hook really blocks?
- Work lost to a reset -> My agent ran git reset --hard and wiped my changes: recover and block
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.