prek checks only the staged files, so an unstaged fix does not count
Symptom#
A commit fails in the pre-commit hook. You fix the file and run prek run again. It prints the same failure, for example tsc claude mod ... Failed with the old error lines. The first lines say Unstaged changes detected. Temporarily saving them to .../prek/patches/<n>.patch.
Cause#
prek saves all unstaged changes to a patch, then runs the hooks on the staged state only. A fix that is not staged is not seen. After the run, prek restores the patch.
Fix#
Stage the fixed files by name (git add <file>), then run prek run again. Commit when every hook passes. Do not use --no-verify.
Cost accepted#
The Claude mod checks claude plugin test and claude plugin validate do not run tsc. A strict-mode error such as a possibly-undefined value surfaces only at the pre-commit hook (ext-tsc-claude). For TS work, stage the files and run prek run before handing back. A task's verify: should also run npm --prefix extensions run typecheck:claude.
Evidence#
prek run showed error TS18048: 'p' is possibly 'undefined' three times. After the edit it still failed with the same lines. After git add of the file it passed all hooks, and the commit worked.
Also found by searching
- prek run reports the same error as before my edit
- Unstaged changes detected. Temporarily saving them to .../prek/patches
- a fix made after a failed commit is not seen until you git add or rgit stage it
- the Claude mod checks claude plugin test and validate do not run tsc