logical-commits
Logical Commits
Turn a mixed worktree into a clean sequence of atomic commits.
Workflow
- Inspect the full change set before staging anything.
- Define commit boundaries by behavior or concern, not by file count.
- Order commits so dependencies land first (types/api/schema/helpers before consumers).
- Stage only the exact hunks for one commit.
- Validate that staged commit state is healthy before committing.
- Commit with a precise message.
- Repeat until all intended changes are committed.
1) Inspect First
Run:
git status --short
git diff --stat
git diff
If there are staged changes already, inspect both views:
git diff --staged
git diff
2) Choose Validation Command Early
Select the fastest command that proves the repo is valid for this project. Prefer project-standard commands (for example: just test, npm test, cargo test, go test ./..., nix flake check, targeted build commands).
If no clear command exists:
- Infer the best available command from repo scripts/config.
- Tell the user what command you chose and why.
- Do not claim full validation if coverage is partial.
3) Plan the Commit Stack
Before committing, write a short plan:
- Commit title
- Files and hunks included
- Why this is a coherent unit
- Validation command to run
If changes are intertwined, split by hunk (git add -p). If hunk splitting is not enough, use git add -e or perform a temporary refactor so each commit remains coherent and valid.
4) Stage Exactly One Commit
Preferred staging flow:
git add -p <file>
git diff --staged
Useful corrections:
git restore --staged -p <file> # unstage specific hunks
git reset -p <file> # alternate unstage flow
Never stage unrelated edits just to make the commit pass.
5) Validate Before Commit
Run the chosen validation command with the current staged/working tree state.
If validation fails:
- Fix only what belongs in this logical commit, or
- Unstage/re-split and revise the commit boundary.
Commit only after validation passes.
6) Commit and Verify
Commit:
git commit -m "<type>: <logical change>"
Then confirm:
git show --stat --oneline -1
Ensure remaining unstaged changes still make sense for later commits.
7) Final Checks
After finishing the stack:
git log --oneline --decorate -n <count>
git status
Report:
- The commit sequence created
- Validation command(s) run per commit
- Any residual risks (for example, partial validation only)
Guardrails
- Keep commits atomic and reviewable.
- Prefer hunk staging over broad file staging when a file contains multiple concerns.
- Preserve user changes; do not discard unrelated work.
- Avoid destructive commands unless the user explicitly requests them.
- If a clean logical split is impossible without deeper refactor, explain the blocker and ask for direction.
More from colonelpanic8/dotfiles
email-unsubscribe-check
Use when user wants to find promotional or unwanted recurring emails to unsubscribe from, or when doing periodic inbox hygiene to identify senders worth unsubscribing from
19release
Use when user asks to release, publish, bump version, or prepare a new version for deployment
1slides
Build, edit, render, import, and export presentation decks with the preloaded @oai/artifact-tool JavaScript surface through the artifacts tool.
1spreadsheets
Build, edit, recalculate, import, and export spreadsheet workbooks with the preloaded @oai/artifact-tool JavaScript surface through the artifacts tool.
1org-agenda-api
Use when interacting with the org-agenda-api HTTP server to read/write org-mode agenda data
1playwright-cli
Automate browser interactions from the shell using Playwright via the `playwright-cli` command (open/goto/snapshot/click/type/screenshot, tabs/storage/network). Use when you need deterministic browser automation for web testing, form filling, screenshots/PDFs, or data extraction.
1