git-commit-messages

Format git commit messages correctly, avoiding HEREDOC syntax issues in favor of multiline strings

⭐2stars🔀0forks📁View on GitHub🕐Updated Dec 30, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill optimizes Git version control workflows by ensuring commit messages are formatted correctly for AI-driven Bash tools. It eliminates common shell execution errors by replacing unreliable HEREDOC syntax with robust multiline strings, facilitating the creation of structured, multi-line commits with proper attribution and cross-platform compatibility.

Use Cases

  • Executing reliable multi-line Git commits within AI-assisted coding environments like Claude Code to avoid shell interpretation failures.
  • Standardizing conventional commit formats including headers, bodies, and footers for better project history and repository maintenance.
  • Automating the inclusion of metadata such as 'Co-Authored-By' and AI-generated attribution in commit messages for transparent development.
  • Ensuring Git command portability across different shell environments and execution contexts where HEREDOC might be unsupported or unstable.
namegit-commit-messages
descriptionFormat git commit messages correctly, avoiding HEREDOC syntax issues in favor of multiline strings

Git Commit Message Formatting

When to Use This Skill

Use this skill when creating git commits with the Bash tool, especially for commits with:

  • Multi-line messages
  • Body text or explanations
  • Co-authored-by footers
  • Claude Code attribution

Core Principle

Avoid HEREDOC syntax - Use -m with multiline strings instead.

Pattern to Follow

✅ DO - Use multiline string with -m

git commit -m "feat(github): add github plugin

This adds comprehensive GitHub workflow support including
commands for PR management and review workflows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Key points:

  • Single -m flag with entire message in quotes
  • Newlines preserved within the quoted string
  • No special syntax or escaping needed
  • Works reliably across all environments

❌ DON'T - Use HEREDOC syntax

# This FAILS in Claude Code's Bash tool
git commit -m "$(cat <<'EOF'
feat(github): add github plugin

This adds comprehensive GitHub workflow support.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Why this fails:

  • HEREDOC syntax has shell interpretation issues
  • Fails in certain execution contexts
  • More complex than necessary
  • Unreliable across environments

Examples

Simple commit

git commit -m "fix: resolve path configuration issue"

Commit with body

git commit -m "feat: add progressive disclosure pattern

Skills now support references/ subdirectory for
detailed documentation that loads on-demand."
git commit -m "chore: update dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Full conventional commit

git commit -m "feat(tools): add git commit message skill

This skill teaches Claude to format git commit messages
using multiline strings instead of HEREDOC syntax, which
fails in certain shell environments.

The pattern uses a single -m flag with the entire message
in quotes, preserving newlines naturally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Why It Matters

Using -m with multiline strings is:

  • Reliable: Works consistently in all environments
  • Simple: No complex shell syntax needed
  • Portable: Standard git behavior
  • Direct: Git handles newlines correctly

HEREDOC syntax causes issues because:

  • Shell interpretation varies by environment
  • Execution context in Claude Code differs from terminal
  • Quote handling becomes complex
  • Unnecessary complexity for the task

Quick Reference

Template for commits with Claude Code attribution:

git commit -m "<type>[optional scope]: <description>

[optional body]

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

Remember:

  • One -m flag
  • Entire message in double quotes
  • Newlines work naturally
  • No HEREDOC needed