autoloop

autoloop is a command for Claude Code from ShaheerKhawaja/ProductionOS. It costs 36 tokens per session (1,102 once invoked), scanned A, original, MIT.

An iterative improvement command that repeatedly examines a target, identifies gaps, applies refinements, and evaluates the result until it reaches a quality threshold or stops improving.

In plain words
What is it for?
It is for improving a file, directory, or described output through assessment, gap analysis, reference checks, recursive refinement, evaluation, and convergence checks.
Why use it?
It provides a repeatable review cycle instead of relying on one pass of changes or guesswork about what still needs improvement.

Command for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions CLAUDE.md.

Part of the productionos plugin — 4 skills, 41 commands, 11 agents shipped together

Good fit It is for improving a file, directory, or described output through assessment, gap analysis, reference checks, recursive refinement, evaluation, and convergence checks.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/shaheerkhawaja/productionos/autoloop
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/ShaheerKhawaja/ProductionOS

Made for: Claude Code.

Or install productionos, the plugin that ships this one along with the rest of its 4 skills, 41 commands, 11 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for autoloop

README.md
[![agentmods](https://agentmods.dev/badge/commands/shaheerkhawaja/productionos/autoloop/github.svg)](https://agentmods.dev/commands/shaheerkhawaja/productionos/autoloop)
Your own site
<a href="https://agentmods.dev/commands/shaheerkhawaja/productionos/autoloop"><img src="https://agentmods.dev/badge/commands/shaheerkhawaja/productionos/autoloop/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for autoloop

Your own site · 80×15
<a href="https://agentmods.dev/commands/shaheerkhawaja/productionos/autoloop"><img src="https://agentmods.dev/badge/commands/shaheerkhawaja/productionos/autoloop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,102 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00036 $0.01102
Opus 5 $0.00018 $0.00551
Sonnet 5 $0.00007 $0.00220
Haiku 4.5 $0.00004 $0.00110

Measured 8d ago against content hash 903c3853be02, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

autoloop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/autoloop.md · 118 lines

How it starts

The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/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

  1. If target is a file path: Read it and assess current state
  2. If target is a directory: Scan for key files and assess overall quality
  3. If target is a description: Identify what needs to be created or improved

Step 2: Gap Analysis

  1. Score current state using the ProductionOS rubric and convergence heuristics already present in this repo
  2. Scan ~/repos/ for reference implementations (per CLAUDE.md Auto-Enrichment Protocol)
  3. Check ~/.productionos/recursive/reference-corpus/ for similar high-quality outputs
  4. Identify specific gaps between current state and goal

Step 3: Initialize Recursion

  1. 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"
    }
    
  2. 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:

  1. Score: Run confidence scorer on current output
  2. Record: Add score to convergence monitor
  3. 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)
  4. If STOP: Return best iteration output
  5. If CONTINUE: Apply refinement via the selected layer
  6. Quality Gate: Check for monotonic improvement and stop if the loop regresses materially
  7. Log: Write metrics to ~/.productionos/recursive/metrics/

Read the full file on GitHub · 118 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 118 lines · 36 tokens per session scan A 903c3853be02

Subscribe to this mod's changes

autoloop is a command published in the GitHub repository ShaheerKhawaja/ProductionOS (8 stars, last pushed 4mo ago), licensed MIT. It adds 36 tokens to every session and 1,102 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.