Smart Commit
Generate precise, conventional commit messages from staged git changes and optionally commit in one step.
Workflow
- Run
git diff --cached --stat to see what's staged. If nothing is staged, check git diff --stat and ask the user if they want to stage all changes first.
- Run
git diff --cached to get the full diff (if very large, use --stat summary + sample key hunks).
- Analyze the diff and generate a commit message following the rules below.
- Present the message to the user. If approved, run
git commit -m "<message>".
Commit Message Format
Follow Conventional Commits:
<type>(<scope>): <subject>
[optional body]
[optional footer]
Rules
- type: One of
feat, fix, refactor, docs, chore, test, style, perf, ci, build
- scope: Optional. Infer from changed files (e.g.,
auth, api, ui, db). Omit if changes span too many areas.
- subject: Imperative mood, lowercase, no period, max 72 chars. Be specific — not "update files" but "add retry logic to HTTP client".
- body: Add only when the "why" isn't obvious from the subject. Wrap at 72 chars.
- breaking changes: Add
! after type/scope and BREAKING CHANGE: footer.
- Multiple logical changes: If the diff contains clearly unrelated changes, suggest splitting into multiple commits with
git add -p.
Type Selection Guide
| Signal |
Type |
| New feature, new endpoint, new UI element |
feat |
| Bug fix, error correction, patch |
fix |
| Code restructure, no behavior change |
refactor |
| Comments, README, docs, JSDoc |
docs |
| Dependencies, configs, tooling |
chore |
| Test files added/modified |
test |
| Formatting, whitespace, linting |
style |
| Performance improvement |
perf |
| CI/CD pipeline changes |
ci |
| Build system, compilation |
build |
Quality Checklist
Before presenting the message, verify:
Examples
Single file fix:
fix(auth): handle expired JWT tokens in refresh flow
Multi-file feature:
feat(api): add pagination support to list endpoints
Implement cursor-based pagination for /users, /posts, and /comments.
Default page size is 20, max 100.
Breaking change:
feat(config)!: migrate from YAML to TOML configuration
BREAKING CHANGE: config.yaml is no longer supported.
Run `migrate-config` to convert existing configs.
Chore:
chore(deps): bump express from 4.18.2 to 4.19.0
Large Diffs
For diffs exceeding ~4000 lines:
- Use
git diff --cached --stat for overview
- Read key files with
git diff --cached -- <important-file>
- Summarize the overall change from the stat + sampled hunks
- If changes are too diverse, recommend splitting the commit
Options
The user may specify preferences:
--no-body: Skip the body, subject only
--scope <name>: Force a specific scope
--type <type>: Force a specific type
--amend: Amend the previous commit instead
--dry-run: Generate message without committing
1---2name: smart-commit3description: Analyze staged git changes and generate high-quality commit messages following Conventional Commits format. Use when: (1) user asks to commit changes, (2) user wants a commit message generated, (3) user says 'smart commit' or 'auto commit', (4) user asks to describe staged changes. Supports feat/fix/refactor/docs/chore/test/style/perf/ci/build types with optional scope and breaking change detection.4---56# Smart Commit78Generate precise, conventional commit messages from staged git changes and optionally commit in one step.910## Workflow11121. Run `git diff --cached --stat` to see what's staged. If nothing is staged, check `git diff --stat` and ask the user if they want to stage all changes first.132. Run `git diff --cached` to get the full diff (if very large, use `--stat` summary + sample key hunks).143. Analyze the diff and generate a commit message following the rules below.154. Present the message to the user. If approved, run `git commit -m "<message>"`.1617## Commit Message Format1819Follow [Conventional Commits](https://www.conventionalcommits.org/):2021```22<type>(<scope>): <subject>2324[optional body]2526[optional footer]27```2829### Rules3031- **type**: One of `feat`, `fix`, `refactor`, `docs`, `chore`, `test`, `style`, `perf`, `ci`, `build`32- **scope**: Optional. Infer from changed files (e.g., `auth`, `api`, `ui`, `db`). Omit if changes span too many areas.33- **subject**: Imperative mood, lowercase, no period, max 72 chars. Be specific — not "update files" but "add retry logic to HTTP client".34- **body**: Add only when the "why" isn't obvious from the subject. Wrap at 72 chars.35- **breaking changes**: Add `!` after type/scope and `BREAKING CHANGE:` footer.36- **Multiple logical changes**: If the diff contains clearly unrelated changes, suggest splitting into multiple commits with `git add -p`.3738### Type Selection Guide3940| Signal | Type |41|--------|------|42| New feature, new endpoint, new UI element | `feat` |43| Bug fix, error correction, patch | `fix` |44| Code restructure, no behavior change | `refactor` |45| Comments, README, docs, JSDoc | `docs` |46| Dependencies, configs, tooling | `chore` |47| Test files added/modified | `test` |48| Formatting, whitespace, linting | `style` |49| Performance improvement | `perf` |50| CI/CD pipeline changes | `ci` |51| Build system, compilation | `build` |5253### Quality Checklist5455Before presenting the message, verify:5657- [ ] Subject is specific and descriptive (someone reading `git log --oneline` can understand the change)58- [ ] Type accurately reflects the change59- [ ] Scope is correct or intentionally omitted60- [ ] No vague words: "update", "change", "modify", "fix stuff", "misc"61- [ ] Breaking changes are flagged if applicable6263## Examples6465**Single file fix:**66```67fix(auth): handle expired JWT tokens in refresh flow68```6970**Multi-file feature:**71```72feat(api): add pagination support to list endpoints7374Implement cursor-based pagination for /users, /posts, and /comments.75Default page size is 20, max 100.76```7778**Breaking change:**79```80feat(config)!: migrate from YAML to TOML configuration8182BREAKING CHANGE: config.yaml is no longer supported.83Run `migrate-config` to convert existing configs.84```8586**Chore:**87```88chore(deps): bump express from 4.18.2 to 4.19.089```9091## Large Diffs9293For diffs exceeding ~4000 lines:94951. Use `git diff --cached --stat` for overview962. Read key files with `git diff --cached -- <important-file>` 973. Summarize the overall change from the stat + sampled hunks984. If changes are too diverse, recommend splitting the commit99100## Options101102The user may specify preferences:103104- **`--no-body`**: Skip the body, subject only105- **`--scope <name>`**: Force a specific scope106- **`--type <type>`**: Force a specific type107- **`--amend`**: Amend the previous commit instead108- **`--dry-run`**: Generate message without committing