agent-loop

agent-loop is a skill for Claude Code, Codex from bainianlaoyao/agent-loop-designer. It costs 61 tokens per session (1,136 once invoked), scanned A, original, MIT.

A design guide for writing a Markdown contract for an agent or automation loop. The contract defines the goal, progress checks, stopping rules, approval points, and how unfinished work is handled.

In plain words
What is it for?
It helps design a loop.md file with a measurable completion signal, termination conditions, a progress invariant, approval gates, and optional rules for using subagents. It does not execute the loop or create runtime code.
Why use it?
It makes an automated process explicit and reviewable, reducing the risk of loops that run forever, stop without evidence, or perform irreversible actions without approval.

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/bainianlaoyao/agent-loop-designer/agent-loop
Any agent
npx skills add bainianlaoyao/agent-loop-designer --skill agent-loop
Clone the repo
git clone --depth 1 https://github.com/bainianlaoyao/agent-loop-designer

Made for: Claude Code, Codex.

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 agent-loop

README.md
[![agentmods](https://agentmods.dev/badge/skills/bainianlaoyao/agent-loop-designer/agent-loop.svg)](https://agentmods.dev/skills/bainianlaoyao/agent-loop-designer/agent-loop)
Your own site
<a href="https://agentmods.dev/skills/bainianlaoyao/agent-loop-designer/agent-loop"><img src="https://agentmods.dev/badge/skills/bainianlaoyao/agent-loop-designer/agent-loop.svg" alt="Measured on agentmods" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,136 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.00061 $0.01136
Opus 5 $0.00030 $0.00568
Sonnet 5 $0.00012 $0.00227
Haiku 4.5 $0.00006 $0.00114

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

Security

Grade A, and why

agent-loop 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 5d 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.

skills/agent-loop/SKILL.md · 111 lines

How it starts

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

Agent Loop

Role

Design one artifact: loop.md. It fixes the decisions a loop must settle and leaves execution to the user's external goal mode. Do not run the loop, write executors, generate launcher code, or prescribe mechanics such as while blocks, phases, tool dispatch, or state layout.

Use assets/loop-template.md as the blank output shape when drafting a new loop.md. Use references/review-checklist.md during review, whenever a residual appears, or when subagent policy is in scope.

Output Shape

loop.md is a design contract. Include only sections that are needed for the task, but keep the spine:

  1. Goal & Success Signal - one goal and an observable completion test. Avoid vague signals such as "done", "looks good", or "task complete".
  2. Termination Conditions - max iterations or budget, the concrete shape of no progress, and the goal-achievement check.
  3. Progress Invariant - the bounded quantity every path advances toward an exit. A path that neither terminates nor advances is undeliverable.
  4. Approval Gates - only for irreversible actions. State the gated action, grant consequence, and deny consequence. Do not gate separable safe work.
  5. Measurement Domain - match verification to the output domain: code uses tests, visual work uses renders/screenshots, interactive work is driven, and data work uses queries or checks.
  6. Residual Routing - route iteration failures to LOCAL (retry in loop), PLANNER (re-scope), or HUMAN (escalate).
  7. Subagent Using Policy (only if dispatching subagents) - define the dispatch contract, not the dispatch mechanism: trigger, role capability, input contract, output contract and acceptance check, concurrency, failure routing, and sub-task termination.

For the exact blank document, copy the shape from assets/loop-template.md.

Workflow

compile goal -> survey role capability -> grill -> draft -> review -> user diff -> accept
  1. Compile goal - extract task, success signal, risk surface, and output domains.
  2. Survey role capability - before grilling subagent selection, inspect the current platform's available role capabilities and tool boundaries. Use this as the strawman for any subagent dispatch contract. Skip this only when the loop will not dispatch subagents.
  3. Grill - resolve one design branch at a time with 2-3 related questions. Each question includes a recommended answer for the user to accept or correct. Push back on vague answers with a sharper strawman.
  4. Draft - write Goal, Termination, and Progress Invariant first; then fill the needed optional sections from the decision log.
  5. Review - read references/review-checklist.md; fix LOCAL residuals in place, re-scope PLANNER residuals, and escalate HUMAN residuals.
  6. User diff - change only the sections the user names.
  7. Accept - deliver when the user accepts and no residuals remain.

Read the full file on GitHub · 111 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 5d ago First seen · 111 lines · 61 tokens per session scan A f4842113af75

Subscribe to this mod's changes

agent-loop is a skill published in the GitHub repository bainianlaoyao/agent-loop-designer (11 stars, last pushed 2mo ago), licensed MIT. It adds 61 tokens to every session and 1,136 once invoked, about $0.0003 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-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

local-ai-agents

Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…

microsoft/ai-agents-for-beginners · 200 tokens

chronicle

Analyze Copilot session history for standup reports, usage tips, session search, and session reindexing. Use when the user asks for a standup, daily summary, usage tips, workflow recommendations, wants to search or find past sessions by keyword/file/PR, wants to reindex their session store, or asks about deleting…

microsoft/vscode · 72 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens