---
title: Safety Guard Skill for Claude Code
canonical: https://skillselion.com/skills/affaan-m/ecc/safety-guard
content_type: text/markdown
description: safety-guard is an agent skill that blocks destructive commands and restricts file edits to approved directories for developers who run autonomous agents.
---

# Safety Guard Skill

Title: Safety Guard Skill for Claude Code

> safety-guard is an agent skill that blocks destructive commands and restricts file edits to approved directories for developers who run autonomous agents.

Canonical: https://skillselion.com/skills/affaan-m/ecc/safety-guard

safety-guard is an agent skill that blocks destructive commands and restricts file edits to approved directories for developers who run autonomous agents against production systems or sensitive repositories.

safety-guard is an ECC protection skill for autonomous agent runs on production systems and sensitive repositories. It provides three protection modes: Careful mode detects destructive commands such as rm -rf, git push --force, DROP TABLE, kubectl delete, and --no-verify hooks before execution and prompts for confirmation with safer alternatives; Freeze mode locks edits to specific directory trees via commands like freeze src. Developers reach for safety-guard during full-auto agent sessions, migrations, deploys, and data changes where a mistaken shell or Git command could wipe state. The skill watches roughly a dozen high-risk command patterns and offers directory-scoped edit locks instead of relying on post-hoc review.

## Key facts

- Installs: 11,540
- GitHub stars: 316,020
- Author: affaan-m
- Repository: affaan-m/ECC
- Install command: `npx skills add https://github.com/affaan-m/ECC --skill safety-guard`
- Last updated: December 1, 2026

## What Safety Guard does

Block destructive commands and limit agent edits to approved directories when running autonomous agents or touching production systems.

How do you stop agents from running destructive shell commands?

Blocked-command warnings, user confirmations, safer command alternatives, and frozen directory edit locks.

Best for: Developers running full-auto coding agents against production repos, databases, or Kubernetes clusters who need pre-execution guardrails.

Not for: Developers working only in local throwaway sandboxes where destructive commands carry no recovery risk.

- Three protection modes: Careful, Freeze, and Guard
- Intercepts 15+ destructive patterns including rm -rf, git push --force, DROP TABLE, docker prune, and npm publish
- Freeze Mode locks all file edits to a single directory tree
- Guard Mode combines command watching with directory restrictions for full-auto agent safety
- Requires explicit confirmation with safer-alternative suggestions before any risky action

## SKILL.md

## Safety Guard  -  破壊的な操作の防止

### 使用するタイミング

- 本番システムでの作業時
- エージェントが自律的に動作している場合（フルオートモード）
- 特定のディレクトリへの編集を制限したい場合
- センシティブな操作時（マイグレーション、デプロイ、データ変更）

### 動作の仕組み

3つの保護モードがあります:

#### モード1: Careful モード

実行前に破壊的なコマンドを検知して警告します:

```
監視するパターン:
- rm -rf（特に /、~、またはプロジェクトルート）
- git push --force
- git reset --hard
- git checkout .（全変更を破棄）
- DROP TABLE / DROP DATABASE
- docker system prune
- kubectl delete
- chmod 777
- sudo rm
- npm publish（誤公開）
- --no-verify を含む全コマンド
```

検知した場合: コマンドの内容を示し、確認を求め、より安全な代替手段を提示します。

#### モード2: Freeze モード

特定のディレクトリツリーへのファイル編集をロックします:

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

`src/components/` 外への Write/Edit は説明付きでブロックされます。エージェントを特定の領域に集中させ、無関係なコードに触れないようにしたい場合に便利です。

#### モード3: Guard モード（Careful + Freeze の組み合わせ）

両方の保護が有効になります。自律エージェントのための最大安全モードです。

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

エージェントはすべてを読み取れますが、`src/api/` にのみ書き込めます。破壊的なコマンドはどこでもブロックされます。

#### ロック解除

```
/safety-guard off
```

### 実装

PreToolUse フックを使用して Bash、Write、Edit、MultiEdit ツールの呼び出しを検知します。実行前に、アクティブなルールに対してコマンド/パスを確認します。

### 統合

- `codex -a never` セッションでデフォルトで有効化する
- ECC 2.0 の可観測性リスクスコアリングと組み合わせる
- ブロックされた全アクションを `~/.claude/safety-guard.log` に記録する

## Safety Guard FAQ

### What commands does safety-guard Careful mode block?

safety-guard Careful mode watches patterns including rm -rf, git push --force, git reset --hard, DROP TABLE, kubectl delete, docker system prune, chmod 777, sudo rm, npm publish, and any command containing --no-verify, then shows the command and asks for confirmation.

### How does safety-guard Freeze mode protect directories?

safety-guard Freeze mode locks edits to a specified directory tree, for example freezing src, so autonomous agents cannot modify files outside the approved path during sensitive operations.

### How do I install Safety Guard Skill?

npx skills add https://github.com/affaan-m/ECC --skill safety-guard

## Machine access

- [Sitemap](https://skillselion.com/sitemap.xml)
- [llms.txt](https://skillselion.com/llms.txt)
- [llms-full.txt](https://skillselion.com/llms-full.txt)
- [Developer resources](https://skillselion.com/developers)
- [OpenAPI spec](https://skillselion.com/openapi.json)
- [MCP handshake](https://skillselion.com/.well-known/mcp)
- [API catalog](https://skillselion.com/.well-known/api-catalog)
- [AI catalog](https://skillselion.com/.well-known/ai-catalog.json)
- [Pricing](https://skillselion.com/pricing.md)
- [Auth](https://skillselion.com/auth.md)
- [AGENTS.md](https://skillselion.com/AGENTS.md)
- [Contact](https://skillselion.com/contact)
- [Home](https://skillselion.com/)
