Skip to content

tools: add commit-cleaner to strip Claude attribution from commits - #12

Merged
jacobyoby merged 1 commit into
mainfrom
claude/peaceful-tesla-ngjufs
Sep 11, 2026
Merged

jacobyoby merged 1 commit into
mainfrom
claude/peaceful-tesla-ngjufs

Conversation

@jacobyoby

Copy link
Copy Markdown
Contributor

Summary

Claude Code appends Co-Authored-By: Claude … <noreply@anthropic.com> and Claude-Session: … trailers to every commit it makes. This adds a shared toolkit under tools/commit-cleaner/ that strips them at commit time, stops the hook being bypassed from inside a Claude Code session, and can scrub commits that already carry them. Reimplements the approach from ya8282/commit-cleaner-hook in-house so the foundation's repositories don't depend on a third-party plugin.

Changes

  • commit-msg: POSIX commit-msg hook. Removes Claude Co-Authored-By, Claude-Session, Generated with [Claude Code] and bare session-URL lines; keeps human co-author trailers; leaves a clean message byte-identical; never blocks a commit on error.
  • install.sh: installs per repository (honours core.hooksPath and worktrees) or globally via ~/.config/git/hooks; chains an existing foreign hook and restores it on --uninstall.
  • guard.py: Claude Code PreToolUse hook that refuses git commit --no-verify, -n (including flag clusters), core.hooksPath overrides, HOME/GIT_DIR relocation, edits to the hook file, and one layer of bash -c / eval / $(…) wrapping.
  • clean-history.sh: dry-run-by-default git filter-repo --message-callback wrapper for existing commits, with clean-tree and range checks.
  • claude-settings.example.json: drop-in .claude/settings.json for repositories that vendor the hook under .githooks/.
  • test.sh plus .github/workflows/commit-cleaner-tests.yml: 26 tests covering message rewriting, a real repository, hook chaining, core.hooksPath, and guard allow/block cases. The workflow runs only when the tool changes and pins actions/checkout to the same SHA as the existing workflows.
  • README.md documenting the three install options, history scrubbing, and limits.

How tested

tools/commit-cleaner/test.sh passes locally (26/26). The hook was also installed into this clone before committing: this PR's own commit was made by Claude Code with the trailers attached, and they were stripped.

Companion PRs vendor the hook into beanstalk and docassemble.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MU3XgW95kXzx2SHkKwPW32


Generated by Claude Code

Adds a commit-msg hook that removes Co-Authored-By: Claude and Claude-Session trailers, an installer (per-repo or global), a Claude Code PreToolUse guard against --no-verify and hooksPath bypasses, a dry-run-by-default git filter-repo wrapper for existing commits, tests, and a workflow that runs them.
@jacobyoby
jacobyoby merged commit fe5d217 into main Sep 11, 2026
1 check passed
@jacobyoby
jacobyoby deleted the claude/peaceful-tesla-ngjufs branch September 11, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants