git-atomic-commits
Scannednpx machina-cli add skill saadjs/agent-skills/git-atomic-commits --openclawGit Atomic Commits
Goal
Transform all uncommitted changes into atomic Conventional Commits.
Stop only when git status is clean (and no untracked files remain unless explicitly told to leave them).
Definition: Atomic Commit
A commit should answer:
“What single logical change does this introduce?”
An atomic commit is easy to:
- review
- revert
- bisect/debug
Avoid mixing concerns (feature + refactor + formatting) in one commit.
Workflow
-
Check status:
git status -sb- Stop if clean.
-
Confirm branch:
git branch --show-current(orgit rev-parse --abbrev-ref HEAD)- If detached HEAD, ask the user to create a branch before committing.
-
Branch safety gate
- If the current branch is
mainormasterand there are changes to commit, do not commit. - Ask the user to create a working branch first:
git switch -c <branch-name> - Then re-run
git status -sband continue.
- If the current branch is
-
Inspect scope:
git diff --statgit diff(as needed)
-
Identify atomic units (one purpose each):
- dependencies
- config/build/CI
- refactor (behavior-preserving)
- bug fix
- feature slice
- tests
- docs
- formatting-only
-
Stage ONLY what belongs to one atomic unit:
- Prefer
git add -pfor mixed files. - Use whole-file staging when the file is cohesive.
- Prefer
-
Commit with Conventional Commits message.
-
Repeat:
- After each commit, run
git status -sb - Continue staging/committing atomic units until clean.
- After each commit, run
Atomic Grouping Rules
-
Dependencies
- If manifests change (e.g.,
package.json,pyproject.toml), commit them with lockfiles in the same commit. - Prefer
build(deps): ...orchore(deps): ....
- If manifests change (e.g.,
-
Config / CI / Build
- Keep build, lint, and CI config changes in their own commit.
-
Refactors
- Refactors must not change behavior.
- Never mix refactors with feature work or bug fixes.
-
Bug fixes
- Keep the fix isolated from refactors and formatting when possible.
-
Feature work
- Prefer one commit per “feature slice” (a coherent, reviewable increment), not “the whole feature” if large.
-
Tests
- Include tests with the change they validate when feasible.
- If tests are a separate logical unit, commit them separately as
test:.
-
Docs
- Docs-only changes should be a
docs:commit.
- Docs-only changes should be a
-
Formatting
- Formatting-only changes should be separate (
style:), never bundled with logic changes.
- Formatting-only changes should be separate (
Conventional Commit Rules
- Use
type(scope): subjectortype: subject - Keep subject short, imperative, and specific
- Suggested types:
feat,fix,chore,refactor,docs,test,build,ci,style
Examples:
feat(auth): add OAuth loginfix(api): handle timeout errorsrefactor(cache): simplify invalidation logicbuild(deps): bump react to 19.0.0style: format codebase
Safety Checks
- Do not include unrelated changes in the same commit.
- If a file mixes unrelated edits and hunk-splitting is ambiguous, ask before proceeding.
- Confirm intent before committing generated files or large diffs.
- Avoid committing build artifacts (
dist/,build/,coverage/, compiled outputs) unless the repo intentionally tracks them. - Ensure deletions and renames are included when relevant.
History Quality Check
Before finishing, verify:
✔ Each commit has one purpose
✔ Commit messages explain intent
✔ Commits can be reviewed independently
✔ Commits can be reverted safely
Optional: History Cleanup
If the current commit sequence contains WIP/noisy commits (or the user wants a cleaner story), offer an interactive rebase:
git rebase -i <base-branch>
Squash/reword/reorder so each remaining commit is atomic and clearly described.
Command Pattern
Inspect:
git status -sbgit diff --statgit diff
Stage:
git add -pgit add <file>
Commit:
git commit -m "type(scope): subject"
Repeat until clean.
Source
git clone https://github.com/saadjs/agent-skills/blob/main/skills/git-atomic-commits/SKILL.mdView on GitHub Overview
Git Atomic Commits helps you convert uncommitted changes into a sequence of atomic Conventional Commits. Each commit should answer a single logical change, making history easy to review, revert, and bisect. Use this before opening a PR or merging to produce a clean, reviewable history.
How This Skill Works
It guides you through status checks, branch validation, and isolating work into atomic units such as dependencies, config/CI, refactor, bug fixes, feature slices, tests, docs, and formatting. You stage only what belongs to one atomic unit (git add -p for mixed files) and commit with a Conventional Commit message, repeating until git status is clean.
When to Use It
- Before you open a PR or merge to ensure a clean, reviewable history where each commit has one purpose.
- When a large change touches multiple concerns (dependencies, code, tests, docs), to isolate each as its own commit.
- During feature slicing, so each logical increment is reviewable and reversible.
- After updates to dependencies or CI configurations to keep these changes in their own commits.
- When doing refactors that preserve behavior to avoid mixing with bug fixes or features.
Quick Start
- Step 1: Check your status and branch; stop if on main/master or detached HEAD.
- Step 2: Inspect changes with diffs and stage one atomic unit (git add -p or whole-file).
- Step 3: Commit with a Conventional Commit message; then re-run status and repeat until clean.
Best Practices
- Define the atomic units before staging to guide the workflow.
- Stage only what belongs to one atomic unit; use git add -p for mixed files.
- Commit with a Conventional Commit type and a concise, imperative subject.
- Review after each commit with git status and diffs to ensure a single purpose.
- Include tests or docs in separate commits when feasible to keep changes isolated.
Example Use Cases
- build(deps): bump react to 19.0.0
- feat(auth): add OAuth login
- fix(api): handle timeout errors
- refactor(cache): simplify invalidation logic
- style: format codebase