/ 目錄 / 演練場 / Claude Code Safety Net
● 社群 kenryu42 ⚡ 即開即用

Claude Code Safety Net

作者 kenryu42 · kenryu42/claude-code-safety-net

A hooks-driven safety net for Claude Code — interceptors catch rm -rf, git reset --hard, force pushes, and uncommitted destructive edits.

Installs as a Claude Code plugin with PreToolUse hooks. Each potentially destructive operation is intercepted and either confirmed or refused based on rules. Includes rules for git, file system, npm, and arbitrary bash.

為什麼要用

核心特性

即時演示

實際使用效果

就緒

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "claude-code-safety-net": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/kenryu42/claude-code-safety-net",
        "~/.claude/skills/safety-net"
      ],
      "_inferred": true
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "claude-code-safety-net": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/kenryu42/claude-code-safety-net",
        "~/.claude/skills/safety-net"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "claude-code-safety-net": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/kenryu42/claude-code-safety-net",
        "~/.claude/skills/safety-net"
      ],
      "_inferred": true
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "claude-code-safety-net": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/kenryu42/claude-code-safety-net",
        "~/.claude/skills/safety-net"
      ],
      "_inferred": true
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "claude-code-safety-net",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/kenryu42/claude-code-safety-net",
        "~/.claude/skills/safety-net"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "claude-code-safety-net": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/kenryu42/claude-code-safety-net",
          "~/.claude/skills/safety-net"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add claude-code-safety-net -- git clone https://github.com/kenryu42/claude-code-safety-net ~/.claude/skills/safety-net

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: Claude Code Safety Net

Install the safety net into Claude Code

👤 Claude Code users ⏱ ~15 min intermediate

何時使用: You've been bitten by an agent overwriting uncommitted changes.

步驟
  1. Clone
    git clone into ~/.claude/skills/safety-net✓ 已複製
    → Skill directory present
  2. Wire hooks
    Run the included setup; settings.json gets PreToolUse entries.✓ 已複製
    → Hooks active
  3. Test
    Ask Claude to git reset --hard; expect block.✓ 已複製
    → Block triggered

結果: Destructive ops require explicit override.

組合

與其他 MCP 搭配,撬動十倍槓桿

claude-code-safety-net + filesystem

Pairs naturally with any agent doing repo edits

Combine claude-code-safety-net with filesystem: Pairs naturally with any agent doing repo edits✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
hook-driven (see docs) No callable tools; activates via PreToolUse hooks 1 call

成本與限制

運行它的成本

API 配額
N/A
每次呼叫 Token 數
0
費用
Free
提示
Start in soft-warn mode; promote to hard-block after a week of clean runs

安全

權限、密鑰、影響範圍

最小權限: hooks-read hooks-write
憑證儲存: None
資料出站: None

故障排查

常見錯誤與修復

Hooks not firing

Confirm settings.json was actually updated; restart Claude Code

False positives on benign git ops

Tune the per-project rules file

替代方案

Claude Code Safety Net 對比其他方案

替代方案何時用它替代權衡
pegasi-ai/reinsYou want broader agent guardrailsHeavier setup
Manual reviewSolo, low-stakes repoDoesn't scale

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills