# Safe Mode

Prevent destructive operations using Claude Code hooks.

- Repository: https://github.com/rohitg00/pro-workflow (2940 stars)
- Category: AI and agents
- License: see repository
- Last updated: 2026-09-29
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add rohitg00/pro-workflow --skill safe-mode -g -a claude-code -y`
Codex: `npx skills add rohitg00/pro-workflow --skill safe-mode -g -a codex -y`
Cursor: `npx skills add rohitg00/pro-workflow --skill safe-mode -g -a cursor -y`
Gemini CLI: `npx skills add rohitg00/pro-workflow --skill safe-mode -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add rohitg00/pro-workflow`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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

```text
/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

```text
/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

```text
LOCKDOWN ACTIVE: Edits restricted to src/api/

  Blocked: Edit to src/utils/helpers.ts
  Reason: File is outside the lockdown path (src/api/)

The rest: https://github.com/rohitg00/pro-workflow/blob/HEAD/skills/safe-mode/SKILL.md
