Get the FREE Ultimate OpenClaw Setup Guide →

git-commit-composer

npx machina-cli add skill Nembie/claude-code-skills/git-commit-composer --openclaw
Files (1)
SKILL.md
4.1 KB

Git Commit Composer

Before generating any output, read config/defaults.md and adapt all patterns, imports, and code examples to the user's configured stack.

Process

  1. Run git diff --cached to read staged changes. If nothing is staged, run git diff and inform the user to stage changes first.
  2. Analyze the diff to determine: what changed, why it changed, and the impact.
  3. Classify the change type and generate a commit message following Conventional Commits.
  4. If the diff contains multiple unrelated changes, suggest splitting into separate commits.

Commit Message Format

<type>(<scope>): <description>

[optional body]

[optional footer(s)]

Types

TypeWhen to use
featNew feature or capability
fixBug fix
refactorCode change that neither fixes a bug nor adds a feature
testAdding or updating tests
docsDocumentation changes only
styleFormatting, semicolons, whitespace (no logic change)
perfPerformance improvement
choreBuild, tooling, dependency updates, config changes
ciCI/CD configuration changes
buildBuild system or external dependency changes
revertReverts a previous commit

Scope

Derive the scope from the primary area of change:

  • File/module name: feat(auth): add JWT refresh token rotation
  • Feature area: fix(checkout): prevent double charge on retry
  • Layer: refactor(api): extract validation middleware

Omit scope if the change spans many unrelated areas.

Description Rules

  • Use imperative mood: "add" not "added" or "adds"
  • No capitalized first letter
  • No period at the end
  • Under 72 characters total (including type and scope)
  • Describe what the change does, not what was wrong

BAD:

fix: Fixed the bug where users couldn't log in.
feat: Added new validation to the form
chore: updated dependencies

GOOD:

fix(auth): prevent login failure when session cookie is expired
feat(form): add email format validation to signup form
chore(deps): bump next from 14.1.0 to 14.2.0

Body

Add a body when the description alone doesn't explain the "why":

fix(api): return 404 instead of 500 for missing resources

Previously, querying a non-existent user threw an unhandled
PrismaClientKnownRequestError, resulting in a 500 response.
Now the error is caught and mapped to a proper 404.

Breaking Changes

Use ! after the type/scope and add a BREAKING CHANGE footer:

feat(api)!: change user endpoint response format

BREAKING CHANGE: GET /api/users now returns { data: User[], meta: {...} }
instead of a plain User[] array. All clients must update their response parsing.

Multi-Change Detection

When the diff modifies unrelated areas, suggest splitting:

## Suggested Commits

The staged changes contain 3 unrelated modifications. Recommend splitting:

1. `feat(auth): add password reset endpoint`
   Files: `app/api/auth/reset/route.ts`, `lib/email.ts`

2. `fix(ui): correct date format on invoice page`
   Files: `components/InvoiceTable.tsx`

3. `chore(deps): bump zod from 3.22.0 to 3.23.0`
   Files: `package.json`, `package-lock.json`

To split, unstage all and re-stage per commit:
git reset HEAD .
git add app/api/auth/reset/route.ts lib/email.ts && git commit
git add components/InvoiceTable.tsx && git commit
git add package.json package-lock.json && git commit

Dependency Updates

For dependency changes, include the version bump:

chore(deps): bump next from 14.1.0 to 14.2.0
chore(deps-dev): add vitest 2.0.0 and @testing-library/react 16.0.0
fix(deps): pin prisma to 5.19.0 to resolve migration bug

Output Format

## Commit Message

[The generated commit message in a code block]

### Analysis
- **Type**: [type] — [reason for classification]
- **Scope**: [scope] — [derived from]
- **Files changed**: [count]
- **Insertions/deletions**: +[n] / -[n]

Source

git clone https://github.com/Nembie/claude-code-skills/blob/main/skills/git-commit-composer/SKILL.mdView on GitHub

Overview

Generates conventional commit messages from your staged changes. It reads diffs with git diff --cached, analyzes what changed and why, and outputs a <type>(<scope>): <description> message that follows the Conventional Commits convention. If multiple unrelated changes are present, it suggests splitting them into separate commits.

How This Skill Works

First, it reads the diff using git diff --cached (or git diff if nothing is staged) to determine what changed. It then classifies the change into a Conventional Commit type, derives a scope from the primary area touched, and builds a concise description that fits the format <type>(<scope>): <description>, with optional body and footers. If the diff contains unrelated changes, it flags the need to split into separate commits.

When to Use It

  • when you need to compose a commit message for staged changes
  • when you want to enforce the Conventional Commits format
  • when a diff includes multiple changes that should be split into separate commits
  • when you want the scope derived from the primary area touched
  • when you want to describe why changes were made with an optional body

Quick Start

  1. Step 1: stage relevant changes with git add -p or git add .
  2. Step 2: generate a Conventional Commit message from the diff (git diff --cached) and refine the description
  3. Step 3: run git commit -m '<generated message>' to finalize

Best Practices

  • Stage only the changes you intend to commit
  • Choose the correct type (feat, fix, refactor, etc.) and derive a meaningful scope
  • Keep the subject under 72 characters and use imperative mood
  • Provide a body to explain why if the change isn't obvious
  • If multiple unrelated changes exist, split them into separate commits

Example Use Cases

  • fix(auth): prevent login failure when session cookie is expired
  • feat(form): add email format validation to signup form
  • chore(deps): bump next from 14.1.0 to 14.2.0
  • refactor(api): extract validation middleware
  • docs(api): update endpoint usage in readme

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers