Skip to content
DevBuildKit
AgentsSkillsCommandsPacksPricingDocsBlogTools
Log inGet DevBuildKit

Block Destructive Commands

Stops irreversible shell commands before they run — recursive deletes of /, ~, . or $HOME, force-pushes to main/master, hard resets to a remote ref, DROP DATABASE, recursive world-writable chmod, mkfs and dd onto block devices — and tells the model a safer alternative.

HookFreev1.0.0
  1. Hooks
  2. Block Destructive Commands

What it does

Stops irreversible shell commands before they run — recursive deletes of /, ~, . or $HOME, force-pushes to main/master, hard resets to a remote ref, DROP DATABASE, recursive world-writable chmod, mkfs and dd onto block devices — and tells the model a safer alternative.

Category
securitysafetygit
Platforms
any
Capabilities
guardrailcommand-filtering

Example tasks

  • “The agent proposes a force-push to main to fix a bad merge and is steered to git revert or a pull request.”
  • “A cleanup script ends up deleting the working directory and the hook stops it before anything is removed.”
  • “The agent tries a hard reset to origin/main with uncommitted work present and is told to stash or inspect the diff first.”

Works with

Recommended alongside

  • Git Workflow· skill
  • Protect Secrets· hook
  • Release Gate· hook

Permissions summary

  • Files

    Reads files only

  • Shell

    No shell commands

  • Network

    No network

Permissions are declared in the component manifest and compiled into each client's tool list. Components are built for least privilege.

Supported environments

ClientSupportInstalled as
Claude CodeNative.forgekit/hooks/<id>/ + .claude/settings.json
OpenAI CodexNot supportedSkipped (reported at install)
CursorNot supportedSkipped (reported at install)
VS Code (Copilot)Not supportedSkipped (reported at install)
Generic markdownAdapterdocs/forgekit/hooks/<id>.md

Claude Code is the native reference. Other clients use adapters, so behaviour is close but not identical. See the compatibility matrix.

Included in packs

  • engineering
  • security

Full hook (free preview)

This is a free component, so its complete content is public. It is exactly what gets installed (before client-specific formatting).

block-destructive-commands

A PreToolUse guardrail for the Bash tool that refuses a short, explicit list of commands whose damage cannot be undone from inside the session. Each refusal is a single stderr line that names the reason and suggests a safer alternative, so the model can recover without asking you.

What is blocked

PatternWhySuggested alternative
Recursive rm of /, /*, ~, $HOME, ., ./*, .., a bare *, $PWD, or system directories (/etc, /usr, /var, /home, ...); any rm --no-preserve-rootWipes the machine, the home directory or the working treeDelete explicit sub-paths, preview with git clean -n
git push with --force, --force-with-lease or +ref to main, master or trunk (the current branch is read from .git/HEAD when no refspec is given); deleting those branches; --mirrorRewrites shared historyPull request, git revert; on feature branches --force-with-lease is allowed
git reset --hard onto origin/..., upstream/..., @{u} or FETCH_HEADDiscards local commits and uncommitted workStash first, inspect git diff HEAD..origin/<branch>, then merge or rebase
DROP DATABASE (any case) and dropdbDeletes a databaseThrowaway local database, or a human after a verified backup
Recursive chmod with mode 777 or a+rwxWorld-writable trees break SSH and expose filesGrant the minimum, for example u+rwX,go+rX
mkfs*, mke2fsFormats a filesystemHuman-run, on a verified device
dd of=/dev/... (except /dev/null, /dev/zero, /dev/stdout) and redirects onto block devicesOverwrites a diskWrite to an image file
find / -delete, find ~ -deleteMass deletionScope to a project directory, dry-run first

Wrappers are unwrapped: sudo, env, time, bash -c "...", eval, $(...), ;, && and pipes are all inspected.

What is deliberately allowed

rm -rf ./build, rm -rf node_modules, plain git push origin main, git push --force-with-lease on a feature branch, git reset --hard HEAD, chmod 777 single-file.sh, dd of=./disk.img. The hook only blocks clear matches so it does not train people to turn it off.

Fail-safe behaviour

Empty or malformed input exits 0 with a note. The only filesystem access is reading .git/HEAD to learn the current branch; nothing is spawned and nothing touches the network.

Disable or extend

Remove the block-destructive-commands entry ForgeKit added to .claude/settings.json. To add a project-specific rule, edit checkSegment in scripts/block-destructive-commands.mjs and add a case to scripts/block-destructive-commands.test.mjs. Run the tests with node --test "registry/hooks/block-destructive-commands/scripts/*.test.mjs".

Version and changelog

Latest version 1.0.0. Requires DevBuildKit CLI 1.0.0 or newer.

Changelog — Block Destructive Commands

1.0.0

  • Initial release.

Build with this hook

Create Demo Project

Install in CLI

$ devbuild add hook block-destructive-commands

Free. Needs a free account: run devbuild login once.

IDblock-destructive-commands
Version1.0.0
TierFree
EventPreToolUse
DevBuildKit

Your entire AI development team. One install.

DevBuildKit never uploads your source code. Telemetry is opt-in and anonymous.

Product

  • Agents
  • Skills
  • Commands
  • Packs
  • Features
  • Live demo
  • Pricing

Learn

  • Documentation
  • Getting started
  • CLI reference
  • Blog
  • Changelog
  • Compare

Free tools

  • All tools
  • Agent generator
  • Config converter
  • Stack detector
  • Context analyzer

Use cases

  • Android development
  • iOS development
  • SaaS development
  • Backend development
  • App Factory
  • Game development

Company

  • Terms
  • Privacy
  • Refunds
  • Log in
  • Sign up

© 2026 DevBuildKit. All rights reserved.

DevBuildKit is an independent product. Claude, Claude Code, Anthropic, OpenAI, Codex, ChatGPT, Cursor, Visual Studio Code, GitHub Copilot, Microsoft and all other product names are trademarks of their respective owners. DevBuildKit is not affiliated with, endorsed by or sponsored by any of them; names are used only to describe compatibility.