Skip to content

feat: /careful skill — destructive command warnings hook #3

Description

@josephfung

Idea

Add a /careful skill that activates a PreToolUse hook intercepting destructive shell commands before they execute. Rather than hard-blocking, the hook returns {"permissionDecision":"ask","message":"..."} so Claude pauses and asks for confirmation — giving the user override capability while preventing accidental damage.

Goal

Catch common high-impact mistakes before they happen: force-pushing, dropping tables, recursively deleting files, pruning containers. Particularly valuable in terminal-heavy workflows or when working near production systems.

Commands to intercept

  • rm -r / rm -rf (with safe-exceptions for node_modules, dist, .next, coverage, tmp)
  • git push --force / git reset --hard / git checkout .
  • DROP TABLE / TRUNCATE
  • docker rm -f / docker system prune
  • kubectl delete

Implementation approach

  1. Add skills/careful/SKILL.md — skill prompt that activates the hook when invoked via /careful
  2. Add hooks/check-careful.shPreToolUse bash script that:
    • Matches the incoming command against destructive patterns
    • Checks a safe-exceptions list (build artifact dirs, etc.)
    • Returns {"permissionDecision":"ask","message":"Destructive pattern detected: <pattern name>. Confirm?"} on match
    • Logs the pattern name (never the full command) to ~/.claude/sysops/usage.jsonl
  3. Register the hook in settings/hooks.json scoped to the skill (not always-on like no-chaining)
  4. Update install.sh to handle skill-scoped hook registration

Notes

  • Warn-and-confirm (not deny) is the right UX here — the user should be able to override
  • Log pattern names only, never command content, for privacy
  • Complements the existing no-chaining hook (different concern: safety vs. discipline)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions