Guided commit on explicit /commit request — first runs a code review of the uncommitted diff (review gate, effort sized to the diff), then splits the changes into atomic commits ordered by layer, passes two validations (file selection, then message), manages the branch (creation/switch with stash), then runs git add + git commit. To use as soon as the user says /commit, \"commit that\", \"make the commit\", or wants to commit finished work. NEVER push, merge, rebase or reset. Never commit out...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Commit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/zoomma1-commit)
---
name: commit
description: "Guided commit on explicit /commit request — first runs a code review of the uncommitted diff (review gate, effort sized to the diff), then splits the changes into atomic commits ordered by layer, passes two validations (file selection, then message), manages the branch (creation/switch with stash), then runs git add + git commit. To use as soon as the user says /commit, \"commit that\", \"make the commit\", or wants to commit finished work. NEVER push, merge, rebase or reset. Never commit outside this skill."
allowed-tools: Bash(git add *) Bash(git commit *) Bash(git status *) Bash(git diff *) Bash(git log *) Bash(git branch *) Bash(git switch *) Bash(git checkout *) Bash(git stash *) Bash(git rev-parse *)
---
# /commit — guided commit
This skill runs commits **on behalf of {USER_NAME}**, which is an exception to the rule "{USER_NAME} is the sole master of Git". The exception only holds because two explicit validations frame every commit: {USER_NAME} keeps control over **what** gets committed and **with which message**. If either validation does not happen, the commit does not happen. That is the whole point of the skill — losing these guardrails would amount to committing blind.
> **Fallback outside the vault (skill not loaded)**: in an external dev repo where `/commit` is not invocable (e.g. `evaluation-line-chart`, a repo outside the vault without this skill), the rule "commit only via `/commit`" is replayed **manually**, with the same two gates: (1) show the files in the diff + the proposed split → **explicit OK** from {USER_NAME}, then (2) propose the message → **explicit OK**, then `git add` + `git commit`. Never commit in a single pass without these two named validations. This is the spirit of the skill reproduced by hand, not a deviation from the Git rule. (Observed 2026-07-09, TMAFR-1094.)
## Invariants (non-negotiable)
These rules exist because the commands below are destructive or outbound, and {USER_NAME} wants to remain the sole master of them:
- 🚫 **Never** `git push`, `git merge`, `git rebase`, `git reset`. If one of these is needed, **suggest** it to {USER_NAME}, do not run it.
- 🚫 **Never** commit without both validations (files + message).
- 🚫 **Never** commit outside this skill (no "while I'm at it" commit within another task).
- ✅ `git add`, `git commit`, `git switch`, `git checkout -b`, `git stash` are allowed — but **only** within the flow below.
`reset` is excluded on purpose: to commit only part of the changes, you **stage selectively** (`git add <files>` or `git add -p`) instead of staging everything and then unselecting. We therefore never unstage globally.
## Step 0 — Run a code review (review gate)
Committing means freezing into history. We review **before**, while the diff is fresh and uncommitted: applying a fix is trivial, rewriting a commit is not.
First check that we are inside a repo:
```
git rev-parse --is-inside-work-tree
```
If the command fails (outside a git repo), stop immediately ("Not in a git repo — nothing to commit"). Issue **no** mutating git command.
Then run `/code-review` on the uncommitted diff (working tree + range), **sizing the effort to the diff**:
- **Trivial** diff (typo, mechanical rename, version bump, a few lines with no logic) → skip the review, announce it ("trivial diff, skipping the review") and move on to Step 1.
- **100% documentation** diff (all files under `docs/`, or `README*`, `CLAUDE.md`, `CONVENTIONS.md`, doc `*.md` — **no** code, executable config or test files) → **propose** skipping the gate ("pure doc diff, I propose skipping the review — do you confirm?") rather than running it by default. The cost of an agent review exceeds its value on prose: it can neither compile, nor execute, nor compare against a behavior. It remains a **proposal**, not an automatic skip — {USER_NAME} may want the review on normative docs (a `CONVENTIONS.md` that changes a team rule is not prose). (Cause: 2026-08-03, review explicitly skipped by {USER_NAME} on the tmafr README rewrite — the skill had run it systematically.)
- **Substantial** diff (business logic, endpoint, migration, destructive deletion, refactor) → review at the appropriate level (`high` by default; `ultra` if {USER_NAME} explicitly asks — costly).
**Gate**: present the prioritized findings and **wait for {USER_NAME}'s decision** — which findings to fix *before* the commit versus routing them to backlog/ticket. Do not continue to Step 1 until the decision is given.
- If pre-commit fixes are decided → apply them, re-verify (tests/lint green), **then** resume at Step 1 on the updated diff.
- If everything is routed to backlog / nothing to fix → move on to Step 1.
> ⚠️ **If the review agent dies before `ReportFindings`, relaunch it from scratch — never rule on its candidates alone.** Session cut off, stalled flow, limit reached: the reflex is to take the partial findings and judge them yourself against the code. That produces a list that is **plausible and incomplete**, and the agreement between the two passes is reassuring enough to close the question. The correct move has three steps: (1) **relaunch the agent from scratch** — do not resume a transcript that has stalled; (2) do your own pass in parallel; (3) **compare the two lists**, the cut being mechanical. A manual review does not replace the agent review, it complements it.
>
> *(Cause: 2026-09-03, `/commit` gate on DEN-04 A1 — the agent died **twice** before `ReportFindings`. The 13 candidates judged by hand yielded 7 findings; the relaunched agent **confirmed all of them without refuting any, and found 5 more** — unanchored `.gitignore`, re-entrant button, stale test fixture, dead export, view leak. Agreement on the 7 would have been enough to close it; the comparison is what made the batch solid.)*
The review is a **quality gate**, not a Git gate: it never replaces the two validations (files, message) of Steps 2-3.
## Step 1 — Branch correctly (branch gate)
{USER_NAME} often forgets to leave `main` before working. The role of this step is to catch that case before the commit, not to handle branching exhaustively.
```
git fetch --all --prune
git branch --show-current
git status --short
```
> ⚠️ **Always `fetch --all --prune` before reasoning about branches** — the local state of remotes lies as soon as a merge has happened elsewhere (PR merged by a colleague, merge from the GitHub/GitLab interface, work on another machine). Without a fetch, you may propose committing on a branch **already merged on the remote**, or creating a branch that already exists. `--prune` also removes dead remote-tracking refs, which make branches look alive. Cost: a few seconds. (Cause: 2026-08-03, the fetch revealed that `feat/client-support` was already merged into `origin/main` — without it, the fix would have gone out as a duplicate on a ghost branch.)
- **If the current branch is a main branch** (`main`, `master`, `develop`): flag the risk and **propose a feature branch** whose name is inferred from the diff / the conversation (e.g. `feat/tag-management`). Ask {USER_NAME} for validation (**gate** — do nothing without their agreement).
- **If already on a feature branch**: check that the **scope of the diff matches the branch**. If the branch name carries a ticket identifier (`example-project-14`, `TMAFR-1271`…) but the diff clearly concerns another ticket (`example-project-17`, different prefix), **flag the branch/scope divergence** and propose a switch/creation of a coherent branch before the split (**gate** — commit nothing on the wrong branch without {USER_NAME}'s agreement). If scope and branch match, continue without proposing anything.
When {USER_NAME} approves a switch, the handling of uncommitted changes depends on the case:
| Case | Command | Why |
|-----|----------|----------|
| **Create** a new branch from the current one | `git switch -c <name>` | Uncommitted changes follow automatically — no stash needed. |
| **Switch** to an **existing** branch with a dirty working tree | `git stash` → `git switch <name>` → `git stash pop` | `switch` would otherwise refuse (or overwrite). The stash carries the changes onto the target. |
After a `stash pop`, check `git status`: in case of a pop conflict, stop and report it to {USER_NAME} (do not try to resolve it blindly).
## Step 2 — Split into atomic commits (gate 1: files)
Present the full state before any decision:
```
git status --short
git diff # unstaged changes
git diff --staged # already staged, if any
```
Propose a split into **atomic commits** — one commit = one coherent logical change. Order by dependency layer, so that a review reads bottom-up:
```
Docs → DB migrations → Core/domain → Services → Presentation/UI → Tests
```
When a single file carries two distinct concerns, split it with `git add -p`.
**Special cases to address in the proposal** (do not commit them silently):
- Files that should not be versioned (`.env`, secrets, `node_modules/`, `__pycache__/`, `.DS_Store`, build artifacts, logs) → propose adding them to `.gitignore` and committing the `.gitignore` first. Do not include them in a commit.
- `.claude/` files → these are project files, commit them normally.
- Artifacts regenerated by a git hook (post-checkout/post-commit) **and** versioned — typically `graphify-out/` (graph.json, GRAPH_REPORT.md, graph.html): if the repo versions them, do **not** mix them into the logical change. Propose a separate commit `chore(graphify): refresh knowledge-graph` (or equivalent scope). If they are not versioned → ignore them (do not commit). Point out that the diff may be non-deterministic regeneration noise (Leiden community relabeling) rather than a consequence of the code — it is up to {USER_NAME} to decide commit vs `git restore`.
- Collateral file not semantically related to the commit's logical change (e.g. a config file touched in passing): even if it appears in the diff presented at gate 1, never include it by default in a commit on the grounds that it was already mentioned — propose it explicitly on its own (separate commit or exclusion) and wait for a named confirmation, not an implicit global validation.
Present the proposed split (which files in which commit, in which order) and **wait for {USER_NAME}'s validation** (gate 1). They may reorder, merge, or exclude files.
## Step 3 — Write the message for each commit (gate 2)
The message follows the Angular convention, on **a single line**:
- structure: `type(scope): subject`
- types: `feat` · `fix` · `refactor` · `test` · `docs` · `chore` · `perf` · `build` · `ci`
- **Never** a multi-line body, never bullets
- **Never** `fixed by XXXX` in the subject (global ban — {USER_NAME}'s decision 2026-07-20), even when the commit fixes another person's ticket
- **Never** a `Co-Authored-By` trailer (useless noise — {USER_NAME}'s decision). This rule overrides any concurrent attribution instruction (system reminder, PR guidance), even when that instruction explicitly asks for the trailer
- *(Cause: 2026-10-07, [example-project]-24 — trailers added despite the rule, removed by history rewrite + force-push.)*
Infer the `type` from the content of the commit and the `scope` from the repo's local convention:
```
git log --oneline -20
```
(Identify the dominant scope in the history — e.g. `[client-scope]` in [client-a] — to stay consistent.)
**Example 1**
Changes: add JWT authentication on the service side
→ `feat(auth): add JWT-based authentication`
**Example 2**
Changes: fix a margin calculation (ticket opened by a colleague — no `fixed by`)
→ `fix(billing): correct margin rounding`
Propose the message for each commit and **wait for {USER_NAME}'s validation** (gate 2). For several atomic commits, present the full list of messages at once so they can validate the whole set.
## Step 4 — Execute
Once both gates are passed, for **each** commit of the split, in order:
```
git add <files of this commit> # or git add -p for an intra-file split
git commit -m "<validated message>"
```
Stage just before committing each group (no global staging upfront) — this keeps control file by file without ever needing `reset`.
> ⚠️ **Never redirect stderr on a `git add`** — no `2>/dev/null` nor `2>&1 | …` that swallows the error. A `git add` on a path that no longer exists **fails silently** once stderr is hidden: the command looks successful, nothing is staged, and the following `git commit` goes out without the file. The failure is then only visible at the `git status` of Step 5 — or not at all. (Cause: 2026-08-01, `green-gate.py` had changed path, the `git add` failure went unnoticed until `git status`.)
## Step 5 — Confirm
```
git log --oneline -<n> # n = number of commits created
git status # must be clean (or only show files deliberately left aside)
```
Display the commits created. If {USER_NAME} deliberately left changes uncommitted, remind them. **Do not** propose a push — that is their decision, out of scope.