commit
Smart git commit. Runs tests, stages all changes, generates a conventional commit message, and commits. Use when committing work, saving progress, or when the user says "commit this", "save my work", or "make a commit".
Create a smart git commit for the current working tree:
- Check for unstaged changes with
git statusandgit diff --stat - Run the project test suite to verify nothing is broken:
- Look for
package.json(runnpm testoryarn test),Makefile(runmake test),pytest.ini/pyproject.toml(runpytest), orgo.mod(rungo test ./...) - If tests fail, stop and report the failures. Do NOT commit broken code.
- Look for
- Stage all changes:
git add -A - Analyze the diff with
git diff --cachedto understand what changed - Generate a conventional commit message following this format:
type(scope): short summaryon the first line (max 72 chars)- Blank line, then a short body explaining WHY (not what)
- Types:
feat,fix,refactor,test,docs,chore,perf,ci - Scope: the module or area affected (e.g.,
auth,api,db)
- Commit with
git commit -m "<message>" - Print the commit hash and summary
Requirements
- Must be run inside a git repository
- Working tree must have at least one change to commit
- Tests must pass before committing
Error Handling
- If no changes are staged or unstaged: report "Nothing to commit" and stop
- If tests fail: report the failures and stop without committing
- If
git commitfails: show the error and suggest fixes - If no test runner is found: skip tests, note the omission, and proceed