## What makes a good commit message

A useful commit message answers *why* a change was made, not just what changed. The diff already shows what changed — the message should add context a reviewer cannot infer from the code alone.

The standard conventions:

- **Imperative mood**: "Add retry logic" not "Added retry logic"
- **Subject line under 72 characters**
- **Conventional Commit prefix**: `feat:`, `fix:`, `docs:`, `chore:`, `refactor:`, etc.

A Conventional Commit looks like this:

```
feat(auth): add OAuth2 token refresh on expiry

Previously the app returned a 401 after the access token expired.
Now it silently refreshes using the stored refresh token and retries
the original request.
```

## Tools that generate commit messages automatically

### GitHub Copilot

Copilot has built-in commit message generation in VS Code, JetBrains IDEs, and GitHub Desktop. Stage your changes, then click the sparkle icon in the Source Control panel.

To steer toward Conventional Commits, add a custom instruction in VS Code settings:

```json
{
  "github.copilot.chat.commitMessageGeneration.instructions": "Always use Conventional Commits format: <type>(<scope>): <description>. Types: feat, fix, docs, chore, refactor, test, ci."
}
```

### Cursor

In Cursor's Source Control panel, the AI commit button reads your staged diff directly and uses your project context for more precise messages.

### aicommit2 (CLI)

`aicommit2` supports OpenAI, Anthropic Claude, Google Gemini, and Ollama.

```bash
npm install -g aicommit2
aicommit2 config set OPENAI_KEY=sk-...
# stage your changes, then:
aicommit2
```

## Using any AI chat tool manually

This prompt works with ChatGPT, Claude, Gemini, or any chat interface:

```
Here is my staged git diff:

<paste output of: git diff --staged>

Write a single git commit message in Conventional Commits format.
Use the correct type (feat, fix, docs, chore, refactor, test, ci).
Imperative mood, subject line under 72 characters.
Add a short body explaining WHY this change was made if not obvious.
```

## The golden rule: keep commits small

AI generates better messages when commits are focused. A 3-file diff with one logical change produces a clear, accurate message. A 40-file diff produces a vague one — no message can honestly summarise work that should have been several commits.

For a deeper look at structuring your commit workflow around AI, see the full guide at [deployhq.com/git/mastering-git-commit-with-ai](https://deployhq.com/git/mastering-git-commit-with-ai).