Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

safety-guard — Claude Code skill: what it does and how to install

Intercepts destructive commands for confirmation and can limit writes to one directory. Use it when an agent runs autonomously or changes need tighter boundaries.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add affaan-m/ECC --skill safety-guard -a claude-code
Open on GitHub

What safety-guard does

The skill has three modes. Careful asks for confirmation before commands such as git push --force or DROP TABLE and suggests a safer alternative. Freeze blocks writes outside a chosen directory. Guard combines both: the agent can read the project but only write to the selected folder.

It uses PreToolUse hooks to check Bash, Write, Edit, and MultiEdit calls. Start a mode with /safety-guard freeze src/components/ or /safety-guard guard --dir src/api/ --allow-read-all; use /safety-guard off to remove the restrictions. Blocked actions are logged to ~/.claude/safety-guard.log.

Install it when an agent runs autonomously or you need to constrain its edits. For routine work without directory boundaries, the write restrictions can get in the way.

What it helps with

  • ask for confirmation before git push --force
  • block writes outside src/components/
  • allow project-wide reads but restrict edits to src/api/
  • intercept destructive commands during a migration

Example prompts for the agent

  • Enable Careful and ask me before running destructive commands.
  • Freeze edits outside `src/components/` with `/safety-guard freeze src/components/`.
  • Enable Guard for `src/api/`, allow reads everywhere, and block destructive commands.

How to install safety-guard

1Skills CLI (Vercel)

npx skills add affaan-m/ECC --skill safety-guard -a claude-code

2Manually: put the files in place

~/.claude/skills/safety-guard/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/safety-guard/

From the same set146

The whole set →
video-editing affaan-m AI-assisted workflow for editing, trimming, and enriching real footage. Connects raw recordings with FFmpeg cuts, Remotion overlays, and ElevenLabs voiceovers. Claude Code CX Codex Cursor +1 6,500installs docker-patterns affaan-m A skill with Dockerfile and Docker Compose patterns: local dev stacks, networking, volumes, container hardening. Claude Code CX Codex Cursor +1 6,300installs frontend-patterns affaan-m A skill for React and Next.js work: component patterns, state, data fetching, and render performance. Use it when building or reviewing UI. Claude Code CX Codex Cursor +1 5,900installs backend-patterns affaan-m A skill with backend patterns for Node.js, Express and Next.js API routes: layering, caching, transactions, error handling. Claude Code CX Codex Cursor +1 5,900installs coding-standards affaan-m Baseline cross-project coding conventions for naming, immutability, and clean code principles. Useful for code reviews and refactoring. Claude Code CX Codex Cursor +1 5,600installs api-design affaan-m Provides REST API design standards covering resource naming, status codes, pagination, and error payloads. Use it when creating or auditing API contracts. Claude Code CX Codex Cursor +1 5,500installs rust-testing affaan-m A skill for writing Rust tests: unit, integration, async, property-based, mocks and coverage. Useful when the project runs on TDD. Claude Code CX Codex Cursor +1 5,500installs laravel-security affaan-m This skill reviews Laravel authentication, Eloquent safety, CSRF, XSS, APIs, and production settings. Use it for security reviews or deployment checks. Claude Code CX Codex Cursor +1 5,400installs

Similar

solana-dev Solana Foundation Skill for building Solana dApps, writing Anchor smart contracts, managing wallets and transactions. Covers setup, testing, and devnet deployment end-to-end. Claude Code CX Codex Cursor +1 98,300installs sql-code-review official github Reviews SQL for security and performance issues, as well as maintainability. Use it when checking queries or a database schema. GitHub Copilot 14,060installs gcloud official Google LLC Validates gcloud commands, reduces command output, and adds execution guardrails for Google Cloud work. Use it when an agent handles the CLI. Claude Code Gemini CLI CX Codex 10,974installs postgresql-code-review official github Reviews SQL and database schemas for PostgreSQL-specific issues. Use it before reviewing migrations, JSONB queries, functions, or access rules. GitHub Copilot 12,608installs git-guardrails-claude-code Matt Pocock This skill adds a Claude Code hook that stops risky Git commands before they run. Use it when an agent must not push or discard working-tree changes. Claude Code 499,069installs ponytail-review DietrichGebert ponytail-review reviews a change beyond the diff, checking connected code, bugs, risks, load, tests, speed, and unnecessary code. Use it for PRs and commits. Claude Code CX Codex Cursor +1 56,300installs ponytail-audit DietrichGebert It audits a repository and ranks bugs, risks, and redundant code in a one-shot report. Use it when you need a review without code changes. Claude Code CX Codex Cursor +1 44,800installs security-audit cloudflare Reviews codebases and APIs for vulnerabilities using safe sandboxing. Fits pre-release security reviews, pen-test triage, and architecture checks. Claude Code CX Codex Cursor +1 52,200installs

Questions about safety-guard

How do I install safety-guard in Claude Code?

Run npx skills add affaan-m/ECC --skill safety-guard -a claude-code.

What does safety-guard do?

It asks for confirmation before destructive commands and can restrict writes to a directory. Guard combines both protections.

Which commands does safety-guard check?

Checks include rm -rf, git push --force, git reset --hard, DROP TABLE, kubectl delete, and commands with --no-verify.

Source text

SKILL.md · MIT
---
name: safety-guard
description: "Guard against destructive operations with three modes: Careful intercepts dangerous commands (rm -rf, git push --force, DROP TABLE) for confirmation, Freeze locks writes to one directory, and Guard combines both via PreToolUse hooks. Use when working on production systems, running agents autonomously, restricting edits to a directory, or during migrations, deploys, and data changes."
metadata:
  origin: ECC
---

# Safety Guard — Prevent Destructive Operations

## When to Use

- When working on production systems
- When agents are running autonomously (full-auto mode)
- When you want to restrict edits to a specific directory
- During sensitive operations (migrations, deploys, data changes)

## How It Works

Three modes of protection:

### Mode 1: Careful Mode

Intercepts destructive commands before execution and warns:

```
Watched patterns:
- rm -rf (especially /, ~, or project root)
- git push --force
- git reset --hard
- git checkout . (discard all changes)
- DROP TABLE / DROP DATABASE
- docker system prune
- kubectl delete
- chmod 777
- sudo rm
- npm publish (accidental publishes)
- Any command with --no-verify
```

When detected: shows what the command does, asks for confirmation, suggests safer alternative.

### Mode 2: Freeze Mode

Locks file edits to a specific directory tree:

```
/safety-guard freeze src/components/
```

Any Write/Edit outside `src/components/` is blocked with an explanation. Useful when you want an agent to focus on one area without touching unrelated code.

### Mode 3: Guard Mode (Careful + Freeze combined)

Both protections active. Maximum safety for autonomous agents.

```
/safety-guard guard --dir src/api/ --allow-read-all
```

Agents can read anything but only write to `src/api/`. Destructive commands are blocked everywhere.

### Unlock

```
/safety-guard off
```

## Implementation

Uses PreToolUse hooks to intercept Bash, Write, Edit, and MultiEdit tool calls. Checks the command/path against the active rules before allowing execution.

## Integration

- Enable by default for `codex -a never` sessions
- Pair with observability risk scoring in ECC 2.0
- Logs all blocked actions to `~/.claude/safety-guard.log`

© affaan-m · MIT · affaan-m/ECC

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor