---
name: smart-commit
description: Analyze uncommitted git changes and create logical, incremental commits with related changes grouped together. Use when user asks to review changes for commit, create smart commits, run smart-commit or /sc, organize uncommitted work into atomic commits, or wants help grouping changes into logical commits.
---

# Smart Commit Review

Analyze all uncommitted changes and create logical, incremental commits with related changes grouped together.

## Workflow

### 1. Analyze Changes

Run these commands to understand the current state:
- `git status` - see modified and untracked files
- `git diff` - see actual changes in each file
- `git log -5 --oneline` - understand the repository's commit style

### 2. Group Related Changes

Identify logical groupings based on:
- Related functionality or features
- File types (config, tests, source code)
- Dependencies (a function and its test)
- Scope (database, API, documentation)

### 3. Present Commit Proposals

For each logical group, present using this format:

```
Commit Proposal #N

Messages:
  - <repository style>
  - <Conventional Commits style>

Files:
  M src/file1.ts
  M src/file2.ts
  A test/newfile.test.ts

Summary:
<What this commit accomplishes in 2-3 sentences>
```

After each proposal, ask: "Create this commit? (yes/no/modify)"

### 4. Execute Approved Commits

For approved commits:
1. Ask: "Use Conventional Commits message? (yes/no)"
2. Stage only the specified files: `git add <files>`
3. Create the commit with the agreed message
4. Confirm with `git log -1 --stat`

## Rules

- Do NOT push changes - only create local commits
- Do NOT commit without explicit user approval for each commit
- Keep commits atomic and reviewable
- Prefer multiple small commits over one large commit

## Special Handling: AGENTS.md and CLAUDE.md

If either AGENTS.md or CLAUDE.md is modified or created:
1. Always propose them together as **Commit Proposal #1** before any other changes
2. Use message: "docs: update AI assistant configuration"
3. If the user refuses this commit, ask: "Would you like me to add AGENTS.md and CLAUDE.md to .git/info/exclude so they're ignored locally?"
4. If yes, append both filenames to `.git/info/exclude`
