Skip to content

chore: strip Claude attribution from commits via a checked-in commit-msg hook - #83

Merged
jacobyoby merged 3 commits into
mainfrom
claude/peaceful-tesla-ngjufs
Sep 12, 2026
Merged

jacobyoby merged 3 commits into
mainfrom
claude/peaceful-tesla-ngjufs

Conversation

@jacobyoby

Copy link
Copy Markdown
Owner

Summary

Claude Code adds Co-Authored-By: Claude and Claude-Session: trailers to every commit. This vendors the commit-cleaner hook from jacobrakaiFoundation/.github so those lines are stripped before a commit is recorded, and wires it so Claude Code on the web sessions (fresh clones with no hooks) get it automatically.

Changes

  • .githooks/commit-msg: the hook. Strips Claude attribution lines, keeps human Co-Authored-By trailers, leaves clean messages byte-identical, never blocks a commit.
  • .claude/hooks/commit-guard.py + .claude/settings.json: a SessionStart hook sets core.hooksPath=.githooks at the start of every Claude Code session, and a PreToolUse guard refuses git commit --no-verify / -n, core.hooksPath overrides, and edits to the hook.
  • .gitignore: .claude/ was ignored wholesale. Appended exceptions so settings.json and hooks/ are tracked while personal state (settings.local.json etc.) stays untracked.
  • Local contributors opt in once with git config core.hooksPath .githooks.

How tested

The hook and guard have a 26-case test suite in jacobrakaiFoundation/.github (tools/commit-cleaner/test.sh). Same change already merged in beanstalk and docassemble.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MU3XgW95kXzx2SHkKwPW32


Generated by Claude Code

…msg hook

Vendors the commit-cleaner hook from jacobrakaiFoundation/.github under .githooks/, and adds .claude/settings.json so Claude Code sessions activate it on start and block --no-verify and hooksPath bypasses. Re-includes .claude/settings.json, .claude/hooks/ and .githooks/ in .gitignore; personal Claude state stays untracked. Local contributors run: git config core.hooksPath .githooks
Sets attribution.commit to an empty string and attribution.sessionUrl to false in .claude/settings.json, the supported way to stop Claude Code writing Co-Authored-By and Claude-Session trailers. Works on every machine the project settings load on, without git hook configuration; the commit-msg hook stays as a backstop. The SessionStart command now cds into CLAUDE_PROJECT_DIR first so it works when the session cwd is not the repository.
Keeps repositories that run ruff format --check or black over the whole tree green. No behaviour change.
@jacobyoby
jacobyoby merged commit 04e1496 into main Sep 12, 2026
7 checks passed
@jacobyoby
jacobyoby deleted the claude/peaceful-tesla-ngjufs branch September 12, 2026 02:51
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