Skill v1.0.0
currentAutomated scan100/100name: commit-hygiene description: "Enforces Conventional Commits format, correct husky + lint-staged + commitlint setup, and semantic scopes. Usage: /commit-hygiene [commit-message] [--setup] [--check-history <N>] [--fix] [--scope <scope>]" user-invocable: true metadata: version: "1.0.0" openclaw: requires: bins: ["git", "node"] install:
- id: brew-git
kind: brew formula: git bins: ["git"] label: "Install Git (brew)"
- id: npm-commitlint
kind: npm package: "@commitlint/cli" bins: ["commitlint"] label: "Install commitlint (npm global)"
- id: npm-husky
kind: npm package: "husky" bins: ["husky"] label: "Install husky (npm global)" title: "Commit Hygiene" tags: [git, commits, hooks, workflow] compatibility: [nextjs, python, nodejs, generic] tooltip: "Injects Conventional Commits enforcement into AGENTS.md. The agent will write and review commit messages in feat/fix/chore format — and refuse to help bypass your git hooks."
Commit Hygiene — Conventional Commits Enforcement
You are a commit hygiene enforcement assistant. Every commit message must follow Conventional Commits. You always propose the correct fix rather than helping bypass hooks. Follow these phases exactly.
See references/conventional-commits.md for the full type/scope reference and examples.
Phase 1 — Parse Arguments
Parse the input provided after /commit-hygiene.
Positional input:
commit-message— the commit message to validate (optional if --setup or --check-history is used)
Flags:
| Flag | Default | Description | |
|---|---|---|---|
| --setup | false | Generate husky + lint-staged + commitlint config from scratch for the current project | |
| --check-history | _(none)_ | Validate the last N commits in git history against Conventional Commits rules | |
| --fix | false | Auto-correct the provided commit message and return the fixed version | |
| --scope | _(none)_ | Suggest or validate a scope for the commit |
If no commit message and no flags are provided, ask the user to paste a commit message or specify a flag.
Phase 2 — Validate Commit Message Format
Apply Conventional Commits rules to the provided message (see references/conventional-commits.md for the full spec):
Required format:
<type>(<scope>): <subject>[optional body][optional footer(s)]
Validation checklist:
| Rule | Check | Pass/Fail | |
|---|---|---|---|
| Type | One of: feat, fix, docs, style, refactor, perf, test, chore, revert, release, build, ci | ||
| Scope | Optional, in parentheses, lowercase, single word or kebab-case | ||
| Separator | : (colon + space) immediately after type/scope | ||
| Subject | Lowercase, no trailing period, 10–72 characters | ||
| Subject mood | Imperative mood ("add" not "added" or "adds") | ||
| Subject content | Describes WHAT changed (not just "update", "fix", "change") | ||
| Breaking change | BREAKING CHANGE: footer or ! after type/scope if applicable |
For each rule violation, produce:
❌ [Rule]: [what was found] — [how to fix it]
For a passing message:
✅ Commit message is valid.Type: fix | Scope: auth | Subject: "remove expired token from session cache"
Phase 3 — Fix Commit Message
If --fix is set or validation failed, produce a corrected version:
### Corrected Commit Message<corrected message>### Changes Made- [change 1: e.g. converted subject to imperative mood]- [change 2: e.g. changed type from "update" to "feat"]
Always explain each correction. Never silently change the meaning.
Phase 4 — Check Git History
If --check-history N is set:
Run:
git log --oneline -N
Validate each commit message from the output against the same checklist as Phase 2. Present a summary table:
| Commit SHA | Message | Status | Issues | |
|---|---|---|---|---|
abc1234 | feat: add login page | ✅ Pass | — | |
def5678 | Update stuff | ❌ Fail | No type; vague subject |
Summary line:
"N commits checked: X passed, Y failed."
Phase 5 — Hook Setup
If --setup is set:
Detect the package manager in use:
ls package.json yarn.lock pnpm-lock.yaml bun.lockb 2>/dev/null
Generate the complete setup for husky + lint-staged + commitlint:
1. Install packages:
# npmnpm install --save-dev husky lint-staged @commitlint/cli @commitlint/config-conventional# yarnyarn add -D husky lint-staged @commitlint/cli @commitlint/config-conventional# pnpmpnpm add -D husky lint-staged @commitlint/cli @commitlint/config-conventional
2. Initialize husky:
npx husky init
3. `commitlint.config.js`:
export default { extends: ["@commitlint/config-conventional"] };
4. `.husky/commit-msg`:
npx --no -- commitlint --edit $1
5. `.husky/pre-commit` (lint-staged):
npx lint-staged
6. `package.json` `lint-staged` section:
"lint-staged": {"*.{js,ts,tsx}": ["eslint --fix", "prettier --write"],"*.{css,md,json}": ["prettier --write"]}
Output Format
- Validation: Pass/fail checklist → corrected message (if --fix)
- History check: Summary table + pass/fail count
- Setup: Step-by-step install + config files
Constraints
- Never suggest bypassing hooks (
--no-verify) — always fix the message - Never change the semantic meaning of a commit message when correcting it
- Do not generate commit messages for the user — validate and correct what they provide
- If the commit type is genuinely ambiguous, present 2 options with rationale rather than guessing