ClaudeMods
☰
ZH-CN
● — 人在线 · 浏览 — 次
赞助提交作品
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

更多类似作品