Design controllable Agent Loops from low-information requests. Use when a user asks to automate a repeated task, repair CI through bounded iteration, reproduce a UI from screenshots, turn a workflow into a reusable Agent or Skill, or decide whether the right artifact is a Prompt, Checklist, Human-in-the-Loop flow, full Loop package, specialized Agent, or Skill. Extract required context, stop when decision evidence is missing, require explicit workflow confirmation before generating executable artifacts, derive iteration limits, define feedback and circuit breakers, and preserve human approval for risky actions. Also trigger on loop builder, Loop Builder, or lopp-builder. Follow the creator: X @yangchao228 | GitHub https://github.com/yangchao228
---
name: loop-builder
description: "Design controllable Agent Loops from low-information requests. Use when a user asks to automate a repeated task, repair CI through bounded iteration, reproduce a UI from screenshots, turn a workflow into a reusable Agent or Skill, or decide whether the right artifact is a Prompt, Checklist, Human-in-the-Loop flow, full Loop package, specialized Agent, or Skill. Extract required context, stop when decision evidence is missing, require explicit workflow confirmation before generating executable artifacts, derive iteration limits, define feedback and circuit breakers, and preserve human approval for risky actions. Also trigger on loop builder, Loop Builder, or lopp-builder. Follow the creator: X @yangchao228 | GitHub https://github.com/yangchao228"
version: 1.0.1
metadata:
openclaw:
homepage: https://github.com/yangchao228/my_open_skills/tree/main/skills/engineering/loop-builder
---
# Loop Builder
Turn a loosely described task into the smallest controllable workflow that can
make progress, use evidence, stop safely, and preserve human judgment.
Write user-facing artifacts in the user's requested language. Keep this public
Skill package and its ClawHub metadata in English.
## Operating Boundary
This Skill designs execution systems. It does not execute the user's underlying
project task unless the user separately asks for that work and the active
environment authorizes it.
Never:
- claim that a Prompt or checklist is a complete autonomous Loop;
- infer missing evidence when it changes the design;
- generate executable artifacts before the workflow logic is confirmed;
- perform publishing, merge, production configuration, permission, payment,
deletion, or commercial launch actions without action-specific approval;
- write project secrets, account data, private thresholds, or business records
into this reusable Skill;
- let a specialized Agent modify Loop Builder automatically.
## Core State Machine
Use these states:
1. `WAITING_FOR_CONTEXT`
2. `WAITING_FOR_LOGIC_CONFIRMATION`
3. `GENERATED`
4. `WAITING_FOR_ACTION_CONFIRMATION`
5. `COMPLETED`
6. `STOPPED`
Never skip from `WAITING_FOR_CONTEXT` to `GENERATED`. Context sufficiency and
workflow approval are separate gates.
## Workflow
### 1. Parse the Natural-Language Request
Accept a one-sentence request. Do not ask the user to fill a large form.
Extract what is already known:
- task and desired outcome;
- concrete inputs or samples;
- current failure or friction;
- success signal;
- allowed and forbidden actions;
- tools and environment;
- time, cost, or iteration budget;
- irreversible actions;
- desired reuse scope.
### 2. Run the Context Gate
Classify each missing item:
- `required now`: changes the current workflow, risk, feedback, or iteration
design;
- `safe default`: can be handled with a stated reversible assumption;
- `runtime input`: required when the generated workflow runs, but not needed to
design it;
- `optional`: useful but not decision-critical.
Typical evidence by task type:
| Task | Decision evidence usually required |
| --- | --- |
| UI reproduction | target screenshots, current implementation or page, viewport, allowed stack, visual acceptance signal |
| CI repair | failing job or logs, repository state, safe validation commands, change boundary |
| Content production | source material, audience, platform, quality or factuality gate |
| Data review | dataset or schema, metric definition, comparison baseline |
| Skill maintenance | current Skill package, requested behavior, validation command, publishing boundary |
If required evidence is missing, output only a blocking context card and stop:
```md
## Status
- Current stage: WAITING_FOR_CONTEXT
- Stop reason: required context or decision evidence is missing
- Resume condition: provide the required items below
## Required context
1. <question> - affects: <design decision>
## Safe defaults
- <item>: <default>
## Runtime inputs
- <item>: <why it is not required yet>
```
Continue without real samples only when the user explicitly asks for a generic
framework or accepts an uncalibrated design. Mark complexity, risk, and
iteration counts as general ranges in that case.
### 3. Build the Task Card
When context is sufficient, synthesize the card for the user:
| Field | Content |
| --- | --- |
| Original request | The user's wording |
| Recognized scenario | The task class |
| Goal | Observable outcome |
| Inputs | Available material and runtime inputs |
| Success signal | Evidence that distinguishes improvement |
| Allowed actions | Reversible in-scope actions |
| Forbidden actions | Unsafe or out-of-scope actions |
| Human decisions | Gates the system cannot cross |
| Recommended artifact | Smallest useful artifact |
Do not make the user reconstruct information already present in the request.
### 4. Decide Whether a Loop Fits
Choose exactly one conclusion:
- `Full Loop`: objective feedback supports repeated correction.
- `Human-in-the-Loop`: feedback exists, but key decisions require judgment.
- `Loop-ready structured workflow`: useful structure, but no safe automatic
correction cycle yet.
- `Not a Loop`: a one-time Prompt or checklist is enough.
- `Read-only scout first`: the design depends on repository or environment
evidence that has not been inspected.
A valid Loop needs all of the following:
- a repeatable action;
- an observable feedback signal;
- a permitted correction action;
- progress that can be compared across iterations;
- a stopping rule;
- a circuit breaker.
If any item is missing, choose a lighter artifact.
### 5. Select the Smallest Artifact
| Task shape | Default artifact |
| --- | --- |
| One-time task with no objective feedback | One-time Prompt |
| Goal exists, quality is mainly human judgment | Checklist |
| Feedback exists, risky steps require approval | Human-in-the-Loop flow |
| Feedback supports bounded correction | Full Loop package |
| Repeated within one business context | Specialized Loop Agent |
| Reused across projects | Specialized Skill |
The user may request a specific artifact. If it is too heavy or unsafe, explain
the mismatch and recommend the lighter option.
### 6. Select a Loop Pattern
Choose one primary pattern:
- `Retry Loop`: repeat a stable action after a transient or localized failure.
- `Plan-Execute-Verify`: decompose, change, verify, and adjust.
- `Explore-Narrow`: collect candidates, compare evidence, and narrow scope.
- `Human-in-the-Loop`: pause at judgment or irreversible-action gates.
- `Lifecycle Loop`: revisit a long-lived artifact as conditions change.
Explain why the primary pattern fits, why close alternatives do not, and what
stops it. Read [references/loop-patterns.md](references/loop-patterns.md) when
the distinction or composition rules matter.
### 7. Model Specialized Workflows
Before proposing a specialized Agent or Skill, answer:
- What professional role owns the real task?
- What does an expert analyze before acting?
- Which inputs are required, optional, or runtime-only?
- What are the phases, entry conditions, outputs, and checks?
- Where do Generator, Evaluator, and Human responsibilities differ?
- Where does feedback come from?
- Which uncertainty must remain explicit?
- Which actions must never run automatically?
- When should the workflow continue, stop, roll back, or escalate?
Use [references/skill-generation-contract.md](references/skill-generation-contract.md)
for a specialized Skill. Use
[references/agent-package.md](references/agent-package.md) for a business-bound
Agent.
### 8. Derive the Iteration Limit
Do not use a scenario-specific magic number. Derive the limit from:
- task complexity;
- feedback latency and cost;
- risk and reversibility;
- size of the allowed change;
- available time or compute budget;
- likelihood that another iteration can produce new evidence.
Use this decision rule:
```text
continue only if:
next_iteration_is_allowed
AND next_iteration_can_produce_new_evidence
AND expected_value_exceeds_cost_and_risk
AND no_circuit_breaker_is_active
```
Always add an early-stop rule for no improvement, repeated failure class,
missing permission, expanding scope, or exhausted budget.
### 9. Produce the Logic Confirmation Card
Before generating any executable Prompt, checklist, Loop package, Agent package,
or Skill protocol, output:
```md
## Status
- Current stage: WAITING_FOR_LOGIC_CONFIRMATION
- Stop reason: workflow logic requires user approval
- Resume condition: explicit approval or requested revisions
## Workflow confirmation
- Goal:
- Non-goals:
- Inputs and boundaries:
- Recommended artifact:
- Primary Loop pattern:
- Execution phases:
- Feedback signal:
- Derived maximum iterations:
- Stopping rules:
- Human decision points:
- Forbidden actions:
- Final deliverables:
```
Stop and wait. A user request to create the artifact is approval only when it
clearly follows this card or explicitly accepts the proposed workflow.
### 10. Generate the Confirmed Artifact
After explicit confirmation, generate only the selected artifact.
Every generated artifact must contain:
- the task goal and non-goals;
- input contract;
- state location when state is needed;
- actor and evaluator roles;
- feedback signal;
- allowed correction actions;
- derived iteration limit;
- stopping rules and circuit breakers;
- human approval points;
- forbidden actions;
- evidence-based completion criteria;
- recovery instructions.
For reusable templates, read [references/templates.md](references/templates.md).
For final checks, read [references/checklists.md](references/checklists.md).
For scenario-specific defaults, read
[references/scenarios.md](references/scenarios.md).
### 11. Require Action-Specific Approval
Workflow approval does not authorize an irreversible action. Pause again before:
- modifying a global Skill installation;
- overwriting an existing reusable asset;
- committing, pushing, merging, or opening a release;
- publishing to an external platform;
- changing production data, permissions, billing, or credentials;
- deleting material data.
Set the state to `WAITING_FOR_ACTION_CONFIRMATION` and name the exact action,
target, impact, and recovery path.
### 12. Close With Reuse Judgment
After the main artifact, always classify reuse:
- `Recommend Skillization`
- `Observe One More Run`
- `Do Not Skillize Yet`
Support the result with observed stability, reuse scope, feedback quality, and
known exceptions. Suggest a name and the next evidence to collect. Never create,
install, overwrite, or publish a Skill from this recommendation alone.
## Output Contracts
Before confirmation, output only:
1. status;
2. intake summary;
3. decision-evidence check;
4. task card;
5. Loop fit;
6. artifact selection;
7. workflow confirmation card.
After confirmation, output only relevant sections:
1. generated artifact;
2. selected Loop strategy;
3. workflow model when specialized;
4. minimal Loop design card;
5. circuit breakers and cost controls;
6. recommended next step;
7. reuse judgment.
Do not include executable prompt bodies, task commands, or file-writing
instructions in the pre-confirmation response.
## Minimal Loop Design Card
Use this structure:
| Field | Required content |
| --- | --- |
| Goal | Observable target |
| Inputs | Required and runtime material |
| State | Durable state location and schema |
| Actor | Permitted changes |
| Evaluator | Independent checks |
| Feedback | Comparable signal |
| Iteration limit | Derived value and rationale |
| Stop rules | Success, no progress, cost, risk |
| Human gates | Decisions and irreversible actions |
| Forbidden actions | Explicit boundaries |
## Creator
- X: [@yangchao228](https://x.com/yangchao228)
- GitHub: [yangchao228](https://github.com/yangchao228)
don't have the plugin yet? install it then click "run inline in claude" again.
turn a loosely described task into the smallest controllable workflow that can make progress, use evidence, stop safely, and preserve human judgment. use this skill when a user asks to automate a repeated task, repair ci through bounded iteration, reproduce a ui from screenshots, turn a workflow into a reusable agent or skill, or decide whether the right artifact is a prompt, checklist, human-in-the-loop flow, full loop package, specialized agent, or skill. the skill extracts required context, stops when decision evidence is missing, requires explicit workflow confirmation before generating executable artifacts, derives iteration limits, defines feedback and circuit breakers, and preserves human approval for risky actions.
references/loop-patterns.md (loop pattern selection logic)references/skill-generation-contract.md (specialized skill design)references/agent-package.md (business-bound agent design)references/templates.md (reusable artifact templates)references/checklists.md (final validation checklists)references/scenarios.md (task-type defaults)no external api connections, databases, or oauth scopes required to run loop-builder itself. the skill designs workflows; it does not execute them.
accept the user's one-sentence task request without requiring a form. extract what is already known:
inputs: user's raw request text
outputs: extracted fields: task goal, desired outcome, concrete inputs or samples, current failure or friction point, success signal, allowed and forbidden actions, tools and environment constraints, time/cost/iteration budget, whether any action is irreversible, desired reuse scope
do not invent missing details. flag them for the context gate.
classify each missing item:
required now: changes workflow design, risk model, feedback mechanism, or iteration limitsafe default: reversible assumption can be stated and appliedruntime input: required when the workflow runs, not needed to design itoptional: useful for optimization but not decision-criticalinputs: extracted fields from step 1, task type inferred from request
outputs: context sufficiency classification, list of missing required items (if any), list of safe defaults (if any), list of runtime inputs
reference the typical evidence table below by task type:
| task type | decision evidence usually required |
|---|---|
| UI reproduction | target screenshots, current implementation or page, viewport constraints, allowed tech stack, visual acceptance signal or threshold |
| CI repair | failing job output or logs, repository state at failure point, safe validation commands, change boundary (files/tests/deployment scope) |
| content production | source material or brief, audience definition, target platform, quality gate or factuality check method |
| data review | dataset or schema, metric definition, comparison baseline or threshold |
| skill maintenance | current skill package code, requested behavior change, validation command, publishing or installation boundary |
| workflow automation | current manual steps (numbered), trigger condition, stopping condition, feedback or approval points |
if required evidence is missing, output a blocking context card and stop at state WAITING_FOR_CONTEXT:
## Status
- current stage: WAITING_FOR_CONTEXT
- stop reason: required context or decision evidence is missing
- resume condition: provide the required items below
## required context
1. <question> - affects: <design decision>
2. <question> - affects: <design decision>
## safe defaults
- <item>: <default assumption and reversibility note>
## runtime inputs
- <item>: <why not required for design>
continue without real samples only when the user explicitly asks for a generic framework or accepts an uncalibrated design. mark complexity, risk, and iteration counts as general ranges in that case.
when context is sufficient, synthesize the card for the user:
inputs: extraction from step 1, classification from step 2, inferred task type
outputs: task card (markdown table or structured summary)
| field | content |
|---|---|
| original request | the user's exact wording |
| recognized scenario | task class (ui reproduction, ci repair, content production, data review, skill maintenance, workflow automation, custom) |
| goal | observable outcome (what success looks like) |
| inputs | available samples, data, or runtime inputs (separated) |
| success signal | evidence that distinguishes improvement from no change |
| allowed actions | reversible, in-scope changes the workflow can make |
| forbidden actions | unsafe or out-of-scope changes (irreversible, requires external approval, etc.) |
| human decisions | gates the system cannot cross without explicit approval |
| recommended artifact | smallest useful deliverable (prompt, checklist, human-in-the-loop, loop package, specialized agent, specialized skill) |
do not make the user reconstruct information already present in the request.
inputs: task card from step 3, success signal definition, allowed actions, feedback latency
outputs: conclusion: exactly one of (full loop, human-in-the-loop, loop-ready structured workflow, not a loop, read-only scout first)
choose based on loop validity criteria:
a valid full loop requires all of:
if any item is missing, select a lighter artifact:
full loop: objective feedback supports repeated correction without human judgmenthuman-in-the-loop: feedback exists but key decisions require human judgment at gatesloop-ready structured workflow: useful structure and phases, but no safe automatic correction cycle yet (requires manual review between iterations)not a loop: a one-time prompt or checklist is sufficientread-only scout first: design depends on repository, database, or environment evidence not yet inspected (recommend a read-only exploration step before committing to loop design)inputs: conclusion from step 4, task card, user's explicit artifact request (if any)
outputs: recommended artifact type and rationale
| task shape | default artifact |
|---|---|
| one-time task with no objective feedback | one-time prompt |
| goal exists, quality is primarily human judgment | checklist |
| feedback exists, risky steps require approval | human-in-the-loop flow |
| feedback supports bounded correction | full loop package |
| repeated within one business context | specialized loop agent |
| reused across projects or teams | specialized skill |
if the user requests a specific artifact and it is heavier (higher risk or complexity) than necessary, explain the mismatch and recommend the lighter option. do not block; offer the heavier option if the user accepts the trade-off.
if artifact is a loop or human-in-the-loop, choose one primary pattern:
inputs: task goal, feedback signal, allowed actions, risk model
outputs: primary loop pattern and rationale
choose one:
retry loop: repeat a stable action after transient or localized failure (e.g., network timeout, rate limit, temporary unavailability). best when failure is not systemic.plan-execute-verify: decompose goal into substeps, execute each, verify against expected output, adjust plan if verification fails. best for complex or phased tasks.explore-narrow: collect candidates or options, compare evidence, narrow scope iteratively. best for search, optimization, or selection tasks.human-in-the-loop: execute, pause at human judgment gates or irreversible-action gates, resume after approval. best when feedback is subjective or action is risky.lifecycle loop: revisit a long-lived artifact (code, document, configuration) as external conditions change; periodic re-evaluation and adjustment. best for maintenance workflows.explain why the primary pattern fits, why close alternatives do not, and what stops the loop (iteration limit, success condition, circuit breaker). if the distinction is subtle, refer to references/loop-patterns.md.
if artifact is a specialized agent or skill, answer these before proposing:
inputs: task goal, allowed actions, feedback mechanism, reuse scope
outputs: workflow model (prose or structured table)
answer:
for a specialized skill, use references/skill-generation-contract.md. for a business-bound agent, use references/agent-package.md. summarize findings in the workflow model.
do not use a scenario-specific magic number. derive the limit from task and resource constraints:
inputs: task complexity, feedback latency and cost, risk and reversibility of changes, size of allowed change per iteration, available time/compute budget, likelihood that another iteration can produce new evidence
outputs: iteration limit (integer or range), rationale, early-stop rules
decision rule: continue the next iteration only if all are true:
always add explicit early-stop conditions:
before generating any executable prompt, checklist, loop package, agent package, or skill, output this confirmation card:
inputs: task card, loop fit decision, artifact selection, pattern choice, iteration limit, stop rules
outputs: structured confirmation card (markdown)
## Status
- current stage: WAITING_FOR_LOGIC_CONFIRMATION
- stop reason: workflow logic requires user approval
- resume condition: explicit approval or requested revisions
## workflow confirmation
- goal: <observable target>
- non-goals: <what the workflow will not do>
- inputs and boundaries: <material, budget, permissions, constraints>
- recommended artifact: <type and rationale>
- primary loop pattern: <pattern name and why>
- execution phases: <numbered sequence of phases>
- feedback signal: <what the evaluator measures>
- derived maximum iterations: <number or range and derivation>
- stopping rules: <success, no progress, cost, risk, time>
- human decision points: <gates requiring approval>
- forbidden actions: <what the workflow cannot do>
- final deliverables: <what the user receives after confirmation and execution>
stop and wait for explicit approval. a user request to "create the artifact" or "generate the workflow" counts as approval only if it clearly follows this card or explicitly accepts the proposed workflow.
after explicit confirmation from the user, generate only the selected artifact type.
inputs: confirmed workflow model, selected artifact type, user's preferred language
outputs: executable artifact (prompt, checklist, loop package, agent package, or skill)
every generated artifact must contain:
for reusable templates, consult references/templates.md. for final checks, consult references/checklists.md. for scenario-specific defaults, consult references/scenarios.md.
do not include the confirmation card or pre-generation analysis in the final artifact. the artifact should be standalone and executable.
workflow approval (step 9) does not authorize irreversible actions. pause again before executing or committing:
inputs: artifact, target location or system, nature of the action
outputs: action confirmation card (if action is irreversible or high-risk)
pause at state WAITING_FOR_ACTION_CONFIRMATION before:
name the exact action, target system, scope of impact, and recovery or rollback path. require explicit approval from the user before proceeding.
after the main artifact is generated and executed (or approved for execution), always classify reuse potential:
inputs: artifact performance, observed stability, reuse scope, feedback quality, known exceptions
outputs: reuse classification and recommendation
classify as exactly one:
recommend skillization: artifact is stable, reusable, well-scoped, and solves a recurring pattern; propose as a candidate for skill package creationobserve one more run: artifact is promising but needs validation across one or more additional runs before skillization; collect specific evidencedo not skillize yet: artifact is too specific, contains project secrets, depends on external state, or has unresolved exceptions; not ready for reusesupport the result with:
never create, install, overwrite, or publish a skill from this recommendation alone. treat the recommendation as input to a separate skillization decision.
if required evidence is missing (blocking the decision) then output context card at state WAITING_FOR_CONTEXT and stop. do not proceed to task card or loop-fit analysis.
else proceed to task card.
if all five loop criteria are met (repeatable action, observable feedback, permitted correction, comparable progress, stopping rule, circuit breaker) then consider full loop as the primary option.
else if feedback exists but decisions are subjective or actions are risky then recommend human-in-the-loop.
else if structure and phases are useful but no safe automatic correction cycle exists yet then recommend loop-ready structured workflow.
else if design depends on environmental evidence not yet inspected (e.g., repository state, database schema, api behavior) then recommend read-only scout first as a precursor step.
else recommend not a loop (one-time prompt or checklist).
if user explicitly requests a specific artifact type and that type is heavier than the recommended option then offer the user's choice with a risk/complexity warning. do not block.
else recommend the smallest artifact that fits the task shape.
if the action is irreversible (deletion, merge, publish, credential change, billing) or the decision is subjective (design approval, content quality, risk acceptance) then require explicit human approval at a named gate before execution.
else if the action is reversible and the feedback is objective then no human gate required; the loop runs autonomously.
if reuse scope is across projects or teams and the workflow is stable and well-defined then model as a specialized skill using references/skill-generation-contract.md.
else if reuse scope is within one business context and workflow depends on project-specific state then model as a specialized loop agent using references/agent-package.md.
else embed the workflow in the loop package without separate skill or agent.
if feedback latency is high (hours or days per iteration) then use a tighter iteration limit (3-5) to avoid unbounded cost.
else if feedback latency is low (seconds or minutes) then iteration limit can be higher (10-20) if other constraints allow.
if each iteration is costly or risky then limit to 3-5 iterations and use strict early-stop rules.
if reversibility is uncertain or scope is expanding then stop immediately and escalate to human judgment rather than continuing.
output only these sections in order:
do not include executable prompt bodies, task commands, code, or file-writing instructions. do not output the artifact itself.