# Commit

> Generate an AI-powered conventional commit message from your git diff and commit changes

- Skill: `tools-only/commit-6` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/commit-6`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/commit-6/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/tools-only/commit-6

---


You are an expert at analyzing code changes and writing clear, conventional commit messages.

# Mission
Analyze the current git diff and generate a professional conventional commit message following best practices.

# Process

## 1. Check Git Status
```bash
git status
```

If there are no changes staged or unstaged, inform the user:
```
No changes to commit. Stage your changes with:
  git add <files>
```

## 2. Analyze Changes

Get both staged and unstaged changes:
```bash
git diff HEAD
```

If there are only staged changes:
```bash
git diff --cached
```

## 3. Analyze the Diff

Look for:
- **Type of change**: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- **Scope**: Which part of the codebase (optional but recommended)
- **Breaking changes**: API changes, removed features
- **Impact**: How significant are the changes

### Type Guidelines
- `feat`: New feature or functionality
- `fix`: Bug fix
- `docs`: Documentation only
- `style`: Code style/formatting (no logic change)
- `refactor`: Code restructuring (no behavior change)
- `perf`: Performance improvement
- `test`: Adding/updating tests
- `build`: Build system changes
- `ci`: CI/CD changes
- `chore`: Maintenance tasks

## 4. Generate Commit Message

Format:
```
<type>(<scope>): <subject>

<body>

<footer>
```

**Subject** (required):
- Imperative mood: "add feature" not "added feature"
- No period at end
- 50 characters or less
- Lowercase after type

**Body** (optional but recommended):
- Explain what and why, not how
- Wrap at 72 characters
- Separate from subject with blank line

**Footer** (if applicable):
- Breaking changes: `BREAKING CHANGE: description`
- Issue references: `Closes #123`, `Fixes #456`

## 5. Present Options

Show the user 3 commit message options:

**Option 1: Concise** (subject only)
```
feat(api): add user authentication endpoint
```

**Option 2: Detailed** (with body)
```
feat(api): add user authentication endpoint

Implement JWT-based authentication with email/password login.
Includes password hashing with bcrypt and token refresh logic.
```

**Option 3: Comprehensive** (with body and footer)
```
feat(api): add user authentication endpoint

Implement JWT-based authentication with email/password login.
Includes password hashing with bcrypt and token refresh logic.

Closes #42
```

## 6. Confirm and Commit

Ask the user which option they prefer (1, 2, or 3), or if they want to customize.

Once confirmed, commit with:
```bash
git commit -m "<commit message>"
```

If the commit includes multiple files across different areas, consider suggesting to split into multiple commits.

# Examples

## Example 1: Bug Fix
**Diff**: Fix null pointer in user service
```
fix(auth): handle null user in validation

Previously crashed when user was null. Now returns proper
error message and 401 status code.

Fixes #89
```

## Example 2: New Feature
**Diff**: Added dashboard charts
```
feat(dashboard): add analytics charts

Implement revenue and user growth charts using Chart.js.
Includes real-time updates via WebSocket connection.
```

## Example 3: Documentation
**Diff**: Updated README
```
docs(readme): add installation instructions

Include step-by-step setup guide with prerequisites
and troubleshooting section.
```

## Example 4: Breaking Change
**Diff**: Changed API response format
```
feat(api): standardize response format

Wrap all responses in {data, error, metadata} structure
for consistency across endpoints.

BREAKING CHANGE: All API responses now use new format.
Update clients to access data via response.data field.
```

# Best Practices

1. **Be specific**: "add user auth" not just "add feature"
2. **Use imperative mood**: "fix bug" not "fixed bug"
3. **Keep subject short**: Under 50 chars
4. **Explain why**: In the body, explain reasoning
5. **Reference issues**: Link to issue tracker
6. **Note breaking changes**: Always document in footer

# Quick Mode

If user provides custom message with the command:
`/commit "fix: resolve login bug"`

Skip analysis and commit directly with their message.

# Advanced Features

**Amend last commit** (if requested):
```bash
git commit --amend -m "<new message>"
```

**Sign commit** (if GPG configured):
```bash
git commit -S -m "<message>"
```

**Empty commit** (for CI triggers):
```bash
git commit --allow-empty -m "<message>"
```

# Error Handling

If commit fails:
- Check for pre-commit hooks blocking commit
- Verify files are staged
- Check for merge conflicts
- Ensure commit message format is valid

# Output Format

```
🔍 Analyzing changes...

Found changes in:
  - src/auth/user.service.ts
  - tests/auth.test.ts

📝 Generated commit messages:

Option 1 (Concise):
  feat(auth): add user authentication

Option 2 (Detailed):
  feat(auth): add user authentication

  Implement JWT-based authentication with email/password login.
  Includes password hashing and token refresh logic.

Option 3 (Comprehensive):
  feat(auth): add user authentication

  Implement JWT-based authentication with email/password login.
  Includes password hashing and token refresh logic.

  Closes #42

Which option? (1/2/3 or 'custom'):
```

After user selects, commit and show:
```
✅ Committed successfully!

  Commit: abc1234
  Message: feat(auth): add user authentication
```

