Skip to content

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

Closed
jacobyoby wants to merge 3 commits into
mainfrom
claude/peaceful-tesla-ngjufs
Closed

jacobyoby wants to merge 3 commits into
mainfrom
claude/peaceful-tesla-ngjufs

Conversation

@jacobyoby

Copy link
Copy Markdown
Owner

Description

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 sessions activate it automatically and cannot bypass it with --no-verify.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Repository tooling (git hook and Claude Code settings; no application code)

Related Issues

None filed; same change already merged in jacobrakaiFoundation/beanstalk and jacobyoby/docassemble.

Changes Made

  • .githooks/commit-msg: 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: SessionStart sets core.hooksPath=.githooks; 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 stays untracked.

Testing

  • All existing tests pass (no Python source changed)
  • New tests added for new functionality: the hook and guard have a 26-case suite in jacobrakaiFoundation/.github (tools/commit-cleaner/test.sh)
  • Tested with both Ollama and Claude providers (n/a)
  • Tested on Windows/macOS/Linux (POSIX sh hook; on Windows it runs under Git Bash like any other hook)

Checklist

  • Code follows PEP 8 style guidelines (commit-guard.py)
  • Code is commented, particularly in hard-to-understand areas
  • Documentation updated (README, CHANGELOG, docs/) — tooling only
  • CHANGELOG.md updated — tooling only, no user-facing change
  • No ROM files included
  • No sensitive data included (API keys, etc.)
  • Tests pass locally
  • Self-review completed

Screenshots (if applicable)

n/a

Additional Notes

Local contributors opt in once with git config core.hooksPath .githooks.

🤖 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 closed this Sep 21, 2026
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