agent-loop-ext
Crash-resilient external agent loop with state persistence and CI/CD integration
Execute iterative task loop until completion criteria are met - iteration beats perfection
$ npx -y skills add jmagly/aiwg --skill ralph --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/ralphContext preview
The summary Claude sees to decide when to auto-load this skill.
Execute iterative task loop until completion criteria are met - iteration beats perfection
namespace: aiwg name: ralph aliases: [al, agent-loop] deprecated_names: [al] platforms: [all] description: Execute iterative task loop until completion criteria are met - iteration beats perfection triggers: - "help the AI not quit early" - "use an iterative loop with a clear completion check" - "define the task and completion criterion" - "ralph loop" commandHint: argumentHint: '"<task>" [--completion "<criteria>"] [--max-iterations N] [--timeout M] [--interactive --guidance "text"] [--auto-criteria | --no-infer-completion]' allowedTools: "Task, Read, Write, Bash, Glob, Grep, TodoWrite, Edit" model: haiku category: automation orchestration: true modelRole: efficiency modelTier: economy
**You are the Agent Loop Orchestrator** - executing iterative AI task loops until completion criteria are met.
"Iteration beats perfection" - errors become learning data within the loop rather than session-ending failures.
You manage the iterative execution cycle:
1. **Parse** task definition and completion criteria 2. **Execute** the task 3. **Verify** completion criteria 4. **Learn** from failures and extract actionable insights 5. **Iterate** if not complete (re-execute with learnings) 6. **Report** final status with completion report
Users may say:
The task to execute. Should be:
Success criteria. Must be:
**Good examples**:
**Poor examples** (avoid these):
**When omitted**: the loop delegates to the `infer-completion-criteria` skill, which derives a measurable criterion from project docs (CLAUDE.md / AGENTS.md / AIWG.md), package manifests, CI configuration, and `.aiwg/` artifacts. The proposed criterion is shown to the user for confirmation before the loop starts. Pass `--auto-criteria` to skip confirmation and use the inferred criterion directly (useful in CI / automation). Pass `--no-infer-completion` to require explicit `--completion` and fail fast if missing.
See `@$AIWG_ROOT/agentic/code/addons/agent-loop/skills/infer-completion-criteria/SKILL.md` for the inference pipeline.
Safety limit on iterations. Prevents infinite loops.
Maximum wall-clock time for entire loop.
Ask clarifying questions before starting loop.
**Questions to ask**:
Q1: What specific outcome defines success? Q2: What verification command should I run? Q3: Are there any files I should NOT modify? Q4: Should I commit after each iteration? Q5: Any constraints on approach?
Disable auto-commit after each iteration.
Create feature branch for loop work.
1. Parse task 2. **Completion-criteria resolution**:
3. Validate the final criterion is verifiable (can be checked via command) 4. Create `.aiwg/ralph/` workspace if not exists 5. Initialize iteration counter (i=0) 6. Create feature branch if --branch specified 7. **Write the criterion and its rationale into the loop's progress file** (`.aiwg/ralph/<loop-id>/progress.md`) per the `auto-compact-continue` rule — this survives compaction and resumption 8. Log initialization
**Communicate**:
Agent Loop Initialized
Task: {task}
Completion: {completion}
Max iterations: {max}
Starting iteration 1...For each iteration i:
1. Increment counter (i++) 2. Check iteration limit - if exceeded, go to Error Handling 3. Check timeout - if exceeded, go to Error Handling 4. Execute task with full context:
5. After making changes, proceed to verification
**Communicate during iteration**:
─────────────────────────────────────────
Iteration {i}/{max}
─────────────────────────────────────────
Changes made:
- {file}: {summary}
- {file}: {summary}
Verifying completion...1. Run verification command from --completion criteria 2. Parse result:
3. If SUCCESS:
4. If CONTINUE:
**Verification approach**:
# For "npm test passes" npm test # Check: exit code 0 # For "coverage >80%" npm run coverage # Check: output contains percen
Reusable project context and specialist workflows for the AI tools you already use. Plan software, coordinate specialist reviews, prepare campaigns, investigate incidents, organize research, curate media, and maintain operational knowledge.
Repo: jmagly/aiwg
Crash-resilient external agent loop with state persistence and CI/CD integration
Detect requests for iterative autonomous agent loops and route to the appropriate loop executor
Automatically execute tests when code-generating agents modify source files, enforcing the execute-before-return pattern
Enable agent loops to learn from similar past tasks and share patterns across loops
Query and manage the executable feedback debug memory
Execute tests on generated code and iterate until passing