Safe Mode
Prevent destructive operations using Claude Code hooks.
Install
npx skills add rohitg00/pro-workflow --skill safe-mode -g -a claude-code -y- Repository
- rohitg00/pro-workflow2.9k
- Category
- AI and agents
- Updated
- 1mo ago
- License
- See repository
- Context cost
- Lightabout 1,304 tokens
- Runs scripts
- No, instructions only
What it does
Prevent destructive operations using Claude Code hooks. Three modes, cautious (warn on dangerous commands), lockdown (restrict edits to one directory), and clear (remove restrictions). Uses PreToolUse matchers for Bash, Edit, and Write.
Safe Mode
Three levels of protection against destructive operations during AI coding sessions.
Note: These hooks are skill-scoped, they only activate when you invoke
/safe-mode. The globalpermission-request.jshook in hooks.json provides always-on alerting for dangerous commands. Safe-mode adds opt-in blocking and directory restrictions on top of that.
Modes
Cautious Mode
/safe-mode cautious
Intercepts Bash commands before execution. Warns on dangerous patterns but does not block, the user decides.
Flagged patterns:
| Pattern | Risk |
|---|---|
rm -rf / rm -r | Recursive deletion |
DROP TABLE / DROP DATABASE | SQL data loss |
TRUNCATE | SQL data destruction |
git push --force / git push -f | Remote history rewrite |
git reset --hard | Local history loss |
git clean -f | Untracked file deletion |
git checkout . / git restore . | Discard all changes |
chmod 777 | World-writable permissions |
curl or wget piped to a shell | Piped remote execution |
> /dev/sda / dd if= | Disk-level operations |
:(){ :|:& };: | Fork bombs |
sudo rm | Elevated deletion |
What happens: the hook returns a permission ask, so Claude Code shows you a prompt that names the pattern, for example Safe mode: rm with -r or -f. You approve or reject the command. This prompt appears even in auto mode.
Lockdown Mode
/safe-mode lockdown <path>
Restricts Edit and Write operations to a single directory tree. Prevents accidental changes to unrelated code.
How it works:
- Set the allowed path (absolute or relative to repo root)
- Every Edit/Write call checks if the target file is inside the allowed path
- Operations outside the path are blocked with an explanation
LOCKDOWN ACTIVE: Edits restricted to src/api/
Blocked: Edit to src/utils/helpers.ts
Reason: File is outside the lockdown path (src/api/)

