loop-engineering
Framework for designing robust, automated agent loops with integrated verification steps.
Install
mkdir -p .claude/skills/loop-engineering && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16678" && unzip -o skill.zip -d .claude/skills/loop-engineering && rm skill.zipInstalls to .claude/skills/loop-engineering
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Turn a repeatable task into a bounded, evidence-driven agent loop. Use when Codex needs to decide whether a task merits a Goal, Loop, Automation, or AutoResearch pattern; define a loop contract; check trigger/state/tools/codebase readiness; choose single-agent versus maker-checker versus manager-workers topology; prevent runaway iteration; or repair a loop that stalls, self-grades, exceeds review budget, or writes without verified evidence.Key capabilities
- →Choose execution mode for repeatable tasks (Goal, Loop, Automation, AutoResearch)
- →Admit or reject a loop based on repeatability and verifiability
- →Check loop harness readiness (trigger, worktree, skills, tools, verifier, memory)
- →Create a loop contract with objective, mode, trigger, scope, evidence, limits, and permission boundary
- →Distinguish verified success, budget stop, stall, and blocked states
- →Ensure independent verification for loop outputs
How it works
This skill structures repeatable tasks into bounded, evidence-driven agent loops by defining a loop contract, choosing an execution mode, and checking readiness conditions.
Inputs & outputs
When to use loop-engineering
- →Design agent loop
- →Automate repeatable task
- →Implement verification gate
- →Manage agentic state
About this skill
Loop Engineering
<skill_contract> <input>A repeatable task with inspectable state, finite budgets, permissions, and an independent verifier.</input> <output>A validated Trigger -> Execute -> Verify -> State contract plus resumable run receipts.</output> <done>The declared metric or stop condition is supported by fresh validator and verifier evidence.</done> <non_goals>Dependency-graph orchestration, unbounded autonomy, or self-certified completion.</non_goals>
Build loops only when repeated execution creates evidence. Every loop needs admission, a validated contract, durable state, independent evaluation, bounded retries, stop/recovery rules, and a final receipt.
Usage Template
Provide: objective, trigger, scope/non-goals, inputs, state/artifact paths, metric, verifier, permissions, budgets, stop condition, recovery, and write-back. See references/ci-repair-loop-example.md for a worked contract.
Workflow
<intake>Select one mode:
- Goal: run until a defined end state or cap.
- Loop: poll/iterate while eligible work exists.
- Automation: start from an external schedule/event; the trigger is not execution evidence.
- AutoResearch: vary experiments against an objective metric in a sandbox.
Admit only if work is repeatable, outputs are inspectable, a verifier exists, failures are recoverable, and autonomy is worth the orchestration/review cost. Otherwise use a one-shot workflow.
Use graph-engineering instead when explicit data dependencies, independent
branches, typed joins, or node-local recovery create measurable value. A Graph
node may use this Loop contract for local repetition; Graph width does not
replace finite Loop depth.
<unknowns_gate>
Classify unknowns as known, probeable, testable, or blocked. Missing objective, verifier, permission boundary, budget, or recovery is NEEDS_INPUT; do not infer these controls from intent. Unknown implementation details may be resolved inside the loop only when the probe is bounded and reversible.
</unknowns_gate>
<execute>Write this contract before acting:
Objective: Mode: Goal | Loop | Automation | AutoResearch
Trigger: Scope: Non-goals:
Owner: Inputs:
Artifacts path: State path: Work clock:
Success metric: Evidence: Verifier:
Topology: single-agent | maker-checker | manager-workers
Max iterations: Time limit: Budget:
Review budget: Stop condition:
Write-back: Permission boundary: Recovery:
Validate it with scripts/validate_loop_contract.py --strict. Then iterate:
- Observe: load durable state, fresh environment evidence, budgets, and last error.
- Orient: update one hypothesis; choose the smallest action that can change the metric.
- Decide: check scope, permissions, expected evidence, and rollback.
- Act: execute one bounded action and capture artifact/diff/receipt.
- Verify: use a deterministic check or independent checker; compare metric and guardrails.
- State: append diagnosis, action, evidence, delta, budget, and next decision atomically.
- Stop/continue: stop on success, cap, permission boundary, regression, repeated signature, or no useful work.
Normalize the model/runtime termination signal after every action. complete
still requires the declared verifier; tool_request returns proposed arguments
to the host permission gate; checkpoint/truncation persists state before any
continuation; refusal, error, or unknown escalates. Never infer completion from
fluent prose or from the word "stop" alone.
For maintenance and queue loops, declare an allowed NO_OP outcome and its
eligibility query. A quiet iteration is successful only when the query proves
there was no eligible work, output count is within policy, and no side effect
occurred.
Use single-agent by default, maker-checker for ambiguous/high-risk evaluation, and manager-workers only for genuinely independent work with an explicit integration gate.
If a validated Graph owns the dependency topology, this skill owns only the
bounded retry behavior inside its declared loop nodes.
The verifier must test the declared result rather than reward activity. Check evidence freshness, metric movement, guardrails, scope, and state replay. For external or consequential actions, require approval and verified rollback before crossing the boundary.
</evaluate><retry_policy>
max_attempts equals the contract's finite max iterations. Retry only after a named diagnosis and a changed input, tool, scope, or strategy. Stop on the same failure signature twice, metric regression, exhausted review budget, or NO_PROGRESS.
</retry_policy>
<state_contract>
Persist {run_id, status, attempt, budget, evidence, unknowns, last_error, next_action} plus contract version, trigger receipt, hypothesis, action, normalized termination reason, artifact/diff, metric/guardrail delta, permissions, output count, no-op receipt, work clock, and recovery point. Append iterations; write current state atomically.
</state_contract>
Failure Protocol
NEEDS_INPUT: a mandatory contract field is absent; do not start.BLOCKED_PERMISSION: the next action crosses authority; checkpoint and request approval.VERIFY_FAILED: result or guardrail fails; rollback/regroup before another attempt.NO_PROGRESS: the same signature repeats or the metric is unchanged after a changed attempt.BUDGET_STOP: any iteration, time, tool, cost, or review cap fires.max_attemptsis always finite.
Output Contract
Return status, result (metric/end-state decision), evidence (validator and iteration receipts), unknowns, and next_action (stop, retry, approval, recovery, or handoff).
Edge Cases
- A scheduled job fired but produced no run receipt: status is triggered, not completed; inspect executor state.
- The model ends because its context or token budget is exhausted: checkpoint
and return
BUDGET_STOPor resume from state; do not label truncation success. - A queue poll returns zero items: accept
NO_OPonly after the declared query and side-effect check pass. - The metric improves while a safety guardrail regresses: rollback and return
VERIFY_FAILED; never optimize the headline metric alone.
Success Metrics
- The strict validator passes before execution.
- Every iteration changes evidence, state, or diagnosis within finite budgets.
- A fresh verifier supports the final status and residual risk.
Quality Gates
- Trigger, owner, topology, budgets, stop, recovery, and write-back are explicit.
- Builder opinion is not the only verifier.
- Termination classes and any legal no-op have host-owned routing and evidence.
- State replay recovers the next decision losslessly.
- External mutation requires approval and rollback.
</skill_contract>
When not to use it
- →When the task is a one-reversible edit or answer
- →When the builder cannot objectively verify its own output and no maker-checker is used
- →When the task is taste-only, ambiguous, irreversible, or production-changing without human approval
Limitations
- →Does not bypass explicit approval, sandbox, permission, or production controls
- →Requires a reachable local state, inspectable output, and feasible evidence source
- →Rejects wide-open loops for taste, product strategy, vague quality, or irreversible external action
How it compares
This skill applies a control-system framework to agent loops, emphasizing independent verification, explicit state, and bounded execution, which is more structured than simply repeating prompts.
Compared to similar skills
loop-engineering side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| loop-engineering (this skill) | 0 | 1mo | Review | Advanced |
| mixseek-team-config | 0 | 6mo | Review | Intermediate |
| crewai | 4 | 6mo | No flags | Advanced |
| autonomous-agent-patterns | 4 | 6mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
mixseek-team-config
drillan
MixSeekのチーム設定ファイル(team.toml)を生成します。「チームを作成」「エージェント設定を生成」「Web検索チームを作って」「分析チームを設定」といった依頼で使用してください。Leader AgentとMember Agentの構成を定義します。
crewai
davila7
Expert in CrewAI - the leading role-based multi-agent framework used by 60% of Fortune 500 companies. Covers agent design with roles and goals, task definition, crew orchestration, process types (sequential, hierarchical, parallel), memory systems, and flows for complex workflows. Essential for building collaborative AI agent teams. Use when: crewai, multi-agent team, agent roles, crew of agents, role-based agents.
autonomous-agent-patterns
davila7
Design patterns for building autonomous coding agents. Covers tool integration, permission systems, browser automation, and human-in-the-loop workflows. Use when building AI agents, designing tool APIs, implementing permission systems, or creating autonomous coding assistants.
computer-use-agents
davila7
Build AI agents that interact with computers like humans do - viewing screens, moving cursors, clicking buttons, and typing text. Covers Anthropic's Computer Use, OpenAI's Operator/CUA, and open-source alternatives. Critical focus on sandboxing, security, and handling the unique challenges of vision-based control. Use when: computer use, desktop automation agent, screen control AI, vision-based agent, GUI automation.
voice-ai-engine-development
sickn33
Build real-time conversational AI voice engines using async worker pipelines, streaming transcription, LLM agents, and TTS synthesis with interrupt handling and multi-provider support
crewai-developer
smallnest
Comprehensive CrewAI framework guide for building collaborative AI agent teams and structured workflows. Use when developing multi-agent systems with CrewAI, creating autonomous AI crews, orchestrating flows, implementing agents with roles and tools, or building production-ready AI automation. Essential for developers building intelligent agent systems, task automation, and complex AI workflows.