Remove Co-Authored-By from Claude Code Commits

Claude Code automatically appends Co-Authored-By: Claude trailers to every commit message it creates. For some teams, this is unwanted — it clutters git log, triggers CI attribution rules, or simply isn't appropriate for the project's commit style.

The Problem

Every time Claude Code runs git commit, it appends a trailer like:

fix: update login validation

Co-Authored-By: Claude <noreply@anthropic.com>

This happens automatically, even if you didn't ask for it. The trailer:

Why you might want to keep it

Some teams and open source projects require AI attribution for transparency. Before stripping the trailer, check your project's contribution guidelines and your company's AI usage policy. The hook below gives you control — you decide whether to keep or strip.

The Fix: strip-coauthored-by Hook

strip-coauthored-by.sh — removes the Co-Authored-By trailer after each commit:

#!/bin/bash
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')

# Only act after git commit commands
echo "$COMMAND" | grep -qE 'git\s+commit' || exit 0

# Amend the last commit to remove Co-Authored-By trailer
LAST_MSG=$(git log -1 --format='%B' 2>/dev/null)
CLEAN_MSG=$(echo "$LAST_MSG" | sed '/^Co-Authored-By:/d' | sed -e :a -e '/^\n*$/{$d;N;ba}')

if [ "$LAST_MSG" != "$CLEAN_MSG" ]; then
  git commit --amend -m "$CLEAN_MSG" --no-verify 2>/dev/null
fi

exit 0

Trigger: PostToolUse (runs after the commit is made)

Alternative: Block the Trailer Before Commit

If you prefer to prevent the trailer from being added in the first place, use a PreToolUse hook that rewrites the commit command:

# In CLAUDE.md (soft instruction, may be forgotten):
"Do not add Co-Authored-By trailers to commits"

# As a hook (enforced at process level):
# Use cc-safe-setup's commit-message-guard example

Control Your Commit Messages + 7 More Safety Hooks

npx cc-safe-setup

655 example hooks including commit message control, branch protection, and more. 9,200+ tests 655 examples

GitHub · npm · Getting Started

Also Prevents

Check Your Safety Score

npx cc-health-check

Free 20-point diagnostic for your Claude Code setup.

Open source, zero dependencies. View source.

Related: rm -rf · force-push · if field · autonomous · all tools

Learn more: Production Guide · All Tools