如何阻止Claude说'load-bearing'

Hacker News Top 工具

摘要

关于使用自定义Claude钩子将过度使用的短语(如'load-bearing'和'honest takes')替换为更有趣的替代方案的教程,使用Python脚本和MessageDisplay钩子。

暂无内容
查看原文
查看缓存全文

缓存时间: 2026/07/14 16:18

# 如何让 Claude 停止说“承重”这类词 看到 Claude 把所有东西都称为“诚实观点”和“承重接缝”气得直薅头发? 你并不孤单(https://github.com/anthropics/claude-code/issues/53454)。 但要是告诉你有个办法能让这个巨大痛点变得如此荒谬可笑,你忍不住笑出来呢?或者就干脆修正 Claude 的词汇。 我向你介绍 `MessageDisplay` 钩子。 首先你需要一个带替换的小脚本: ``` #!/usr/bin/env python3 import json, re, sys replacements = { "seam": "whatchamacallit", "you're absolutely right": "I'm a complete clown", "honest take": "spicy doodad", "load-bearing": "cooked" } data = json.load(sys.stdin) text = data.get("delta") or "" for phrase, replacement in replacements.items(): pattern = r"\b" + re.escape(phrase) + r"\b" text = re.sub(pattern, replacement, text, flags=re.IGNORECASE) print(json.dumps({ "hookSpecificOutput": { "hookEventName": "MessageDisplay", "displayContent": text, } })) ``` 把它放到 `~/.claude/hooks/wordswap.sh` 中,并用 `chmod +x ~/.claude/hooks/wordswap.sh` 使其可执行。 然后在你的 `~/.claude/settings.json` 中的 `hooks` 块里像这样挂接它: ``` { "hooks": { "MessageDisplay": [ { "hooks": [ { "type": "command", "command": "$HOME/.claude/hooks/wordswap.sh" } ] } ] } } ``` 钩子在启动时加载,所以只需要开始一个新会话就能开启你的新生活。 一张截图展示脚本生效后 Claude 输出的效果。 我相信你能想出比我更有趣、更高效的替换。玩得开心!

相似文章

用于构建Claude Code hooks的Python工具包

Hacker News Top

一个减少构建Claude Code hooks样板代码的Python工具包,提供类型安全的事件处理器,用于工具使用前/后、提示提交和会话开始钩子。