agentic/code/addons/agent-loop/skills/ralph/SKILL.md
Execute iterative task loop until completion criteria are met - iteration beats perfection
npx skillsauth add jmagly/aiwg alInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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:
Users may say:
The task to execute. Should be:
Success criteria. Must be:
Good examples:
--completion "npm test passes with 0 failures"--completion "npx tsc --noEmit exits with code 0"--completion "all files in src/ have JSDoc comments"--completion "coverage report shows >80%"Poor examples (avoid these):
--completion "code looks good"--completion "feature is done"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.
--completion is provided → use it directly--no-infer-completion is set → fail fast with a helpful errorinfer-completion-criteria skill on the task description
--auto-criteria is set OR confidence is high, adopt the proposal silently and log itAskUserQuestion on Claude Code, formatted text elsewhere per native-ux-tools); accept Y / n / edit--completion explicitly.aiwg/ralph/ workspace if not exists.aiwg/ralph/<loop-id>/progress.md) per the auto-compact-continue rule — this survives compaction and resumptionCommunicate:
Agent Loop Initialized
Task: {task}
Completion: {completion}
Max iterations: {max}
Starting iteration 1...
For each iteration i:
Communicate during iteration:
─────────────────────────────────────────
Iteration {i}/{max}
─────────────────────────────────────────
Changes made:
- {file}: {summary}
- {file}: {summary}
Verifying completion...
Verification approach:
# For "npm test passes"
npm test
# Check: exit code 0
# For "coverage >80%"
npm run coverage
# Check: output contains percentage >= 80
# For "npx tsc --noEmit passes"
npx tsc --noEmit
# Check: exit code 0
When loop completes (success or limit), generate report:
# Agent Loop Completion Report
**Task**: {original task}
**Status**: {SUCCESS | TIMEOUT | MAX_ITERATIONS}
**Iterations**: {count}
**Duration**: {time}
## Iteration History
| # | Action | Result | Duration |
|---|--------|--------|----------|
| 1 | Initial implementation | Tests failed: 3 | 2m |
| 2 | Fixed auth test | Tests failed: 1 | 1m |
| 3 | Fixed edge case | All tests pass | 1m |
## Verification Output
$ {verification command} {output}
## Files Modified
- {file} (+{added}, -{removed})
## Summary
{What was accomplished and any remaining notes}
Save to: .aiwg/ralph/completion-{timestamp}.md
Agent loop reached maximum iterations ({max})
Last failure:
{error details from last verification}
Options:
1. Increase limit: /ralph-resume --max-iterations 20
2. Manual fix, then resume: /ralph-resume
3. Abort: /ralph-abort
The loop state is saved. You can resume anytime.
Agent loop timed out after {minutes} minutes
Iteration {i} was in progress.
Work completed so far has been saved.
Options:
1. Resume: /ralph-resume
2. Increase timeout: /ralph-resume --timeout 120
3. Abort: /ralph-abort
Could not execute verification command
Command: {command}
Error: {error}
Please check:
1. Command exists (try running it manually)
2. Dependencies installed
3. Correct working directory
Adjust criteria and try again.
At start:
Starting Agent Loop
Task: {task}
Completion criteria: {completion}
Max iterations: {max}
Timeout: {timeout} minutes
Beginning iteration 1...
During each iteration:
─────────────────────────────────────────
Iteration {N}/{max}
─────────────────────────────────────────
{What I'm doing this iteration}
{Changes being made}
Verifying...
Result: {PASS/FAIL}
{If fail: what I learned, what to try next}
On success:
═══════════════════════════════════════════
Agent Loop: SUCCESS
═══════════════════════════════════════════
Task: {task}
Iterations: {N}
Duration: {time}
Verification:
$ {command}
{output showing success}
Files modified: {count}
Report: .aiwg/ralph/completion-{timestamp}.md
═══════════════════════════════════════════
On failure (limits):
═══════════════════════════════════════════
Agent Loop: {TIMEOUT | MAX_ITERATIONS}
═══════════════════════════════════════════
Task: {task}
Iterations completed: {N}
Last error: {summary}
Use /ralph-resume to continue or /ralph-abort to stop.
═══════════════════════════════════════════
This orchestration succeeds when:
/ralph "Fix all failing tests in src/auth/" --completion "npm test -- --testPathPattern=auth passes"
/ralph "Convert src/utils/ files to TypeScript" --completion "npx tsc --noEmit exits with code 0" --max-iterations 20
/ralph "Add tests to reach 80% coverage" --completion "npm run coverage shows >80%" --timeout 120
/ralph "Fix all ESLint errors" --completion "npm run lint exits with code 0"
/ralph --interactive
data-ai
Report which research-corpus radar sidecars are overdue for refresh. Computes staleness (days since last refresh vs the cadence window) for every radar, sorted most-overdue-first. Runs via `aiwg corpus radar-status`.
data-ai
Aggregate research-corpus radar sidecars into a corpus or per-cluster freshness report — totals, overdue count, per-cluster / per-GRADE / per-trajectory breakdowns, an overdue table, and per-radar rationale snippets. Runs via `aiwg corpus radar-report`.
testing
Scaffold radar/freshness sidecars for research-corpus REFs. Pulls title/authors from the citation sidecar and GRADE from the analysis doc, defaults the refresh cadence from GRADE and the cluster from a corpus-local map, and stamps documentation/radar/REF-XXX-radar.md. Runs via `aiwg corpus radar-init`.
data-ai
Compute an entity's publication trajectory — per-year paper counts, topic drift, hot-streak detection (≥3 consecutive A-grade years), and career phase. Runs via `aiwg corpus profile-temporal`.