Chuyển đến nội dung
Skillpedia
Bảo mật280k · #397

safety-guard

Skill này làm gì

Agent này hoạt động như người bảo vệ cho các thao tác của bạn. Nó ngăn các lệnh nguy hiểm chạy nhầm và có thể giới hạn thay đổi trong một phạm vi cụ thể của dự án.

Khi nào nên dùng

  • ✓Khi bạn làm việc trên hệ thống quan trọng (môi trường thật, production).
  • ✓Khi bạn muốn AI làm việc độc lập trong một khu vực bị giới hạn.
  • ✓Khi bạn thực hiện các đợt cập nhật quan trọng hoặc thay đổi dữ liệu.

Liên kết skill

https://github.com/affaan-m/ECC/blob/main/skills/safety-guard/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/affaan-m/ECC/blob/main/skills/safety-guard/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy bảo vệ dự án của tôi khỏi các lệnh nguy hiểm và chỉ cho phép chỉnh sửa trong thư mục “src/components/”.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ kiểm tra các lệnh mà AI sắp chạy. Nếu lệnh bị coi là nguy hiểm (như xóa toàn bộ) hoặc AI cố sửa thứ gì đó ngoài phạm vi cho phép, nó sẽ dừng lại và hỏi xác nhận của bạn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

Nó chặn những lệnh nguy hiểm nào?

Nó chặn các lệnh như “xóa tất cả” (rm -rf), ép đẩy code lên hệ thống quản lý phiên bản (git push --force), và xóa bảng cơ sở dữ liệu (DROP TABLE).

Làm sao để tắt tính năng bảo vệ?

Bạn có thể tắt bảo vệ bằng cách gõ “/safety-guard off”.

Tôi có thể cho AI đọc mọi thứ nhưng chỉ ghi ở một nơi không?

Được. “Guard Mode” cho phép điều này. Bạn chỉ định một thư mục mà AI được phép ghi, và nó sẽ không thể sửa các phần khác của dự án.

Chi tiết

Mô tả gốc của tác giả

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.

repo: affaan-m/ECC

Độ phổ biến

Sao GitHub
280k
Vị trí xếp hạng
#397
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự