---
title: "在經歷太多次驚險之後，我打造了 5 個小型 Claude Code 模組"
url: "https://claudemods.dev/zh-tw/builds/i-built-5-small-claude-code-mods-after-one-too-many-close-ca-bbda35"
source: "https://www.reddit.com/r/ClaudeCode/comments/1x401ga/i_built_5_small_claude_code_mods_after_one_too"
source_type: "reddit"
author: "ITower__Education"
author_handle: "ITower__Education"
stars: 0
category: "安全與隱私"
categories: ["security"]
tags: ["guardrails", "hooks", "safety", "statusline", "task-board"]
permission_level: null
scan_complete: false
added: "2026-10-16T16:49:50.897Z"
updated: "2026-10-16T16:49:50.897Z"
locale: "zh-tw"
content_locale: "zh-tw"
---

# 在經歷太多次驚險之後，我打造了 5 個小型 Claude Code 模組

一位 Reddit 使用者分享了他們在多次驚險之後打造的五個小型 Claude Code hook 模組：一個破壞性指令防護，會在 git reset --hard 或 rm -rf 時暫停並列出有風險的未提交檔案；一個提示上方的上下文用量天氣預報指示器；一個用於貼上密鑰的 API 密鑰過濾器；一個對推送到 main 以及週五下午的阻擋；以及一個 Claude 可讀取並可追加的任務看板。作者指出 hook 會失敗開放——崩潰的 hook 會被跳過，因此他們新增了一個捕獲，將任何崩潰轉換為拒絕——並承認這些防護只是模式匹配，並非萬無一失。

## Description

r/ClaudeCode 上的 Reddit 貼文，描述了作者打造的五個小型 Claude Code 模組，每個大約 20-50 行。最突出的是一個破壞性指令防護：當 Claude 嘗試 git reset --hard 或 rm -rf 時，它會暫停，顯示哪些未提交檔案會遺失，並請求確認，通常會提議改為 stash。作者強調，崩潰的 hook 會被靜默跳過，因此未加防護的失敗會讓一切通過，於是他們新增了一個捕獲，將崩潰轉為拒絕。另外四個模組：一個提示上方的上下文用量天氣預報指示器，一個用於意外貼上密鑰的 API 密鑰過濾器，一個對推送到 main（以及週五下午 3 點之後的任何操作）的阻擋，以及一個 Claude 可讀取並可新增內容的看板。作者指出，密鑰過濾器只檢查鍵入輸入，指令防護是模式匹配，因此隱藏在指令碼中的程式碼可能溜過去。未提供存儲庫連結或安裝說明。

## Original README

Claude Code opened up to mods recently so I built a few for stuff that kept biting me. Each one is 20-50 lines. I built them with Claude Code itself. I described what each mod should do, Claude wrote the first version, then I tested it in a live session and asked it to fix whatever broke. The regex lists for risky commands and API key formats were mostly Claude’s, I just trimmed them down. The most useful one by far stops destructive commands. If Claude tries git reset --hard or rm -rf , it pauses, shows which uncommitted files would be lost and asks me. If I say no, Claude usually just offers to stash first. Funny thing I didn’t expect: if a hook crashes, Claude Code just skips it. So a broken guard lets everything through. Had to add a catch that turns any crash into a deny. Lesson for me: always decide what your mod should do when it fails, because the default is “do nothing”. The other four: context usage shown as a little weather forecast above the prompt, a filter that hides API keys if you paste them by accident, a block on pushing to main (and on anything after 3pm Friday), and a task board Claude can read and add to. None of them are bulletproof btw. The key filter only sees what you type, and the command guard is just pattern matching, so something hidden inside a script gets past it. Is anyone else making mods? I’d like to see what people come up with.   submitted by   /u/ITower__Education   to   r/ClaudeCode [link]   [comments]
