Git 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 (or git rev-parse --abbrev-ref HEAD)
- If detached HEAD, ask the user to create a branch before committing.
Branch safety gate
Inspect scope:
git diff --stat
git 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 -p for mixed files.
- Use whole-file staging when the file is cohesive.
Commit with Conventional Commits message.
Repeat:
- After each commit, run
git status -sb
- Continue staging/committing atomic units until clean.
Atomic Grouping Rules
Dependencies
- If manifests change (e.g.,
package.json, pyproject.toml), commit them with lockfiles in the same commit.
- Prefer
build(deps): ... or chore(deps): ....
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.
Formatting
- Formatting-only changes should be separate (
style:), never bundled with logic changes.
Conventional Commit Rules
- Use
type(scope): subject or type: subject
- Keep subject short, imperative, and specific
- Suggested types:
feat, fix, chore, refactor, docs, test, build, ci, style
Examples:
feat(auth): add OAuth login
fix(api): handle timeout errors
refactor(cache): simplify invalidation logic
build(deps): bump react to 19.0.0
style: 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 -sb
git diff --stat
git diff
Stage:
git add -p
git add <file>
Commit:
git commit -m "type(scope): subject"
Repeat until clean.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: git-atomic-commits3description: Organize uncommitted changes into atomic Git commits using Conventional Commits. Use before opening a PR or merging to produce a clean, reviewable history where each commit represents one logical change. Use when this capability is needed.4---56# Git Atomic Commits78## Goal910Transform all uncommitted changes into **atomic** Conventional Commits.1112Stop only when `git status` is clean (and no untracked files remain unless explicitly told to leave them).1314## Definition: Atomic Commit1516A commit should answer:1718> “What single logical change does this introduce?”1920An atomic commit is easy to:2122- review23- revert24- bisect/debug2526Avoid mixing concerns (feature + refactor + formatting) in one commit.2728## Workflow29301. Check status:31 - `git status -sb`32 - Stop if clean.33342. Confirm branch:35 - `git branch --show-current` (or `git rev-parse --abbrev-ref HEAD`)36 - If detached HEAD, ask the user to create a branch before committing.37383. **Branch safety gate**39 - If the current branch is `main` or `master` and there are changes to commit, **do not commit**.40 - Ask the user to create a working branch first:41 ```bash42 git switch -c <branch-name>43 ```44 - Then re-run `git status -sb` and continue.45464. Inspect scope:47 - `git diff --stat`48 - `git diff` (as needed)49505. Identify atomic units (one purpose each):51 - dependencies52 - config/build/CI53 - refactor (behavior-preserving)54 - bug fix55 - feature slice56 - tests57 - docs58 - formatting-only59606. Stage ONLY what belongs to one atomic unit:61 - Prefer `git add -p` for mixed files.62 - Use whole-file staging when the file is cohesive.63647. Commit with Conventional Commits message.65668. Repeat:67 - After each commit, run `git status -sb`68 - Continue staging/committing atomic units until clean.6970## Atomic Grouping Rules7172- **Dependencies**73 - If manifests change (e.g., `package.json`, `pyproject.toml`), commit them with lockfiles in the same commit.74 - Prefer `build(deps): ...` or `chore(deps): ...`.7576- **Config / CI / Build**77 - Keep build, lint, and CI config changes in their own commit.7879- **Refactors**80 - Refactors must not change behavior.81 - Never mix refactors with feature work or bug fixes.8283- **Bug fixes**84 - Keep the fix isolated from refactors and formatting when possible.8586- **Feature work**87 - Prefer one commit per “feature slice” (a coherent, reviewable increment), not “the whole feature” if large.8889- **Tests**90 - Include tests with the change they validate when feasible.91 - If tests are a separate logical unit, commit them separately as `test:`.9293- **Docs**94 - Docs-only changes should be a `docs:` commit.9596- **Formatting**97 - Formatting-only changes should be separate (`style:`), never bundled with logic changes.9899## Conventional Commit Rules100101- Use `type(scope): subject` or `type: subject`102- Keep subject short, imperative, and specific103- Suggested types: `feat`, `fix`, `chore`, `refactor`, `docs`, `test`, `build`, `ci`, `style`104105Examples:106107- `feat(auth): add OAuth login`108- `fix(api): handle timeout errors`109- `refactor(cache): simplify invalidation logic`110- `build(deps): bump react to 19.0.0`111- `style: format codebase`112113## Safety Checks114115- Do not include unrelated changes in the same commit.116- If a file mixes unrelated edits and hunk-splitting is ambiguous, ask before proceeding.117- Confirm intent before committing generated files or large diffs.118- Avoid committing build artifacts (`dist/`, `build/`, `coverage/`, compiled outputs) unless the repo intentionally tracks them.119- Ensure deletions and renames are included when relevant.120121## History Quality Check122123Before finishing, verify:124125✔ Each commit has one purpose 126✔ Commit messages explain intent 127✔ Commits can be reviewed independently 128✔ Commits can be reverted safely129130## Optional: History Cleanup131132If the current commit sequence contains WIP/noisy commits (or the user wants a cleaner story), offer an interactive rebase:133134```bash135git rebase -i <base-branch>136```137138Squash/reword/reorder so each remaining commit is atomic and clearly described.139140## Command Pattern141142Inspect:143144- `git status -sb`145- `git diff --stat`146- `git diff`147148Stage:149150- `git add -p`151- `git add <file>`152153Commit:154155- `git commit -m "type(scope): subject"`156157Repeat until clean.158159---160> Converted and distributed by [TomeVault](https://tomevault.io/claim/saadjs) — claim your Tome and manage your conversions.161<!-- tomevault:4.0:skill_md:2026-04-14 -->