Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .claude/skills/new-loop/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ that returns clear pass/fail (e.g. `pytest test/users`, `npm test`,
| Pattern | Use when | Mechanism |
|---|---|---|
| **`/goal`** (default) | Iterate-to-completion on a well-scoped task with a provable success condition. | `/goal` with a separate validator model (defaults to Haiku). Requires Claude Code v2.1.139+. |
| **ralph** (`/ralph-loop` or bash) | Long autonomous build where each iteration should reset context to anchor files. | Official `ralph-wiggum` plugin, or `templates/ralph/run.sh`. |
| **ralph** (`/ralph-loop` or bash) | Long autonomous build where each iteration should reset context to anchor files. | Official `ralph-wiggum` plugin (`--max-iterations` defaults to **unlimited** — always set it), or `templates/ralph/run.sh`. |
| **`/loop`** | Recurring maintenance on an interval (babysit PRs, poll a deploy). | Bundled `/loop` skill (v2.1.72+); cron-backed, session-scoped; recurring tasks expire after 7 days. |

Default to `/goal` for "do this task once, correctly." Use ralph for
Expand Down Expand Up @@ -55,8 +55,11 @@ Create `loops/<slug>/` (slug derived from the task) containing:
2. **No-progress detection** — instruct the loop to bail if N consecutive
iterations produce no git diff / no test-state change (default N=3), and
document blockers instead of looping forever.
3. **Budget ceiling** — set `MAX_BUDGET_USD` (ralph/SDK) or remind the user of
the session budget. State the expected cost order-of-magnitude.
3. **Budget ceiling** — set `MAX_BUDGET_USD` (ralph `run.sh` / Agent SDK
`max_budget_usd`), or pass `--max-budget-usd` on the Claude Code invocation
(since v2.1.217 it also halts background subagents at the cap). A reminder
about the session budget is an alert, not a ceiling. State the expected
cost order-of-magnitude.

Pull the exact defaults from `guardrails/budget.env`. Reference
`guardrails/checklist.md` and confirm every box is satisfied before finishing.
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ bakes in guardrails.
## The one rule

**Never run an uncapped loop.** Every loop gets all three hard stops — a max
iteration count, no-progress detection, and a token/dollar budget ceiling. The
billing layer will *not* save you (soft alerts only). See
iteration count, no-progress detection, and a token/dollar budget ceiling.
Anthropic now ships some real spend enforcement (Enterprise Spend Limits API,
gateway spend limits, Managed Agents session budgets), but the gateway layer
fails open by default and none of it reaches a plain Claude Code loop
automatically — the ceiling still has to live in your harness. See
[`guardrails/`](guardrails/).

## Staying current
Expand Down
6 changes: 6 additions & 0 deletions templates/ralph/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
set -euo pipefail

# ---- CONFIG (edit me) ------------------------------------------------------
# NOTE: models that take more turns per unit of work (e.g. Fable 5.1-class
# long-horizon models) trip iteration/stall caps tuned on older models earlier.
# An early stop on such a model is a re-tuning signal, not proof of failure
# (see knowledge/00-primer.md §4, Fable 5.1 breaking changes).
PROMPT_FILE="PROMPT.md"
MAX_ITERATIONS=20 # hard stop #1: iteration cap
MAX_BUDGET_USD=10 # hard stop #3: dollar ceiling (enforced below)
STALL_LIMIT=3 # hard stop #2: bail after N no-progress passes
COMPLETION_MARKER="<promise>COMPLETE</promise>"
SUCCESS_CHECK="${SUCCESS_CHECK:-false}" # e.g. "pytest -q" / "npm test"
# Agent command. --dangerously-skip-permissions only for sandboxed/headless use.
# Narrower alternative (v2.1.259+): --permission-prompts none denies anything
# that would prompt instead of skipping permissions wholesale.
AGENT_CMD=(claude -p --dangerously-skip-permissions)
# ---------------------------------------------------------------------------

Expand Down
Loading