labali-git-auto-commit-rewrite
NEVER
- Never fabricate diff content or invent changes not present in
git diff output — a fabricated commit message is worse than no message; it destroys trust in git history.
- Never commit without running
npm run skills:validate and npm run check:chinese when any file under skills/ has changed — these checks exist because broken skills and Chinese-in-docs violations have slipped through unguarded commits before.
- Never amend a previous commit — always create a new commit. Amending rewrites history and can silently overwrite commits that others (or hooks) have already acted on.
- Never use
--no-verify to bypass pre-commit hooks — the hooks are the project's safety net; bypassing them defeats their purpose and masks real issues.
- Never write a body that only lists filenames —
- update core.ts tells nothing; name the intent behind the change, not the file that changed.
Commit Type Selection
| Type |
When to use |
feat |
New capability or behavior visible to users/agents |
fix |
Corrects wrong behavior (not just wrong output) |
docs |
Documentation, examples, references only — no behavior change |
chore |
Housekeeping: structure, config, scripts, CI — no behavior change |
refactor |
Code restructure with no behavior change |
improve |
Meaningful enhancement to existing behavior (not a new feature, not a bug fix) |
perf |
Performance improvement |
test |
Test additions or changes only |
Scope selection: use a scope when the change is confined to one clear subsystem — fix(browser): ..., feat(skill): .... Omit scope for cross-cutting changes that span multiple subsystems.
When types conflict: if a commit spans both a behavior change and a structural change, use the behavior-change type (feat/fix/improve) — structural changes are secondary to their purpose. If the two concerns are truly independent, split into two commits.
Execution Contract
- Inspect working tree changes (
git status --short, git diff --name-status) before writing message.
- If any changed files are under
skills/, run npm run skills:validate and npm run check:chinese before staging.
- If
skills:validate fails: read the error, fix the SKILL.md or referenced file it names, re-run until green.
- If
check:chinese fails: find and remove Chinese characters from the flagged doc/config files, re-run until green.
- Before writing the subject, determine: is this a behavior change (
feat/fix/improve) or a structural change (docs/chore/refactor)? This choice drives the type.
Generate a commit message that is both clear and elegant:
- Subject format:
<type>(<scope>): <subject> or <type>: <subject>
- Subject is concise, action-oriented, and specific to the dominant change set.
- Body contains 2-6 bullet points, each tied to real grouped changes from diff.
- Avoid vague wording like only
update/align when multiple meaningful changes exist.
- MANDATORY — load
examples/good.md before writing the message to calibrate quality. Load examples/anti-pattern.md if the draft message feels vague or generic.
- Stage all changes with
git add -A.
- Commit once with the generated subject and body. The commit command MUST be prefixed with
LABALI_SKILL_COMMIT=1 so the repository's pre-commit hook recognizes it as skill-authorized:LABALI_SKILL_COMMIT=1 git commit -m "..."
- MUST run
<skill_base_dir>/scripts/clean_commit.sh immediately after commit (non-optional).
The skill base directory is provided in the Base directory for this skill: line at the top of the invocation header.
clean_commit.sh may rewrite the subject — read the final hash and subject from its output, not from the original commit.
Message Quality Rules
- Body bullets must reflect actual file-level intent, not generic placeholders.
- Prefer aggregate summaries when many files changed, then include concrete sub-actions in body.
Failure Handling
- If repository is not a Git repo, fail fast with explicit message.
- If there are no changes to commit, return
No changes to commit..
Resources
| When |
Must load |
Do NOT load |
| Always — before writing the message |
examples/good.md |
examples/anti-pattern.md |
| Draft feels vague, generic, or uncertain |
examples/anti-pattern.md |
— |
1---2name: labali-git-auto-commit-rewrite3description: Generate a clear conventional commit message from current git changes, stage all files, commit locally, and run clean_commit.sh to normalize the result. Use when users want to commit, stage and commit, auto-commit, or generate a commit message for current changes. Trigger phrases: "commit changes", "git commit", "commit all", "commit message", "conventional commit".4license: MIT5---67# labali-git-auto-commit-rewrite89## NEVER1011- **Never fabricate diff content** or invent changes not present in `git diff` output — a fabricated commit message is worse than no message; it destroys trust in git history.12- **Never commit without running `npm run skills:validate` and `npm run check:chinese`** when any file under `skills/` has changed — these checks exist because broken skills and Chinese-in-docs violations have slipped through unguarded commits before.13- **Never amend a previous commit** — always create a new commit. Amending rewrites history and can silently overwrite commits that others (or hooks) have already acted on.14- **Never use `--no-verify`** to bypass pre-commit hooks — the hooks are the project's safety net; bypassing them defeats their purpose and masks real issues.15- **Never write a body that only lists filenames** — `- update core.ts` tells nothing; name the intent behind the change, not the file that changed.1617## Commit Type Selection1819| Type | When to use |20|------|-------------|21| `feat` | New capability or behavior visible to users/agents |22| `fix` | Corrects wrong behavior (not just wrong output) |23| `docs` | Documentation, examples, references only — no behavior change |24| `chore` | Housekeeping: structure, config, scripts, CI — no behavior change |25| `refactor` | Code restructure with no behavior change |26| `improve` | Meaningful enhancement to existing behavior (not a new feature, not a bug fix) |27| `perf` | Performance improvement |28| `test` | Test additions or changes only |2930**Scope selection:** use a scope when the change is confined to one clear subsystem — `fix(browser): ...`, `feat(skill): ...`. Omit scope for cross-cutting changes that span multiple subsystems.3132**When types conflict:** if a commit spans both a behavior change and a structural change, use the behavior-change type (`feat`/`fix`/`improve`) — structural changes are secondary to their purpose. If the two concerns are truly independent, split into two commits.3334## Execution Contract35361. Inspect working tree changes (`git status --short`, `git diff --name-status`) before writing message.372. If any changed files are under `skills/`, run `npm run skills:validate` and `npm run check:chinese` before staging.38 - If `skills:validate` fails: read the error, fix the SKILL.md or referenced file it names, re-run until green.39 - If `check:chinese` fails: find and remove Chinese characters from the flagged doc/config files, re-run until green.403. Before writing the subject, determine: is this a behavior change (`feat`/`fix`/`improve`) or a structural change (`docs`/`chore`/`refactor`)? This choice drives the type.41 Generate a commit message that is both clear and elegant:42 - Subject format: `<type>(<scope>): <subject>` or `<type>: <subject>`43 - Subject is concise, action-oriented, and specific to the dominant change set.44 - Body contains 2-6 bullet points, each tied to real grouped changes from diff.45 - Avoid vague wording like only `update`/`align` when multiple meaningful changes exist.46 - **MANDATORY — load `examples/good.md` before writing the message** to calibrate quality. Load `examples/anti-pattern.md` if the draft message feels vague or generic.474. Stage all changes with `git add -A`.485. Commit once with the generated subject and body. The commit command MUST be prefixed with `LABALI_SKILL_COMMIT=1` so the repository's pre-commit hook recognizes it as skill-authorized:49 ```bash50 LABALI_SKILL_COMMIT=1 git commit -m "..."51 ```526. MUST run `<skill_base_dir>/scripts/clean_commit.sh` immediately after commit (non-optional).53 The skill base directory is provided in the `Base directory for this skill:` line at the top of the invocation header.54 `clean_commit.sh` may rewrite the subject — read the final hash and subject from its output, not from the original commit.5556## Message Quality Rules5758- Body bullets must reflect actual file-level intent, not generic placeholders.59- Prefer aggregate summaries when many files changed, then include concrete sub-actions in body.6061## Failure Handling6263- If repository is not a Git repo, fail fast with explicit message.64- If there are no changes to commit, return `No changes to commit.`.6566## Resources6768| When | Must load | Do NOT load |69|------|-----------|-------------|70| Always — before writing the message | `examples/good.md` | `examples/anti-pattern.md` |71| Draft feels vague, generic, or uncertain | `examples/anti-pattern.md` | — |