| name | autoloop |
| description | Autonomous recursive improvement loop for a single target. Runs gap analysis, recursive refinement, evaluation, and convergence checks until the target reaches quality threshold or converges. |
| argument-hint | [repo path, target, or task context] |
autoloop
Autonomous recursive improvement loop for a single target. Runs gap analysis, recursive refinement, evaluation, and convergence checks until the target reaches quality threshold or converges.
Inputs
| Parameter | Values | Default | Description |
|---|
target | path or context | cwd | What to operate on |
/autoloop — Autonomous Recursive Improvement
Step 0: Preamble
Before executing, run the shared ProductionOS preamble (templates/PREAMBLE.md).
You are running the /autoloop command. This is an autonomous recursive improvement loop that takes a target and iteratively improves it until convergence.
Input
The user provides:
- Target: A file path, directory, or description of what to improve
- Goal: What "good" looks like (optional -- defaults to "maximize quality score")
Execution Protocol
Step 1: Understand the Target
- If target is a file path: Read it and assess current state
- If target is a directory: Scan for key files and assess overall quality
- If target is a description: Identify what needs to be created or improved
Step 2: Gap Analysis
- Score current state using the ProductionOS rubric and convergence heuristics already present in this repo
- Scan
~/repos/ for reference implementations (per CLAUDE.md Auto-Enrichment Protocol)
- Check
~/.productionos/recursive/reference-corpus/ for similar high-quality outputs
- Identify specific gaps between current state and goal
Step 3: Initialize Recursion
- Create session state at
~/.productionos/recursive/recursion-state.json:
{
"session_id": "<generated>",
"target": "<target>",
"goal": "<goal>",
"layer": "L17",
"current_iteration": 0,
"max_iterations": 10,
"best_iteration": 0,
"best_score": 0.0,
"scores": [],
"convergence_verdict": "CONTINUE",
"status": "running"
}
- Select the appropriate layer:
- Complex decomposable task -> L16 RecDecomp
- Quality improvement (default) -> L17 SelfRefine
- Context too large -> L18 RecSumm
- Security/factual claims -> L19 RecVerify
- Plan execution -> L20 PEER
Step 4: Iteration Loop (max 10)
For each iteration:
- Score: Run confidence scorer on current output
- Record: Add score to convergence monitor
- Check Convergence: Run all 5 algorithms from
convergence.py:
- Score delta tracking (stalled if < 0.1 for 2+ iterations)
- Spectral contraction (converged if cosine > 0.95)
- Diminishing returns (stalled if DR ratio < 0.15)
- Oscillation detection (oscillating if sign changes > 60%)
- EMA velocity (plateau if |EMA delta| < 0.05)
- If STOP: Return best iteration output
- If CONTINUE: Apply refinement via the selected layer
- Quality Gate: Check for monotonic improvement and stop if the loop regresses materially
- Log: Write metrics to
~/.productionos/recursive/metrics/
Step 5: Completion
- Return the output from the best-scoring iteration
- Show convergence trajectory (ASCII visualization)
- Report: iterations completed, final score, convergence reason
- Save final state to recursion-state.json
Output Format
AUTOLOOP COMPLETE
Target: <target>
Goal: <goal>
Iterations: <n> / <max>
Best Score: <score> (iteration <i>)
Convergence: <verdict> — <reason>
Trajectory:
i=0 |*** | 4.20
i=1 |********* | 6.50 (+2.30)
i=2 |*********** | 7.20 (+0.70)
i=3 |************ | 7.30 (+0.10) <- converged
Applied: <output from best iteration>
Constraints
- Max 10 iterations per autoloop invocation
- Configurable depth per iteration (default: 1)
- Always check token budget before each iteration
- Never modify Phase 1 or Phase 2 RLM scripts
- Log everything to metrics for PromptEvo batch analysis
- Use
rlm-recursive-orchestrator agent for depth management when needed
Integration
This command integrates all Phase 1-3 RLM components:
confidence_scorer.py — scoring each iteration
quality_gate.py — monotonic improvement enforcement
convergence.py — 5-algorithm convergence detection
instinct_scorer.py — weight adjustment from learned patterns
embedding_corpus.py — reference comparison
prompt_evolution.py — active prompt selection per layer
tier2_live_eval.py — evaluation framework
rlm_classifier.py — budget circuit breaker
Error Handling
| Scenario | Action |
|---|
| No target provided | Ask for clarification with examples |
| Target not found | Search for alternatives, suggest closest match |
| Missing dependencies | Report what is needed and how to install |
| Permission denied | Check file permissions, suggest fix |
| State file corrupted | Reset to defaults, report what was lost |
Guardrails
- Do not silently change scope or expand beyond the user request.
- Prefer concrete outputs and verification over abstract descriptions.
- Keep scope faithful to the user intent.
- Preserve existing workflow guardrails and stop conditions.
- Verify results before concluding.