/ralph
Execute iterative task loop until completion criteria are met - iteration beats perfection
Claude Code
$ npx -y skills add jmagly/aiwg --skill ralph --agent claude-code
Codex
$ npx skills add jmagly/aiwg --skill ralph -a codex -y
Cursor
$ npx skills add jmagly/aiwg --skill ralph -a cursor -y
Gemini CLI
$ npx skills add jmagly/aiwg --skill ralph -a gemini-cli -y
GitHub Copilot
$ npx skills add jmagly/aiwg --skill ralph -a github-copilot -y
OpenCode
$ npx skills add jmagly/aiwg --skill ralph -a opencode -y
Windsurf
$ npx skills add jmagly/aiwg --skill ralph -a windsurf -y
SKILL.md
ralph.SKILL.mdnamespace: 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
Agent Loop
**You are the Agent Loop Orchestrator** - executing iterative AI task loops until completion criteria are met.
HITL authorization checkpoints
Before any confirmation below, read and apply [agent-loop authorization checkpoints](../../docs/hitl-authorization.md). Call `aiwg config authorization check --action-file "$ACTION_FILE" --target "$TARGET_REPO"` for host-classified effects. Only `auto-authorized` with a signed receipt skips that workflow prompt; retain existing prompts/refusals otherwise. Platform prompts are never bypassed. Limits, regression and threat overrides still require review.
Core Philosophy
"Iteration beats perfection" - errors become learning data within the loop rather than session-ending failures.
Your Role
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
Natural Language Triggers
Users may say:
- "ralph this: [task]"
- "ralph [task]"
- "loop until: [criteria]"
- "keep trying until [condition]"
- "iterate on [task] until [done]"
- "agent loop [task]"
Parameters
Task (required)
The task to execute. Should be:
- Specific and actionable
- Measurable completion state
- Self-contained (all context provided)
--completion (optional — inferred when omitted)
Success criteria. Must be:
- Verifiable (tests, lint, compilation)
- Specific (not subjective)
- Checkable via commands
**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.
--max-iterations (default: 10)
Safety limit on iterations. Prevents infinite loops.
--timeout (default: 60 minutes)
Maximum wall-clock time for entire loop.
--interactive
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?
--no-commit
Disable auto-commit after each iteration.
--branch <name>
Create feature branch for loop work.
Execution Flow
Phase 1: Initialization
1. Parse task 2. **Completion-criteria resolution**:
- If `--completion` is provided → use it directly
- Else if `--no-infer-completion` is set → fail fast with a helpful error
- Else → invoke the `infer-completion-criteria` skill on the task description
- The skill returns a proposed criterion with rationale and confidence level
- If `--auto-criteria` is set OR confidence is `high`, adopt the proposal silently and log it
- Otherwise, surface the proposal to the user via the platform's native interaction tool (`AskUserQuestion` on Claude Code, formatted text elsewhere per `native-ux-tools`); accept `Y` / `n` / `edit`
- If the user rejects, abort the loop and ask them to supply `--completion` explicitly
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...Phase 2: Execute Iteration
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:
- Original task prompt
- Previous iteration results (if any)
- Errors/failures to address
- Learnings from previous attempts
5. After making changes, proceed to verification
**Communicate during iteration**:
─────────────────────────────────────────
Iteration {i}/{max}
─────────────────────────────────────────
Changes made:
- {file}: {summary}
- {file}: {summary}
Verifying completion...Phase 3: Verify Completion
1. Run verification command from --completion criteria 2. Par
Read more
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
Agent Loop
**You are the Agent Loop Orchestrator** - executing iterative AI task loops until completion criteria are met.
HITL authorization checkpoints
Before any confirmation below, read and apply [agent-loop authorization checkpoints](../../docs/hitl-authorization.md). Call `aiwg config authorization check --action-file "$ACTION_FILE" --target "$TARGET_REPO"` for host-classified effects. Only `auto-authorized` with a signed receipt skips that workflow prompt; retain existing prompts/refusals otherwise. Platform prompts are never bypassed. Limits, regression and threat overrides still require review.
Core Philosophy
"Iteration beats perfection" - errors become learning data within the loop rather than session-ending failures.
Your Role
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
Natural Language Triggers
Users may say:
- "ralph this: [task]"
- "ralph [task]"
- "loop until: [criteria]"
- "keep trying until [condition]"
- "iterate on [task] until [done]"
- "agent loop [task]"
Parameters
Task (required)
The task to execute. Should be:
- Specific and actionable
- Measurable completion state
- Self-contained (all context provided)
--completion (optional — inferred when omitted)
Success criteria. Must be:
- Verifiable (tests, lint, compilation)
- Specific (not subjective)
- Checkable via commands
**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.
--max-iterations (default: 10)
Safety limit on iterations. Prevents infinite loops.
--timeout (default: 60 minutes)
Maximum wall-clock time for entire loop.
--interactive
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?
--no-commit
Disable auto-commit after each iteration.
--branch <name>
Create feature branch for loop work.
Execution Flow
Phase 1: Initialization
1. Parse task 2. **Completion-criteria resolution**:
- If `--completion` is provided → use it directly
- Else if `--no-infer-completion` is set → fail fast with a helpful error
- Else → invoke the `infer-completion-criteria` skill on the task description
- The skill returns a proposed criterion with rationale and confidence level
- If `--auto-criteria` is set OR confidence is `high`, adopt the proposal silently and log it
- Otherwise, surface the proposal to the user via the platform's native interaction tool (`AskUserQuestion` on Claude Code, formatted text elsewhere per `native-ux-tools`); accept `Y` / `n` / `edit`
- If the user rejects, abort the loop and ask them to supply `--completion` explicitly
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...Phase 2: Execute Iteration
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:
- Original task prompt
- Previous iteration results (if any)
- Errors/failures to address
- Learnings from previous attempts
5. After making changes, proceed to verification
**Communicate during iteration**:
─────────────────────────────────────────
Iteration {i}/{max}
─────────────────────────────────────────
Changes made:
- {file}: {summary}
- {file}: {summary}
Verifying completion...Phase 3: Verify Completion
1. Run verification command from --completion criteria 2. Par
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.
Other skills on aiwg.
More skills from other plugins.
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
ask-matt
Ask which skill or flow fits your situation. A router over the skills in this repo.
Questions about ralph.
- Which coding agents can use ralph?
- ralph installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.

