1---2name: writing-git-commits3description: Split staged or uncommitted changes into conventional commits. Use when asked to commit, generate commit messages, split commits, squash commits, or reorder history.4---56# Writing Git Commits78## Workflow9101. **Inspect** — `diffs --staged` (staged) and `diffs` (unstaged); fallback to `git diff --stat` when raw line stats required112. **Group** — cluster related changes by intent123. **Order** — commit foundational changes first (deps, config, types), then features, then tests134. **Write** — use the message format below145. **Stage & commit** — `git hunks list`, `git hunks add <hunk-id>` (or `git add <paths>` for whole files), then `git commit -m "..."`1516## Message Format1718```19<type>(<scope>): <subject>2021[optional body]2223[optional footer]24```2526### Types2728| Type | When |29| ---------- | --------------------------------------- |30| `feat` | New feature or capability |31| `fix` | Bug fix |32| `refactor` | Code change that neither fixes nor adds |33| `docs` | Documentation only |34| `test` | Adding or updating tests |35| `chore` | Build, CI, deps, tooling |36| `style` | Formatting, whitespace, semicolons |37| `perf` | Performance improvement |3839### Rules4041- **Subject**: imperative mood, lowercase, no period, ≤72 chars42- **Scope**: optional, the module/area affected (e.g., `auth`, `pi`, `nix`)43- **Body**: wrap at 72 chars, explain _what_ and _why_ (not _how_)44- **Footer**: `Closes #123`, `BREAKING CHANGE: ...`45- **Atomic**: each commit compiles/passes independently46- **No mixed concerns**: don't combine a bugfix with a refactor4748### Examples4950```51feat(pi): add diff-renderer extension5253chore: update flake inputs5455fix(auth): prevent token refresh race condition5657Tokens were being refreshed concurrently, causing 401s for58in-flight requests. Added a mutex around the refresh call.5960Closes #426162refactor(shell): extract zsh plugin config to module63```6465## Grouping Heuristics6667- Same file touched for different reasons → separate commits68- Multiple files for one feature → single commit69- Formatting/whitespace mixed with logic → split them70- Dependency updates → own commit (`chore(deps): ...`)71- Generated files (lockfiles, schemas) → commit with the change that caused them