Organize and create atomic git commits with intelligent change grouping
Analyze changes, group them into coherent atomic commits, and create signed commits following repository conventions. This command transforms a messy working directory into a clean, logical commit history.
| Principle | Description |
|---|---|
| Feature + Tests | Implementation and its tests go together |
| Config Changes | package.json, tsconfig, etc. grouped separately |
| Documentation | README, docs/ changes grouped together |
| Refactoring | Pure refactors (no behavior change) separate |
| Bug Fixes | Each fix is atomic with its test |
git status and git diff to understand all changesSingle commit when:
Multiple commits when:
Before creating commits, present the plan:
Proposed Commit Plan:
āāāāāāāāāāāāāāāāāāāāā
1. feat(auth): add OAuth2 refresh token support
- src/auth/oauth.ts (modified)
- src/auth/oauth.test.ts (modified)
2. chore(deps): update authentication dependencies
- package.json (modified)
- package-lock.json (modified)
3. docs: update OAuth2 setup guide
- docs/auth/oauth-setup.md (modified)
Proceed with this plan? [Yes / Modify / Single commit]
These rules MUST be followed for EVERY commit:
ALWAYS USE conventional commits v1.0.0 to write the messages:
../../docs/convetional-commits.mdCommit message body must be clean and professional:
Run these commands in parallel to understand the current state:
# Check staged and unstaged changes
git status
# View ALL changes (staged and unstaged)
git diff
git diff --cached
# View recent commits for style reference
git log --oneline -10
For each changed file, determine:
Grouping heuristics:
IMPORTANT NOTE: This example is only for illustration purposes. The actual grouping should be based on the actual changes and programming language standards.
| File Pattern | Likely Group |
|---|---|
*.test.ts, *.spec.ts |
Group with implementation file |
package.json, *-lock.json |
Dependency changes |
*.md, docs/* |
Documentation |
*.config.*, tsconfig.* |
Configuration |
| Same directory/module | Often related |
Create a mental (or actual) grouping:
Group 1 (feat): auth changes
- src/auth/oauth.ts
- src/auth/oauth.test.ts
Group 2 (chore): dependencies
- package.json
- package-lock.json
Group 3 (docs): documentation
- README.md
Order matters for bisectability:
MANDATORY: Get user confirmation before executing.
If user selects "Let me review", show the full plan with files per commit.
For each commit group, in order:
Stage only the files for this commit:
git add <file1> <file2> ...
After all commits, verify the result:
# Show all new commits
git log --oneline -<number_of_commits>
# Confirm clean state
git status
If the user provides a commit message as argument:
After successful commit, ask the user if they want to push:
git push
git push -u origin <current-branch>