claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Feature] Suffix git author with `(Claude Code)`

Open gwpl opened this issue 7 months ago • 0 comments

Aider has cool feature that is adding suffix (Aider) to git author/commiter name, I wonder how to achieve similar ,

so when I run git myself in repository directory it commits as me,

while when claude code commits , it by default adds postfix to author name (Claude Code) (unless instructed otherwise or configured by flag/settings otherwise).


Workaround:

When I asked claude code what would be elegant solution it suggested launching it via ./claude.sh provided below:

$ cat claude.sh

( newest version: https://github.com/gwpl/handy_scripts_misc/blob/master/claude.sh )

#!/bin/bash
# Generic wrapper script to launch Claude Code with modified git config
# This script appends "(Claude Code)" to the current git user name
#
# To always run calude "wrapped" put this script in some $PATH directory and alias claude=`claude.sh` to your ~/.bashrc

# Get current git user config
CURRENT_NAME=$(git config user.name)
CURRENT_EMAIL=$(git config user.email)

# Check if git user is configured
if [ -z "$CURRENT_NAME" ] || [ -z "$CURRENT_EMAIL" ]; then
    echo "Error: Git user.name and user.email must be configured"
    echo "Run: git config --global user.name \"Your Name\""
    echo "Run: git config --global user.email \"[email protected]\""
    exit 1
fi

# Set Claude-specific git config using environment variables
export GIT_AUTHOR_NAME="$CURRENT_NAME (Claude Code)"
export GIT_COMMITTER_NAME="$CURRENT_NAME (Claude Code)"

# Add +claude suffix to email if it doesn't already have it
if [[ "$CURRENT_EMAIL" == *"+claude.code"* ]]; then
    export GIT_AUTHOR_EMAIL="$CURRENT_EMAIL"
    export GIT_COMMITTER_EMAIL="$CURRENT_EMAIL"
else
    # Insert +claude before @ symbol
    export GIT_AUTHOR_EMAIL="${CURRENT_EMAIL/@/+claude.code@}"
    export GIT_COMMITTER_EMAIL="${CURRENT_EMAIL/@/+claude.code@}"
fi

# Launch Claude Code with all arguments passed through
exec claude "$@"

gwpl avatar Jun 10 '25 11:06 gwpl