Skip to content

feat(hooks): dangerous-actions-blocker — PreToolUse hook for blocking destructive CLI ops #1007

Closed as not planned

Description

@ousamabenyounes

Proposal

A ready-to-use PreToolUse Bash hook that intercepts dangerous commands before execution in Claude Code (and compatible AI agents). Shipped as a file in hooks/claude/ that users can copy into their .claude/hooks/ config.

What it blocks/asks

Category Action Decision
Files rm -rf /, rm -rf ~, rm -rf .. 🚫 block
Files rm -rf <other> (except safe dirs like node_modules, dist, .next) ⚠️ ask
Git git push --force (but allows --force-with-lease) 🚫 block
Git git push -f 🚫 block
Git git reset --hard, git clean -f, git checkout -- ., git branch -D ⚠️ ask
Secrets cat .env, echo $ANTHROPIC_API_KEY=..., reading .pem/.key files 🚫 block
Database DROP TABLE, TRUNCATE, DELETE FROM x; 🚫 block
Docker docker system prune -a, mass docker rm -f ⚠️ ask

Container-aware

Commands inside docker exec / kubectl exec skip host-path safety checks (paths resolve inside the container, not the host).

Integration

// .claude/settings.json
{
  "hooks": {
    "PreToolUse": [
      { "matcher": "Bash", "hooks": ["bash hooks/claude/dangerous-actions-blocker.sh"] }
    ]
  }
}

Questions for the team

  1. Is this in scope for RTK? Or does it belong in a separate repo / community hooks collection?
  2. Overlap with existing features? Does RTK already plan a built-in safety layer (e.g., via the rewrite hook or TOML filters)?
  3. Regex vs structured parsing? Current approach uses grep -qE on the raw command string — works but can false-positive on edge cases. Would a Rust-based approach be preferred?
  4. Default decisions — should rm -rf outside safe dirs be block or ask?

Happy to implement whichever direction you prefer. I have a working prototype ready to go once we align on scope.

Activity

  1. added
    effort-medium
    and removed on Apr 4, 2026
  2. pszymkowiak commented on Apr 4, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    ✨ Category feature
    🟡 Priority medium
    🎯 Confidence 88%

    Summary

    Feature request for a community-contributed PreToolUse hook that intercepts and blocks dangerous CLI operations (rm -rf, force push, secret exposure, DROP TABLE, etc.); author has a working prototype but seeks scope/design alignment before submitting a PR.

    📁 Relevant files
    • hooks/claude/dangerous-actions-blocker.sh
    • .claude/settings.json

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. fdambrosio commented on Aug 5, 2026

    @fdambrosio

    I agree, we need this feature

  4. KuSh commented on Nov 8, 2026

    @KuSh
    Collaborator

    Thanks for raising this. Having rtk block, refuse or ask for confirmation before commands it considers dangerous is outside what RTK Open Source takes on: it is covered by RTK Pro Policies (https://pro.rtk-ai.app/), and the contributing guide lists it as out of scope for the open-source core, which focuses on token savings and harness optimization (https://github.com/rtk-ai/rtk/blob/develop/CONTRIBUTING.md#out-of-scope). Closing it on that basis. If you think your case falls outside that line, you can reach the maintainers on Discord to discuss it: https://discord.com/invite/RySmvNF5kF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:securityeffort-mediumenhancementhelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions