safety-guard

Block destructive shell commands and restrict file edits to a specified directory.

Updated Sep 13, 2025
One-click install
npx skills add https://github.com/llmh333/employee_management_spring --skill safety-guard-llmh333
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safety-guard
Source: https://github.com/llmh333/employee_management_spring/tree/main/.gemini/skills/safety-guard
Command: npx skills add https://github.com/llmh333/employee_management_spring --skill safety-guard-llmh333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It reduces the risk of accidental or autonomous agents running destructive commands or making unintended edits on production codebases.

Core Features & Use Cases

  • Destructive Command Blocking (Careful Mode): Detects high-risk patterns (e.g., rm -rf, force pushes/resets, dangerous SQL drops, prune/delete commands) and requires confirmation while suggesting safer alternatives.
  • Directory Write Locking (Freeze Mode): Restricts file edits to a specified directory tree so an agent can’t modify unrelated areas.
  • Combined Guard Mode: Enforces both destructive-command blocking and directory write restrictions simultaneously, while allowing configurable read access.
  • Operational Controls: Enables a global unlock/off switch to restore normal agent behavior when the risk window is over.

Quick Start

Enable guard mode for your session by running: /safety-guard guard --dir src/api/ --allow-read-all

Frequently Asked Questions about safety-guard

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

FAQPage Schema
How do I prevent autonomous agents from running destructive shell commands like rm -rf during production deployment?

To prevent destructive shell commands during production deployment, apply PreToolUse hooks to intercept Bash, Write, and Edit tool calls. The safety guard detects high-risk patterns like rm -rf and force pushes, blocking them and suggesting safer alternatives.

How can I restrict autonomous agent file edits to a specific directory tree?

To restrict autonomous agent file edits to a specific directory tree, enable Freeze Mode. This enforces directory write locking, preventing modifications to unrelated areas while optionally allowing configurable read access to the rest of the repository.

Can I block dangerous SQL drops and force pushes without completely disabling my agent's write access?

You can block dangerous SQL drops and force pushes while retaining write access by enabling Combined Guard Mode. This simultaneously enforces destructive-command blocking and directory write restrictions, allowing configurable read access while logging blocked actions.

How do I enable directory write locking for a specific path during a migration?

To enable directory write locking for a specific path during a migration, run the guard command with your target directory and read permissions. For example, start a session with the guard command targeting your specific directory tree and allowing global read access.

Where are blocked destructive operations and high-risk command attempts logged?

Blocked destructive operations and high-risk command attempts are logged to the safety-guard.log file within the .gemini directory. This captures all intercepted Bash, Write, Edit, and MultiEdit tool calls that triggered the command and path pattern checks.

How do I restore normal agent behavior after finishing a risky production maintenance window?

To restore normal agent behavior after a risky production maintenance window, use the global unlock or off switch. This operational control disables the destructive command blocking and directory write restrictions, returning the agent to its standard execution state.