Verification-gated self-running loop skill

A drop-in Claude Code skill that keeps looping until an external verifier passes — not the model's own self-report — making it a strong anti-reward-hacking pattern for autonomous coding.

prompt
→ Claude
Drop-in Claude Code skill: self-running agent loop with a "real, un-foolable verification gate" — loop continues until an external verifier (not the model's self-report) passes.
claude-code

Implementation note

When to use: any autonomous loop where you have been burned by the agent declaring victory prematurely — the model reporting done while the actual checks fail is the classic reward-hacking failure of self-directed loops. How it works: a drop-in Claude Code skill implementing a self-running loop whose continuation logic is gated by a real, un-foolable verification step: the loop continues until an external verifier passes, not until the model's self-report says things look good. The verifier is code the model cannot argue with — tests, builds, whatever objective check you wire in — which structurally removes the incentive to describe success instead of achieving it. Safety: the external-verifier gate is the anti-reward-hacking rail and the entire design point. Its guarantee is exactly as strong as the verifier you supply, so invest in that check; a weak verifier resurrects the original problem one level down. Add an iteration cap alongside it.

Source: selmakcby/loop-engineering

More testing loops

Stabilize flaky tests for good

Measure the flakiness, fix one root cause at a time, and stop after a defined streak of stable full-suite runs.

prompt
→ Claude
Run [test suite] [N] times under the same conditions and list tests whose result changes. Fix the most frequent flake at its root cause—shared state, timing, ordering, or an external dependency—never with a blind sleep or retry. Run that test [N] times, then rerun the full suite. Repeat until [N] consecutive full-suite runs pass, progress stalls, or approval is required. Return each flake, root cause, fix, evidence, and justified quarantine.
testingmedium riskclaude-codecodex

Build a todo CLI app with tests

Loop/ralphnew

Ralph autonomously builds a todo CLI application with comprehensive test coverage over multiple iterations until complete.

prompt
→ Claude
/ralph-loop "Build a todo CLI app with tests" --max-iterations 30
testinglow riskclaude-code

Kill flaky tests

Loop/loop

Run your test suite repeatedly, collect every intermittent failure, and fix or quarantine flaky tests until you get five consecutive green runs.

prompt
→ Claude
/loop run my test suite 20 times, collect every intermittent failure, fix or quarantine the flaky ones, and don't stop until you get 5 consecutive fully-green runs
testinghigh riskclaude-codecursor