safe-mode

Intercepts destructive Bash commands and restricts Edit and Write operations using PreToolUse hooks.

1|Updated May 6, 2026
One-click install
npx skills add https://github.com/surfingalien/FinSurfing --skill safe-mode-surfingalien
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safe-mode
Source: https://github.com/surfingalien/FinSurfing/tree/main/.claude/skills/safe-mode
Command: npx skills add https://github.com/surfingalien/FinSurfing --skill safe-mode-surfingalien

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI coding sessions can execute destructive commands like rm -rf, git push --force, or DROP TABLE, and edits can spill into unrelated files. This Skill adds opt-in guardrails that warn on dangerous shell commands and confine file edits to a chosen directory. ## Core Features & Use Cases - Cautious Mode: Scans every Bash command against patterns for recursive deletion, SQL drops, force pushes, hard resets, piped remote execution, and fork bombs, emitting a stderr warning before execution. - Lockdown Mode: Restricts Edit and Write operations to a single directory tree, blocking changes outside the allowed path with an explanation. - Session-Scoped State: Stores mode and lockdown path in a per-session temp file, cleared with /safe-mode clear. - Use Case: While refactoring one API module, run /safe-mode lockdown src/api/ so the AI cannot accidentally modify tests or unrelated code, and combine it with cautious mode to catch destructive git commands. ## Quick Start Ask the AI to activate safe mode in cautious mode, or lock down edits to a specific directory such as src/api/.

Frequently Asked Questions about safe-mode

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I block destructive shell commands in Claude Code?

Activate cautious mode with /safe-mode cautious. A PreToolUse hook inspects every Bash command against patterns like rm -rf, git push --force, DROP TABLE, and piped curl-to-shell execution, emitting a stderr warning before the command runs.

How to restrict AI file edits to one directory?

Run /safe-mode lockdown followed by a path, such as /safe-mode lockdown src/api/. The Edit and Write hook resolves each target file path and blocks any operation outside the allowed directory tree until you run /safe-mode clear.

Can cautious mode and lockdown mode run at the same time?

Yes, both modes can run simultaneously. Activate cautious mode for Bash command warnings, then set a lockdown path for Edit and Write restrictions. Running /safe-mode clear removes both restrictions for the session.

Does safe-mode block commands or only warn about them?

Cautious mode only warns; it writes the risk details to stderr and the command still executes if you proceed. Lockdown mode actively blocks Edit and Write operations outside the allowed path. Neither replaces git branches for history protection.

How long do safe-mode restrictions last?

Restrictions are session-scoped. State is stored in a temp file keyed by session ID, so it persists until you run /safe-mode clear, the session ends, or the temp file is manually removed. Each session maintains its own independent state.