rtk-ai / rtk-ai/rtk

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

Open
#1,007 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli area:security effort-medium enhancement help wanted priority:medium
Dominant language
Rust
Stars
81k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed hooks/claude/dangerous-actions-blocker.sh prototype and its .claude/settings.json PreToolUse integration. Check the raw-command grep -qE approach, container-aware behavior, and the listed block/ask rules, then resolve the scope, implementation language, and default decisions with the team before defining completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, rust
Domain
cli, devtools, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.