Runbook: Pre-commit Failing
Trigger
make pre-commit-checkfails.git commitfails because a hook failed.
Fast triage
- Run hooks:
make pre-commit-check. - Check which hook failed (ruff, format, mypy, hygiene hooks).
- Fix issues, then run again; hooks may edit files for you.
Most common causes
ruff-formatchanged files but they were not staged before commit.mypyreports type errors after schema/service edits.- Hygiene hooks found trailing spaces/EOF/line endings.
- Merge conflict markers accidentally committed.
Recovery steps
- Apply auto-fixes:
make lint-fix,make format-fix. - Stage updated files:
git add -A. - Re-run hooks:
make pre-commit-check. - If
mypystill fails, runmake type-checkand fix typing issues.
Special case: unstaged changes conflict
If commit output shows stash/rollback conflict:
- Stage all intended files first:
git add -A. - Run
make pre-commit-check. - Commit again.
Exit criteria
make pre-commit-checkpasses.- No auto-modified files remain unstaged.
- Commit succeeds without hook rollback.
Follow-up
- To change which hooks run or how strict they are, edit
.pre-commit-config.yaml. - If the same failure keeps happening, add a line to this runbook.
Page history
| Date | Change | Author |
|---|---|---|
| Added Page history section (repository baseline). | Ivan Boyarkin |