loop-operator

A set of rules for running autonomous or partly autonomous agent loops with limits, checkpoints, progress tracking, and stop conditions.

In plain words
What is it for?
Use it for batch processing, retries, multi-step workflows, migrations, or CI/CD stages that need bounded execution and resume support.
Why use it?
It reduces the risk of loops running indefinitely, repeating failures, or losing their place during long tasks.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/apexiq/skillsmith/loop_operator
Any agent
npx skills add ApexIQ/skillsmith --skill loop_operator
Clone the repo
git clone --depth 1 https://github.com/ApexIQ/skillsmith

Made for: Claude Code, Codex.

Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,374 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00040 $0.02374
Opus 5 $0.00020 $0.01187
Sonnet 5 $0.00008 $0.00475
Haiku 4.5 $0.00004 $0.00237

Measured 2d ago against content hash 83dc5375d190, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

loop-operator 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 2d 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.

.agent/skills/loop_operator/SKILL.md · 305 lines

How it starts

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

🔄 Loop Operator — Autonomous Execution with Safety

Philosophy: Autonomous loops are powerful but dangerous. Every loop must have a clear exit condition, a safety budget, and a checkpoint mechanism. Unbounded loops are bugs, not features.

1. When to Use This Skill

  • Running multi-step agentic workflows autonomously
  • Processing batches of tasks (files, tests, migrations)
  • Implementing retry logic with exponential backoff
  • Building CI/CD pipeline stages
  • Any iterative process that needs bounded execution

2. The Autonomous Loop Contract

Every autonomous loop MUST have these 5 properties:

Property Description Example
Exit Condition When does the loop stop successfully? All tests pass, all files processed
Max Iterations Hard cap on loop cycles max_iterations=50
Max Duration Hard cap on wall-clock time max_hours=2
Failure Budget How many consecutive failures before abort early_stop_fails=3
Checkpoint State saved after each iteration for resume checkpoint_dir=.agent/loops/

The Bounded Loop Template

import time
import json
from pathlib import Path

class BoundedLoop:
    def __init__(
        self,
        max_iterations: int = 50,
        max_duration_seconds: int = 7200,
        early_stop_fails: int = 3,
        checkpoint_dir: str = ".agent/loops",
    ):
        self.max_iterations = max_iterations
        self.max_duration_seconds = max_duration_seconds
        self.early_stop_fails = early_stop_fails
        self.checkpoint_dir = Path(checkpoint_dir)
        self.checkpoint_dir.mkdir(parents=True, exist_ok=True)
        
        self.iteration = 0
        self.consecutive_failures = 0
        self.start_time = time.time()
        self.results = []
    
    def should_continue(self) -> bool:
        """Check all exit conditions."""
        if self.iteration >= self.max_iterations:
            print(f"⛔ Max iterations reached ({self.max_iterations})")
            return False
        
        elapsed = time.time() - self.start_time
        if elapsed >= self.max_duration_seconds:
            print(f"⛔ Max duration reached ({self.max_duration_seconds}s)")
            return False
        
        if self.consecutive_failures >= self.early_stop_fails:
            print(f"⛔ Too many consecutive failures ({self.early_stop_fails})")
            return False
        
        return True
    
    def checkpoint(self, state: dict):
        """Save state for resume capability."""
        checkpoint = {
            "iteration": self.iteration,
            "elapsed_seconds": time.time() - self.start_time,
            "consecutive_failures": self.consecutive_failures,
            "state": state,
            "results": self.results,
        }
        path = self.checkpoint_dir / "latest.json"
        path.write_text(json.dumps(checkpoint, indent=2))
    
    def record_result(self, success: bool, details: dict):
        """Track iteration outcomes."""
        if success:
            self.consecutive_failures = 0
        else:
            self.consecutive_failures += 1
        
        self.results.append({
            "iteration": self.iteration,
            "success": success,
            "details": details,
        })
        self.iteration += 1

Read the full file on GitHub · 305 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. 2d ago First seen · 305 lines · 40 tokens per session scan A 83dc5375d190

Subscribe to this mod's changes

loop-operator is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 5mo ago), licensed MIT. It adds 40 tokens to every session and 2,374 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.

Related

Other skills, from other repositories

rove

Use when controlling Rove tasks, parallel coding attempts, hosted agent sessions, task lifecycle, or the daemon-owned issue tracker from a shell. Also the ONLY channel for messaging another agent session on this machine — rove api send, never a peer/MCP side channel.

Sma1lboy/rove · 56 tokens

subagent-strategy

Delegates research and parallel work to sub-agents.

andreaswasita/copilot-agents-dojo · 16 tokens

agent-messaging

Send and receive cryptographically signed messages between AI agents using the Agent Messaging Protocol (AMP). Supports local messaging, federation across providers, file attachments, and Ed25519 signatures. Works with any AI agent that can execute shell commands.

23blocks-OS/ai-maestro-plugins · 50 tokens

ai-maestro-agents-management

Creates, manages, and orchestrates AI agents using the AI Maestro CLI. Use when the user asks to "create agent", "list agents", "delete agent", "rename agent", "hibernate agent", "wake agent", "install plugin", "show agent", "export agent", "restart agent", "install marketplace", or any agent lifecycle management task.

23blocks-OS/ai-maestro-plugins · 79 tokens

plugin-development

Build, extend, test, debug, package, and maintain portable EvoFlux Agent Plugins end to end, including plugin.json, immediate-child Agent Skills, portable MCP servers, credentials, installation-scoped data, Plugin Center and CLI lifecycle, and runtime verification. Use when authoring or repairing an unpacked or…

evoelsewhere/evoflux · 102 tokens

mcp-installer

Install, inspect, update, restart, authenticate, or remove EvoFlux Model Context Protocol servers and wire their tools to a selected agent. Use only for explicit MCP configuration requests; do not use to call an already-configured integration, author a new MCP server, or install a plugin or skill.

evoelsewhere/evoflux · 64 tokens