Back to loops
Testingevent

Pre-Commit Guard

Hook that runs tests before git commit commands to block commits when the suite is red.

0 views0 usesby solo lemon.

// parameters

Triggerevent
Max iterations10
Check commandnpm test
Exit conditionTests pass before each git commit

// run_this_loop

Copy the kickoff into your agent first. The blueprint below explains how the loop evaluates progress and when it should stop.

Open in CursorOpen in Claude

Use loop copies the kickoff prompt. Share copies the loop link. Open in Cursor / Claude only pre-fill that prompt — they do not install hook files. Download loop saves the loop as pre-commit-guard.md.

Install and run the "Pre-Commit Guard" loop.

Goal: block git commits when tests are failing.
Between iterations run: npm test
Exit when: tests exit 0 before each commit.

Step 1: Before any git commit, run tests. Fix failures before committing.

// blueprint

The loop contract: target outcome, execution sequence, checks, stopping condition, and safety constraints.

Goal

block git commits when tests are failing.

// loop_sequence

// loop_sequence_diagram.json
closed loop

Trigger

event event

Actions block

3 steps
1Detect commit intent
2Run tests
3Block or allow

Feedback gate

Evaluate: npm test

Run the check, read the output, then decide whether the loop is complete.

Check failed

Repeat actions with the latest feedback.

Success

Tests pass before each git commit

Safety capMax 10 iterations

// steps

  1. 1
    Detect commit intent

    When a git commit command is about to run, pause and run the test suite first.

  2. 2
    Run tests

    Run the full test suite before allowing the commit to proceed.

    npm test
  3. 3
    Block or allow

    If tests fail, fix failures and re-run. Only allow the commit when tests pass.