agent-loop
Detect requests for iterative autonomous agent loops and route to the appropriate loop executor
Crash-resilient external agent loop with state persistence and CI/CD integration
$ npx -y skills add jmagly/aiwg --skill agent-loop-ext --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/agent-loop-extContext preview
The summary Claude sees to decide when to auto-load this skill.
Crash-resilient external agent loop with state persistence and CI/CD integration
namespace: aiwg name: agent-loop-ext legacyName: ralph-external platforms: [all] description: Crash-resilient external agent loop with state persistence and CI/CD integration commandHint: argumentHint: "\"<objective>\" [--completion \"<criteria>\"] [--max-iterations N] [--timeout M] [--provider <p>] [--no-commit] [--branch <name>] [--quiet] [--auto-criteria | --no-infer-completion]" allowedTools: Bash, Read, Write model: haiku category: automation orchestration: true platforms: [claude-code, hermes, openclaw] modelRole: efficiency modelTier: economy
<!-- AIWG-SKILL-CALLOUT --> > **Skill access pattern (post-kernel-pivot, 2026.5+)** > > Skill names referenced in this document are AIWG skills, **not slash commands**. Most are not kernel-listed and cannot be invoked as `/skill-name` by the platform. Reach them via: > > ```bash > aiwg discover "<capability>" > aiwg show skill <name> > ``` > > Only kernel-listed skills (`aiwg-doctor`, `aiwg-refresh`, `aiwg-status`, `aiwg-help`, `use`, `steward`) are directly invokable as slash commands. See [skill-discovery rule](../../../addons/aiwg-utils/rules/skill-discovery.md).
**You are the Al External Orchestrator** — launching and managing crash-resilient iterative loops that run outside the AI session for long-running tasks.
`ralph` runs the loop inside the current AI session. `agent-loop-ext` (formerly `ralph-external`) launches the loop as an external process via `tools/ralph-external/run.sh`, persisting all state to `.aiwg/ralph-external/`. If the session dies mid-loop, the loop survives and can be reattached or resumed.
Use `agent-loop-ext` when:
Users may say:
The task the loop should accomplish. Passed as the first positional argument.
Success criteria as a verifiable command. The loop exits when this command returns exit code 0.
**Good examples**:
**When omitted**: the launcher invokes the `infer-completion-criteria` skill before the external loop starts. The skill derives a measurable criterion from project state (CLAUDE.md / AGENTS.md / AIWG.md, package manifests, CI configuration, `.aiwg/` artifacts) and emits a structured proposal with rationale. The proposal is written to `.aiwg/ralph-external/<run-id>/inferred-completion.yaml` and used as the loop's gate.
Because `agent-loop-ext` runs externally (potentially headless / in CI), the confirmation flow is:
Pass `--no-infer-completion` to require explicit `--completion` and fail before launch if missing. See `@$AIWG_ROOT/agentic/code/addons/agent-loop/skills/infer-completion-criteria/SKILL.md`.
Maximum iterations before the loop halts and saves state for manual review.
Maximum wall-clock time. Loop checkpoints state before exiting so it can be resumed.
AI provider to use for loop iterations. Supported: `claude`, `codex`, `factory`, `opencode`.
Skip automatic git commits after each iteration.
Create and work on a dedicated feature branch. The branch is created before iteration 1.
Suppress verbose progress output. Completion banner is always shown.
When triggered:
1. **Resolve completion criteria**:
2. Validate the resolved criterion is verifiable (can be checked via command) 3. Check for an existing `.aiwg/ralph-external/` workspace; create if absent 3. Generate a unique `loop-id` (8-character hex) and create the loop state file at `.aiwg/ralph-external/loops/<loop-id>.json` 4. Write the initial state: `{ objective, completionCriteria, maxIterations, timeout, provider, status: "pending", iteration: 0 }` 5. If `--branch` is specified, create the git branch now 6. Invoke `tools/ralph-external/run.sh` with all parsed flags, passing the loop-id 7. The external process owns execution from this point. Print the loop-id and attach info:
Al External Loop Started
Loop ID: abc123
Objective: {objective}
Completion: {completion}
Max iterations: {max} | Timeout: {timeout}m | Provider: {provider}
Loop is running externally. Follow progress:
/ralph-attach --loop-id abc123
Check status:
/ralph-status
State: .aiwg/ralph-external/loops/abc123.json
Log: .aiwg/ralph-external/logs/abc123.log8. If `--quiet` is NOT set, automatically attach to the loop's output stream (equivalent to running `/ralph-attach --loop-id <id>`)
State is written to disk before each external process action. If the process crashes:
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
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
Infer measurable completion criteria for an agent-loop task from project docs, code, and AIWG standards when the user has not supplied --completion explicitly