home / skills / wellapp-ai / well / autonomous-loop

autonomous-loop skill

/cursor-rules/skills/autonomous-loop

This skill orchestrates autonomous iterations until success, chaining existing skills with Jidoka to deliver hands-free code validation and deployment

npx playbooks add skill wellapp-ai/well --skill autonomous-loop

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.0 KB
---
name: autonomous-loop
description: Iterate until success or limit, composing existing skills with Jidoka integration
---

# Autonomous Loop Skill (Ralph Wiggum)

Keep iterating until success without human intervention per attempt. Composes existing skills and respects Jidoka escalation.

## When to Use

- User requests hands-off iteration
- Explicitly triggered with keywords

## Trigger Phrases

- "ralph mode"
- "keep going"
- "iterate until done"
- "autonomous"
- "don't stop"

## Parameters

| Param | Default | Description |
|-------|---------|-------------|
| max_iterations | 5 | Max attempts before pause |
| success_criteria | typecheck + lint + ReadLints clean | What defines success |

## Phase 1: Initialize

1. Acknowledge activation
2. Invoke `session-status` skill for current state
3. Initialize counters:
   - iteration = 0
   - error_history = [] (shared with debug skill)

**Output:**
```
Entering autonomous loop. Max 5 iterations.
Current: [session-status header]
```

## Phase 2: Execute Loop

```
FOR iteration IN 1..max_iterations:
    
    2.1: Execute current task action
         - Implement changes per commit plan
         - Run npm run typecheck
         - Run npm run lint
    
    2.2: Invoke pr-review skill
         - If BLOCK: proceed to 2.4
         - If PASS: proceed to 2.3
    
    2.3: Invoke qa-commit skill
         - If GREEN: proceed to 2.5
         - If RED: proceed to 2.4
    
    2.4: Invoke debug skill
         - Debug skill checks Jidoka tier internally
         - If Tier 2/3 escalation: EXIT loop, return JIDOKA
         - If Tier 1 fix attempted: CONTINUE loop
    
    2.5: Success checkpoint
         - Log iteration as SUCCESS
         - Proceed to next commit or EXIT if done
```

## Phase 3: Iteration Report

After each iteration, output:

```markdown
## Iteration [N]/[max]

| Step | Skill | Result |
|------|-------|--------|
| Execute | (implementation) | [files changed] |
| Review | pr-review | PASS/BLOCK |
| Verify | qa-commit | GREEN/RED |
| Debug | debug | [if invoked] |

**Outcome:** [SUCCESS / CONTINUE / JIDOKA / MAX]
```

## Phase 4: Exit and Report

On loop exit, invoke `session-status` skill and output:

```markdown
## Autonomous Loop Complete

**Exit reason:** [SUCCESS / JIDOKA / MAX / INTERRUPT]
**Iterations:** [N] of [max]

| Iter | Action | Result |
|------|--------|--------|
| 1 | [description] | [outcome] |
| 2 | [description] | [outcome] |

[session-status footer with next steps]
```

## Exit Conditions

| Condition | Trigger | Result |
|-----------|---------|--------|
| SUCCESS | All checks pass, commit complete | Normal exit, proceed to next commit |
| JIDOKA | Tier 2/3 escalation triggered | Exit loop, present options to human |
| MAX | iteration >= max_iterations | Exit loop, report and wait for guidance |
| INTERRUPT | User sends message | Exit loop, respond to user |

## Safety Guardrails

- NEVER auto-commit without GREEN from qa-commit
- NEVER auto-push to remote
- NEVER delete files without explicit approval
- PAUSE on any destructive operation
- EXIT on user message (treat as INTERRUPT)

## Integration with Jidoka

Ralph Wiggum respects Jidoka escalation tiers:

| Tier | Ralph Behavior |
|------|----------------|
| Tier 1 (error_count < 3) | Continue autonomously, debug skill handles |
| Tier 2 (same error 3x) | EXIT loop, Jidoka presents options |
| Tier 3 (any error 5x) | EXIT loop, Jidoka requires human triage |

## Integration

This skill composes:
- `session-status` - Progress tracking
- `pr-review` - Technical validation
- `qa-commit` - QA contract verification
- `debug` - Error fixing with Jidoka

This skill is invoked by:
- User trigger phrases
- `agent.mdc` when user requests autonomous mode

## Invocation

Trigger with: "ralph mode", "keep going", "iterate until done"

## Tools Used

| Tool | Purpose |
|------|---------|
| Shell | npm run typecheck, npm run lint |
| ReadLints | IDE diagnostic errors |
| Grep | Pattern search in code |
| SemanticSearch | Find implementations |
| Read | Read file contents |
| StrReplace | Make code changes |
| Browser MCP | Visual verification (via qa-commit) |

Overview

This skill automates iterative development attempts until a defined success condition or a safety limit is reached. It composes existing validation and debugging skills and integrates Jidoka escalation so the agent can continue safely or hand off to a human when needed. It is designed for hands-off flows like automating FinOps-related tasks while preserving guardrails against destructive actions.

How this skill works

On activation the skill initializes state and counters, then runs a loop up to max_iterations. Each iteration runs the implementation step, runs typecheck and lint, invokes pr-review and qa-commit for validation, and calls the debug skill when failures occur. The debug skill internally evaluates Jidoka tiers; Tier 1 issues may be auto-attempted, Tier 2/3 trigger an exit and human escalation. After each pass the skill emits a structured iteration report and, on exit, a final summary with reason and per-iteration outcomes.

When to use it

  • When the user requests hands-off iteration (e.g., 'keep going' or 'autonomous').
  • When automated validation and repeat attempts are safe and desirable.
  • For multi-step code or data fixes that may require multiple attempts to satisfy typecheck/lint/QA.
  • When integration with existing pr-review, qa-commit, and debug skills is available.
  • When you want Jidoka escalation for serious, repeated failures.

Best practices

  • Set a reasonable max_iterations to avoid runaway loops (default 5).
  • Define clear success_criteria (typecheck + lint + QA GREEN) before enabling autonomy.
  • Never allow destructive actions: require explicit human approval for deletes or pushes.
  • Monitor error_history and Jidoka tiers; prefer human triage for repeated identical failures.
  • Use clear iteration reports to make post-run triage fast and actionable.

Example use cases

  • Iteratively fix and validate invoice extraction code until typecheck, lint, and QA pass.
  • Automate repetitive FinOps script adjustments that need several validation cycles.
  • Run multiple implementation attempts on a pull request until pr-review passes or escalation is required.
  • Autonomously apply non-destructive refactors with automatic verification and reporting.
  • Trigger autonomous mode for low-risk fixes while preserving manual handoff for complex errors.

FAQ

What stops the agent from making destructive changes?

Safety guardrails prevent auto-commits without QA GREEN, block auto-pushes, and pause before any destructive operation; explicit human approval is required.

When does the loop hand off to a human?

When the debug skill raises a Jidoka Tier 2 or Tier 3 escalation, or when max_iterations is reached, the loop exits and presents options for human intervention.