ClaudeMods
☰
ZH-TW
● — 人在線上 · 瀏覽 — 次
贊助提交作品
GitHub 儲存庫 · 發布者 Sea-University-7237

我沒讀就批准了代理的「oc delete —all」,於是我用 Claude Code 的新函式鉤子打造了護欄(以及另外 10 個模組)

作者在沒讀的情況下批准了代理的 `oc delete --all`,差點清空一個 Kubernetes 命名空間,接著使用新的函式鉤子 API 打造了一套包含 11 個 Claude Code 外掛的套件。主要模組 guardrails 會阻擋破壞性指令,例如大規模 kubectl/oc 刪除、rm -rf、強制推送和機密讀取,並告知 Claude 使用者已阻擋該動作。其他模組涵蓋活動監控、桌面通知、上下文追蹤、使用限制、提示教練、指令探索和一個模組管理器。11 個中有 9 個從不呼叫模型,沒有遙測,專案免費且採用 MIT 授權。

已翻譯

關於這個 mod

Reddit 使用者 u/Sea-University-7237 發文描述了一套使用新函式鉤子 API 打造的 11 個 Claude Code 外掛,起因是作者在沒讀的情況下批准了代理的 oc delete --all,導致命名空間被部分清空。旗艦模組 guardrails 讓使用者切換規則來阻擋 rm -rf、大規模 kubectl/oc 刪除、強制推送、破壞性 git 操作、.env 讀取、安裝和網路存取,並向 Claude 發出訊號表示使用者已阻擋該動作,使其不會繞過。其餘模組:activity、notify、context-keeper、usage-meter、prompt-coach、command-hub、toolbox、changes、loop-breaker、一個快速啟動列啟動器,以及用於安裝和切換它們的 /mods。九個模組從不呼叫模型;prompt-coach 和 context-keeper 的交接說明會經過 Claude Code。除了市場更新檢查外沒有遙測。README 記錄了每個流程和涉及的檔案。限制:guardrails 檢查傳遞給工具的指令,因此它能捕獲 oc delete --all,但無法捕獲代理撰寫並稍後執行的指令碼。使用 claude plugin marketplace add mishgoldenberg/claude-mods 和 claude plugin install mod-manager@claude-mods 安裝,然後重新啟動並執行 /mods。需要 Claude Code 2.1.286+。儲存庫:https://github.com/mishgoldenberg/claude-mods

安裝

安裝方式請查看原始來源。

原文 / README

A while ago I asked an agent (Claude Code on a self-hosted model) to "delete everything you added in the last command". It came back with oc delete --all. I hit approve without reading it, and it started wiping the namespace. I caught it about halfway. Rebuilding the rest from Confluence pages took me two days. Claude Code recently added function hooks, which are plugins that run inside it, see every tool call before it executes, and can draw their own panels. So I built the stuff I wish I'd had that day. The one that matters most is guardrails. You click rules on or off: block rm -rf, mass kubectl/oc deletes, force-push, destructive git, reading .env, installs, network, or keep Claude inside the project folder. When it blocks something it tells Claude the user blocked it and not to work around it. The rest: - activity: shows what Claude is running right now, for how long, and when it's waiting for your approval - notify: a desktop notification (Windows/macOS/Linux) when a long task finishes or an approval has been sitting there - context-keeper: what's filling your context window, plus checkpoints saved to disk so /compact and /clear don't lose the thread - usage-meter: 5h/7d limit bars with burn rate and cache hit ratio - prompt-coach: when a prompt is vague (like mine was), it suggests a sharper version and you pick which one to send. It never rewrites anything silently - command-hub: the built-in commands people miss (/rewind, /btw, /context) explained, plus a form to make your own - toolbox, changes, loop-breaker (catches Claude retrying the same failing command), a quickbar launcher, and /mods to install and toggle all of them Nine of the eleven never call a model, so they cost no tokens. The two that do (prompt-coach and the context-keeper handoff note) go through Claude Code itself. There's no telemetry, and the only other network traffic is the marketplace check when you click update in /mods. The README lists every process and file they touch. To be clear about the limits: guardrails is a seatbelt, not a sandbox. It checks the command the agent passes to a tool, so it would have caught my oc delete --all, but it won't catch a script the agent writes and then runs. How Claude helped: I built the whole thing in Claude Code (Opus). I wrote the feature list and the rules I wanted. Claude read the function hooks API types, wrote the mods, ran the plugin validator on each one, and wrote the tests (64 on the guardrail rules, running in CI). My job was testing in the real desktop app and reporting what broke. Funny part: its own guardrails kept blocking its edits during the build, and it fixed the rule instead of working around it. What I learned: - How you deny matters more than what you deny. A plain "blocked" makes the model try a reworded command. "The user blocked this, don't work around it, ask them" makes it stop and explain. - Matching raw command text is noisy. Commit messages that just mentioned rm -rf got blocked. Ignoring quoted text (unless the command runs a shell inline like bash -c or | sh) fixed most of it. - Anything that changes what gets sent to the model has to be visible. A silent prompt rewriter is worse than none. It's free and MIT licensed, no account needed. Install: claude plugin marketplace add mishgoldenberg/claude-mods claude plugin install mod-manager@claude-mods Then restart and type /mods. Needs Claude Code 2.1.286 or newer. Repo: https://github.com/mishgoldenberg/claude-mods What annoys you in Claude Code that a mod could fix? I'm picking the next ones from the comments. submitted by /u/Sea-University-7237 [link] [comments]

取得徽章

這是你的專案嗎?把這個徽章放進 README 或網站,連回本頁。

Featured on ClaudeMods
尺寸
配色
Markdown
HTML

更多類似作品