feat(guardrails): block destructive git commands (bash_destructive_git) #116
Reference in New Issue
Block a user
Delete Branch "feat/guardrails-destructive-git"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
New always-scope guardrail rule
bash_destructive_git(block | warn | off; absent key means block) in the opencode plugin. It blocks history-destroying git commands even in a worktree and with no active boulder:reset --hard|--keep|--mergecleanwith-f/--forcecheckout -f,checkout .,checkout <ref> -- .restorewith pathspec.branch -D/branch -f,switch -fupdate-ref -d,reflog expire|delete,gc --prune=nowAllowed (pinned by tests):
git checkout <ref> -- <file>,git restore --source=<ref> -- <file>,git revert,git reset <path>, read-only commands,clean -n.Why
2026-10-10: a worker asked to restore one file ran
git reset --hard origin/mainin the classifier-reliability worktree and moved the branch off 8 commits. They survived only via the reflog. No existing rule objected (bash_bannedhas no--hard;bash_main_checkoutonly fires in the main checkout).Notes
--git-dir /xand--work-tree /x.bash -c '...'wrappers are not inspected (shared with the other bash rules).reset --hardis blocked too, on purpose: the log line is the signal for the operator to decide.ALWAYS_RULESupdated; hook-level test proves the wiring (mutation evidence in commit794f70d)..omo/guardrails.jsonuntouched.Verification
cd deploy/opencode-plugin && node --test: 436 tests, 0 fail (baseline was 328). Merges cleanly with current origin/main (checked withgit merge-tree).Install (operator)
then restart opencode (plugins load at process start). This branch's version is already installed locally.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR