Hook-based loop that runs related tests after file edits to catch regressions early.
Identify which source files were edited in the last turn.
Run the smallest relevant test subset for edited files. Fix failures before continuing.
Related tests pass after each edit batch
{
"version": 1,
"hooks": {
"afterFileEdit": [
{
"type": "prompt",
"prompt": "Post-Edit Test Guard: run related tests for the files just edited. If tests fail, fix them before continuing other work."
}
]
}
}
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "prompt",
"prompt": "Post-Edit Test Guard: run related tests for the files just edited. If tests fail, fix them before continuing other work."
}
]
}
]
}
}
# Post-Edit Test Guard Uses the `afterFileEdit` hook (Cursor) and `PostToolUse` hook (Claude Code) to run related tests after edits. ## Pair with Copy the kickoff prompt from loops! to align agent behavior with the hook.
Install and run the "Post-Edit Test Guard" loop. Goal: after each batch of file edits, related tests must pass before continuing. Between iterations run: npm test -- --findRelatedTests <edited files> Exit when: related tests exit 0. Step 1: After edits, run related tests. If they fail, fix before making more changes.