# Commit Message Generation

## Determine Commit Type

```bash
# Determine commit type from branch
BRANCH_TYPE=$(echo $CURRENT | cut -d'/' -f1)
case "$BRANCH_TYPE" in
  feature) PREFIX="feat" ;;
  hotfix)  PREFIX="fix" ;;
  release) PREFIX="chore" ;;
  *)       PREFIX="chore" ;;
esac

# Determine scope from branch name
SCOPE=$(echo $CURRENT | cut -d'/' -f2 | cut -d'-' -f1)

# If migrations present
[ "$HAS_MIGRATIONS" = "true" ] && PREFIX="db(migrations)"

# Generate message from diff analysis
SUMMARY=$(git diff --cached --stat | tail -1 | sed 's/^ *//')
```

## Message Format

```
{type}({scope}): {summary - 50 chars max}

**CHANGE**
PROBLEM: {what was wrong}
SOLUTION: {what was done}
IMPACT: {benefit}

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

## Stage and Create Commit

```bash
# Stage all changes
git add -A

# Show what will be committed
echo "Files to commit:"
git diff --cached --stat
```

## Create Commit

```bash
git commit -m "$(cat <<'EOF'
{generated_message}
EOF
)"

COMMIT_HASH=$(git rev-parse --short HEAD)
```
