Run iterative agent loops until success criteria are met. Controlled autonomous iteration.
---
name: Loop
slug: loop
version: 1.0.2
description: Run iterative agent loops until success criteria are met. Controlled autonomous iteration.
changelog: Fixed internal contradiction about Git commits in memory.md
metadata: {"clawdbot":{"emoji":"๐","requires":{"bins":[]},"os":["linux","darwin","win32"]}}
---
## Data Storage
```
~/loop/
โโโ active.json # Currently running loops
โโโ history/ # Completed loop logs
โ โโโ {loop-id}.json
โโโ learnings.md # Cross-loop patterns
```
Create on first use: `mkdir -p ~/loop/history`
## Scope
This skill:
- โ
Runs iterative attempts toward defined success criteria
- โ
Logs each iteration with learnings
- โ
Exits on success, max iterations, or unrecoverable error
- โ NEVER makes Git commits automatically
- โ NEVER deploys to production
- โ NEVER modifies system configuration
- โ NEVER runs indefinitely (max 10 iterations hard limit)
## Quick Reference
| Topic | File |
|-------|------|
| Loop examples | `examples.md` |
| Memory between iterations | `memory.md` |
## Core Rules
### 1. Pattern
```
Task + Criteria โ Execute โ Verify โ [Pass? Exit : Retry]
```
### 2. Required Setup
| Element | Required | Example |
|---------|----------|---------|
| Task | Yes | "Fix failing tests" |
| Success criteria | Yes | "All tests pass" |
| Max iterations | Default: 5 | Max: 10 |
| Verify command | Recommended | `npm test` |
### 3. When to Propose
- Task has clear success criteria but uncertain path
- Previous attempt failed but error is fixable
- User says "keep trying until..."
**NOT for:** One-shot tasks, undefined goals, exploratory work
### 4. Each Iteration
1. **Fresh context** โ Only carry: task, criteria, count, learnings
2. **Execute** โ Attempt the task
3. **Verify** โ Check success criteria
4. **Record** โ Append to history: what worked, what failed
5. **Decide** โ Pass? Exit. Fail? Retry if under limit.
### 5. Stopping Conditions
- โ
Success criteria met
- โ Max iterations reached
- โ ๏ธ Unrecoverable error (missing dependency, permission denied)
### 6. On Failure
If max reached without success:
- Summarize all attempts
- Identify common failure pattern
- Recommend manual intervention or different approach
### 7. Safety
- Hard limit: 10 iterations maximum
- No destructive actions without explicit per-action approval
- Log everything to ~/loop/history/
don't have the plugin yet? install it then click "run inline in claude" again.