Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

smart-commit

FreeNo executable scriptsNot checked

Detect staged and unstaged git changes, classify them by type (feat/fix/refactor/docs/chore/test/style/perf), group into logical commit units, then commit…

conectlensby conectlens★ 18 GitHub stars

About this skill

Smart Commit

Inspect the working tree, classify every change first, group into logical commits, then handle each commit separately with explicit user approval.

Never commit without user confirmation. Never lump unrelated changes into one commit.


Workflow

Step 1 — Snapshot the working tree

Run all three commands and keep the output in context:

git status --short
git diff --stat HEAD
git diff --cached --stat

If both staged and unstaged areas are empty, tell the user there is nothing to commit and stop.

Step 2 — Read the full diff

# Staged changes
git diff --cached

# Unstaged changes
git diff

Skim hunks to understand what changed, not just which files. Treat both staged and unstaged as candidates — classification covers everything.

Step 3 — Classify ALL changes (REQUIRED FIRST STEP)

This step is mandatory before any staging or committing decision is made.

Map every changed file (staged or unstaged) to a conventional-commit type:

Type When to use
feat New user-visible feature or capability
fix Bug fix or incorrect behavior corrected
refactor Code restructuring with no behavior change
perf Performance improvement
test Adding or updating tests only
docs Documentation, comments, README only
style Formatting, whitespace, lint — no logic change
chore Build scripts, deps, tooling, config
ci CI/CD pipeline changes
revert Reverts a previous commit

Output a classification table immediately:

File Status Type Scope Brief description
path/to/file.ts staged/unstaged feat auth Added login form
path/to/other.ts unstaged chore deps Updated lockfile

Do not proceed to Step 4 until this table is shown to the user.

Step 4 — Group into logical commit units

Based on the classification, propose separate commits for each distinct type/scope cluster. Do not merge unrelated types into one commit.

Rules for grouping:

  • Same type + same scope → one commit candidate
  • Different types → separate commits
  • Unrelated features in the same type → separate commits (use judgment)
  • A single large feat that also touches tests → two commits (feat + test) unless trivially inseparable
  • Purely mechanical changes (style, chore, docs) should never be bundled with feat/fix

Present the proposed grouping:

Proposed commit plan (N commits):

Commit 1 — feat(auth): login form + validation Files: src/auth/LoginForm.tsx, src/auth/validators.ts

Commit 2 — test(auth): add login form tests Files: src/auth/LoginForm.test.tsx

Commit 3 — chore(deps): update lockfile Files: pnpm-lock.yaml

Ask the user:

Does this grouping look right? Reply yes to proceed group by group, regroup <instructions> to adjust, or cancel to abort.

Wait for confirmation before continuing.

Step 5 — Handle each commit group, one at a time

For each proposed commit group (in order):

5a — Stage the files for this group

Stage only the files belonging to this group:

git add path/to/file1 path/to/file2

Never use git add -A or git add . unless the user explicitly requests it for a specific group.

5b — Draft the commit message

Format: Conventional Commits v1.0

<type>(<optional scope>): <short imperative summary, ≤72 chars>

<optional body: what changed and why, wrapped at 72 chars>

<optional footer: breaking changes, closes #issue>

Rules:

  • Summary line: imperative mood, no period, ≤72 chars
  • Body: explain why, not what (the diff shows what)
  • Breaking change: add BREAKING CHANGE: footer or ! after type
  • Co-author line added automatically on user approval

5c — Present and ask for confirmation

Show the user:

  1. Files being staged for this commit
  2. Proposed commit message (in a code block)
  3. Progress indicator — e.g., "Commit 1 of 3"
  4. Explicit question:

Shall I commit group 1/3 with this message? Reply yes to commit, edit <new message> to change the message, skip to skip this group, or cancel to abort all remaining commits.

5d — Act on the user's reply

Reply Action
yes / y Run git commit -m "..." with approved message + Co-Authored-By footer
edit <new message> Use provided message instead, ask once more
skip Skip this group, move to next
cancel / no Abort all remaining commits, leave working tree as-is

After each successful commit, show the short SHA and commit summary, then move to the next group.

Step 6 — Final summary

After all groups are processed, show a summary:

Done. N commits created:

  • abc1234 feat(auth): add login form
  • def5678 test(auth): add login form tests
  • ghi9012 chor
Full SKILL.md on GitHub

Install smart-commit in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the smart-commit skill do?

Detect staged and unstaged git changes, classify them by type (feat/fix/refactor/docs/chore/test/style/perf), group into logical commit units, then commit each group separately with user approval. Use when the user wants to commit their current work, wants help writing a commit message, or says /commit or /smart-commit.

How do I install the smart-commit skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the smart-commit skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare smart-commit with