loops!
BrowseSign in
Back to loops
Automation
manual
CursorClaude CodeCodex

Guardrails Learning Loop

When a check fails twice the same way, append a guardrail sign to .ralph/guardrails.md so the next iteration avoids repeating it.

5 copies · 0 installs · 13 views

by loops!

Use loop copies the kickoff. Share copies the loop link. Open in Cursor / Claude Code only pre-fill that prompt — they do not install hook files. Click Install files, extract the zip into your repo, then restart your agent. Full install guide

Sign in to save
Guardrails
Hardened
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
How to run this loop
Includes install files
Run “Guardrails Learning Loop” in your agent
Deeplinks and “Open in Cursor” only paste the kickoff prompt. They do not install hook files — your agent cannot tell whether files are on disk until you add them yourself.

Two separate pieces

  • Kickoff prompt — tells the agent the goal, check command, exit condition, and how to self-pace between passes.
  • Install files — optional hooks under .cursor/ or .claude/ that fire on events (save, commit, etc.). You must download and extract these into your repo.
  1. 1

    Download and extract install files

    Click Install files on this loop, unzip, and merge into your project root so paths like .ralph/guardrails.md exist on disk.

    Restart Cursor or reload the Claude Code session so hooks are picked up. Until then, nothing is “installed” — the browser cannot write into your repo.

  2. 2

    Copy or open the kickoff prompt

    Use Use loop to copy the kickoff, or Open in Cursor / Open in Claude Code to pre-fill the prompt in that app. Those links only carry text, not hook files.

  3. 3

    Paste and let the agent self-pace

    Paste the kickoff into agent chat. The agent should run your check command between iterations and stop when the exit condition passes.

Full guide with Cursor /loop notes: How to install loops

manual trigger
Automation
Manual start
Read guardrails
Run checks
Record failure sign
Fix with guardrails
Checks pass and no repeated failure pattern remains
Rendering diagram…
Steps
What the agent does on each pass.

1. Read guardrails

Read .ralph/guardrails.md before any work. Treat each sign as a hard constraint.

2. Run checks

Run the project's backpressure commands.

npm test && npm run lint

3. Record failure sign

If the same error occurred before, append a concise sign to guardrails.md: what failed and how to avoid it.

4. Fix with guardrails

Apply a fix that respects all guardrail signs. Do not repeat prior failed approaches.

Kickoff prompt
Copy this into your coding agent to start the loop.
Start the "Guardrails Learning Loop" loop.

Goal: tests and lint pass without repeating prior failure patterns
Max iterations: 12
Between iterations run: npm test && npm run lint
Exit when: all checks pass

Step 1: Read .ralph/guardrails.md, run checks, and if a failure repeats, add a sign before fixing.

Self-pace this loop. After each iteration, run the check command, read the output, and only continue if the exit condition is not met. Stop when the exit condition passes or max iterations is reached. Give a short status update each pass.

Related loops

Automation
manual
1 copies · 1 installs
Fresh-context loop: pick one incomplete story from prd.json, implement it, run backpressure checks, commit, and update progress before the next iteration.

Start the "Ralph Story Executor" loop. Goal: every story in .ralph/prd.json has passes: true Max iterations: 20 Between iterations run: npm test && npm run lint && npm run build Exit when: no stories remain with passes: false (respond "ALL STORIES ARE COMPLETE") Step 1: Read .ralph/prd.json and .ralph/progress.md. Pick one incomplete story, implement it, run backpressure checks, commit, update prd.json and progress.md, then stop this iteration. Self-pace this loop. Each iteration does exactly one story. State lives on disk, not in chat history.

CursorClaude CodeCodex
ralph
automation
prd
fresh-context
by loops!
View