Skills

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 global permission-request.js hook 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:

PatternRisk
rm -rf / rm -rRecursive deletion
DROP TABLE / DROP DATABASESQL data loss
TRUNCATESQL data destruction
git push --force / git push -fRemote history rewrite
git reset --hardLocal history loss
git clean -fUntracked file deletion
git checkout . / git restore .Discard all changes
chmod 777World-writable permissions
curl or wget piped to a shellPiped remote execution
> /dev/sda / dd if=Disk-level operations
:(){ :|:& };:Fork bombs
sudo rmElevated 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:

  1. Set the allowed path (absolute or relative to repo root)
  2. Every Edit/Write call checks if the target file is inside the allowed path
  3. 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/)
Read the whole SKILL.md on GitHub

More in AI and agents