返回资讯中心
外部精选
软件工程
#开发者实时流

strip-claude:一个自动移除 Claude Code 提交署名信息的 Git hook

来源标题:A Git hook to augment Claude-code attribution

开发者发布名为 strip-claude 的 Git commit-msg hook,可自动删除提交信息末尾的 Claude Code 署名内容,如 Co-Authored-By、Claude-Session 和「Generated with Claude Code」等行。该 hook 支持通过 core.hooksPath 全局安装到所有仓库,也可在单个仓库内配置使用。

Hacker News 最新maitland2026/11/8 · 今天4 分钟阅读

以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。

strip-claude 是一个 Git commit-msg 钩子,用于从提交信息中移除末尾的 Claude Code 署名。

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com Claude-Session: https://claude.ai/... Generated with Claude Code Created by Claude Code Generated with Claude Code

全局安装

通过全局的 core.hooksPath 设置,Git 可以让所有仓库共用一个 hooks 目录:

mkdir -p ~/.config/git/hooks curl -fsSL https://gist.githubusercontent.com/imaitland/caefe0b2d6f007f1c200ee4e294f8494/raw/strip-claude-commit-msg -o ~/.config/git/hooks/commit-msg chmod +x ~/.config/git/hooks/commit-msg git config --global core.hooksPath ~/.config/git/hooks

在单个仓库中安装

在你想启用该钩子的仓库中执行:

mkdir -p .githooks curl -fsSL https://gist.githubusercontent.com/imaitland/caefe0b2d6f007f1c200ee4e294f8494/raw/strip-claude-commit-msg -o .githooks/commit-msg chmod +x .githooks/commit-msg git config core.hooksPath .githooks

本地测试

tmp=$(mktemp) printf '%s\n'
'feat: test hook'
''
'This body mentions Claude and should stay.'
''
'Generated with Claude Code'
'Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com' > "$tmp" hooks_path=$(git config --path --get core.hooksPath) "$hooks_path/commit-msg" "$tmp" cat "$tmp" rm -f "$tmp"

预期输出:

feat: test hook This body mentions Claude and should stay.

说明

这个钩子可以按你的喜好进行定制。例如,你可以故意误导,把提交归到另一个 agent 名下,也可以如实写一句类似这样的话:

An LLM trained on the sum total of human knowledge was used.

Claude Code 可以在源头上配置为不添加这条署名(但这并不会让它变得更诚实)。参见 Claude Code attribution settings。

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →