Pre-Commit Guard
Hook that runs tests before git commit commands to block commits when the suite is red.
起動プロンプト
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.基本情報
カテゴリ
テスト
目標
block git commits when tests are failing.
検査コマンド
npm test
退出条件
tests exit 0 before each commit.
対応エージェント
Cursor
手順
- 1
Detect commit intent
When a git commit command is about to run, pause and run the test suite first.
- 2
Run tests
Run the full test suite before allowing the commit to proceed.
npm test - 3
Block or allow
If tests fail, fix failures and re-run. Only allow the commit when tests pass.
他のテストのループ
Build Until Green
Run the production build, fix compile and bundling errors, and loop until the build succeeds.
Coverage Until Threshold
Add focused tests until coverage meets your threshold (e.g. 80%), without changing production behavior unnecessarily.
Post-Edit Test Guard
Hook-based loop that runs related tests after file edits to catch regressions early.
Format Until Clean
Run the formatter, fix any remaining style issues, and loop until the codebase formats cleanly with no diffs.
Flaky Test Triage
Run failing tests repeatedly, classify each failure as flaky or real, and fix only confirmed regressions.
Autoloop TDD
Test-first loop: write a failing test, implement the minimum code to pass, refactor, and repeat.