On this page
Package trailer injects git trailers (key-value metadata lines) into commit messages for AI agent traceability and session attribution.
#internal/trailer
#internal/trailer
Package trailer injects git trailers (key-value metadata lines) into commit messages for AI agent traceability and session attribution.
#SessionKey
const SessionKey = "Claude-Code-Session-Id"SessionKey is the git trailer key used to record the Claude Code session ID.
#Inject
func Inject(message string) stringInject reads CLAUDE_CODE_SESSION_ID from the environment and appends a Claude-Code-Session-Id trailer to the commit message if present. For amend: deduplicates if the same session ID already exists as a trailer; keeps both if a different session's trailer is present.
#AppendCustom
func AppendCustom(message string, trailers []string) stringAppendCustom appends user-provided trailers to the commit message. Each trailer should be in "Key: Value" format. If trailers is empty, the message is returned unchanged. Follows the same format as Inject: appends to an existing trailer block, or adds a blank line separator first.
#SplitBodyTrailers
func SplitBodyTrailers(message string) (body, trailerBlock string)SplitBodyTrailers splits a commit message into the body (everything before the trailer block) and the trailer block (trailing Key: Value lines preceded by a blank line). Continuation lines (indented lines following a trailer) are included in the trailer block.
If the message has no trailers, body is the entire message and trailerBlock is empty. If the entire message consists of trailer- format lines with no blank-line separator, body is empty and trailerBlock is the entire message.
#ReplaceIdentity
func ReplaceIdentity(message, oldName, newName, oldEmail, newEmail string) stringReplaceIdentity replaces author identity in identity-bearing trailers (lines whose key ends in "-by", such as Signed-off-by, Co-authored-by, Reviewed-by, Acked-by). Within those trailer lines, it replaces "oldName