AAWEA.ORG
AAWEA.ORG
AAWEA.ORG
Testing Event trigger πŸ‘‘ Official πŸ›‘ Hardened

Post-Edit Test Guard

Hook-based loop that runs related tests after file edits to catch regressions early.

πŸ‘ 1,327 views πŸ“₯ 1,328 installs πŸ‘€ by loops!
Download loop
Share Now
Manual start
↓
  1. 1
    Detect edited files

    Identify which source files were edited in the last turn.

  2. 2
    Run related tests

    Run the smallest relevant test subset for edited files. Fix failures before continuing.

    > npm test -- --findRelatedTests
↓
βœ“
Exit condition: tests_pass

Related tests pass after each edit batch

> npm test -- --findRelatedTests
πŸ“¦ Install Files
These files are included when you download the loop.
πŸ“„ .cursor/hooks.json
{
  "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."
      }
    ]
  }
}
πŸ“„ .claude/settings.json
{
  "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."
          }
        ]
      }
    ]
  }
}
πŸ“„ .cursor/loops/post-edit-test-guard/README.md
# 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.
πŸ“Š Flow Diagram
flowchart TD Start(["Event start"]) Start --> S0 S0("Detect edited files") S1("Run related tests") S0 --> S1 Exit{"Related tests pass after each edit batch"} S1 --> Exit Exit -- "No" --> S0 Exit -- "Yes" --> Done(["Success"]) style Exit fill:#fffbeb,stroke:#f59e0b,stroke-width:2px,color:#92400e style Done fill:#ecfdf5,stroke:#10b981,stroke-width:2px,color:#065f46
Kickoff prompt
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.
Anti-gaming rules
Rules the agent must follow so it cannot cheat the exit condition.
  • Do not modify the check command or exit criteria to force success
  • Do not skip, disable, or bypass checks to pass the exit condition
  • If stuck after several iterations, stop and report blockers instead of gaming metrics