Install
openclaw skills install agent-loop-engineeringUse when an AI coding agent needs bounded development loops, persistent project-local Docs/ state, context budgeting, environment escalation rules, safe stop gates, and Done / Done with Risk / Blocked completion decisions across Codex, Claude Code, OpenCode, Cline, Qoder, CodeBuddy, Trae, Gemini CLI, Aider, GitHub Actions, or other AI coding agents.
openclaw skills install agent-loop-engineeringVersion: 1.0.0
Agent Loop Engineering 是一个面向 AI Coding Agent 的编码循环总控 Skill。它把用户目标、验收标准、当前状态、待办、停止规则、完成判定和每轮记录保存在项目自己的 Docs/ 目录中,让 Codex、Claude Code、OpenCode、Cline、Qoder、CodeBuddy、Trae、Gemini CLI、Aider、GitHub Actions 等不同 Agent 可以接力同一个开发工作。
核心原则:
Docs/ 协议不变。Done。Docs/ 状态文件。推荐入口:
agent-loop-engineering。ai-workflow-os 或 web-search-rules。daily-workflow,但要保留 Agent Loop Engineering 的 loop evidence。Use this skill as the top-level controller for AI coding work only. The goal is to turn development into a managed loop:
Target -> Plan -> Implement -> Verify -> Review -> Fix -> Evaluate -> Continue or Stop
Do not rely on chat history as memory. Persist the working state in the project's own Docs/ directory so any agent can resume after context loss, a new session, or a different runner.
For non-coding workflow governance, research intake, knowledge-base work, or cross-source synthesis, use ai-workflow-os. For coding-loop control, implementation direction, stop gates, and completion gates, this skill is authoritative.
State is stable. Runner is replaceable. Stop rules are universal.
Docs/.TARGET.md -> ACCEPTANCE.md -> STATUS.md -> PENDING.md -> NEXT_ACTIONS.md.Docs/ file names. Legacy aliases may be read for migration, but write canonical files only.Bootstrap if Docs/ is missing
-> Loop Start
-> Verify target and acceptance
-> Discover project verification commands
-> Execute one bounded implementation loop
-> Run automatic and functional verification
-> Completion or stop gate
-> Write state and user report
Route to existing skills only when needed:
project-lifecycle-navigator when Docs/TARGET.md is missing, the user cannot state the goal in one sentence, multiple goals conflict, or MVP boundaries are unclear. If unavailable, use the bootstrap questions in references/bootstrap.md and stop for confirmation when the target remains unclear.ai-workflow-os for multi-source research decisions, knowledge intake governance, cross-module audits, or non-coding workflow governance. Do not route pure code verification or bug-fix loops to it. If unavailable, keep coding-loop state in this skill and record unresolved governance work in Docs/PENDING.md.daily-workflow when the user explicitly asks to checkpoint, wrap up, recover after context loss, or create a standalone handoff. During a coding loop, keep lightweight loop updates in this skill. If unavailable, write Docs/HANDOFF.md using references/loop-state-protocol.md.web-search-rules when using external web pages, API docs, uploaded files, or other sources that require trust and provenance handling. If unavailable, use primary sources where possible and record source limits in Docs/STATUS.md. In a coding loop, write the short research conclusion to Docs/STATUS.md compressed context or Docs/PENDING.md; use the full intake path only when the task is research/governance-heavy.Do not load every related skill every loop. Load the narrow skill or reference file that answers the current question.
Use project-local Docs/ files. Create missing files conservatively from the schemas in references/loop-state-protocol.md.
Minimum reused files:
Docs/TARGET.mdDocs/STATUS.mdDocs/PENDING.mdDocs/NEXT_ACTIONS.mdDocs/HANDOFF.md when a standalone handoff is neededAgent Loop Engineering files:
Docs/LOOP_CONFIG.mdDocs/ACCEPTANCE.mdDocs/EVALUATION.mdDocs/STOP_RULES.mdDocs/LOOP_RUNS.jsonlDocs/COMPLETED.mdCanonical file names are TARGET.md, STATUS.md, COMPLETED.md, PENDING.md, NEXT_ACTIONS.md, and HANDOFF.md. Read legacy aliases only for migration, such as PROJECT_TARGET.md, PROJECT_STATUS.md, COMPLETED_JOBS.md, PENDING_JOBS.md, NEXT_STEPS.md, or SCHEDULE.md; after migration, write the canonical files.
If Docs/ does not exist or both Docs/TARGET.md and Docs/ACCEPTANCE.md are missing, follow references/bootstrap.md before coding.
At the start of each loop:
Docs/LOOP_CONFIG.md if it exists; otherwise use the default budget below.Docs/TARGET.md and Docs/ACCEPTANCE.md.Docs/STATUS.md.Docs/PENDING.md.Docs/NEXT_ACTIONS.md.package.json, pyproject.toml, Makefile, Cargo.toml, go.mod, pom.xml, or repository docs to identify test, lint, build, typecheck, and functional verification commands. Record discovered commands in Docs/LOOP_CONFIG.md.Default budget:
protocol_version: 1
runner: generic
max_loops: 5
max_consecutive_failures: 2
max_runtime_minutes: 60
max_context_files_per_loop: 8
max_recent_loop_records: 5
require_double_evidence_for_done: true
core_verification: test
max_compressed_context_lines: 40
log_directory: .agent/logs
verification_commands:
test: null
typecheck: null
build: null
lint: null
functional: null
progress_signals:
- new passing verification
- narrower failing scope
- changed root cause with evidence
- implemented accepted next action
allow_parallel_tasks: false
allow_project_dependency_install: true
allow_project_config_changes: true
allow_system_install: false
allow_secret_access: false
allow_production_data_access: false
allow_destructive_changes: false
max_consecutive_failures counts only consecutive failures of core_verification. If core verification fails but a configured progress signal is present, do not increment the consecutive failure count for that loop. Other verification failures must be recorded in Docs/EVALUATION.md, but they do not consume this budget unless Docs/LOOP_CONFIG.md defines a stricter project-specific rule.
For simple bug fixes, use 3-5 loops. For multi-file features, 8-10 loops may be reasonable. Keep max_loops below 20 unless the user explicitly approves a longer run.
For coding work, run one bounded cycle:
Select next action -> Implement minimal change -> Run verification -> Review result -> Fix if safe -> Evaluate status
The agent may automatically handle project-local problems listed in references/environment-escalation.md. The agent must stop and ask a human for anything outside that whitelist.
At the end of every loop, update the touched acceptance criteria in Docs/ACCEPTANCE.md under Current evidence. If a criterion is blocked, name the unmet criterion ID or heading in Docs/EVALUATION.md and Docs/PENDING.md.
Loop-end write contract:
Docs/EVALUATION.md.Docs/STATUS.md compressed context and latest verification.Docs/ACCEPTANCE.md current evidence for touched criteria.Docs/PENDING.md.Docs/NEXT_ACTIONS.md.Docs/COMPLETED.md when a user-visible or verification-backed unit is finished.Docs/LOOP_RUNS.jsonl.daily-workflow may create broader checkpoint or handoff summaries when explicitly triggered by the user, but it should not replace the loop-end write contract above.
If the user changes direction, classify it before editing:
scope_expansion: affects no more than 2 Must Pass items and does not change Non-Goals. Add or adjust affected Docs/ACCEPTANCE.md items and record the expansion in Docs/EVALUATION.md.target_revision: changes the user goal, changes any Non-Goals, replaces the verification strategy, or affects more than 2 Must Pass items. Update Docs/TARGET.md, regenerate affected acceptance criteria, append a target_revision entry to Docs/EVALUATION.md, and continue only after the new target is unambiguous.If the classification is ambiguous, stop and ask.
Use progressive reading:
Docs/ set.Docs/LOOP_RUNS.jsonl only for the last 3-5 records unless debugging loop behavior.Docs/STATUS.md.Docs/STATUS.md to the latest 5-10 updates and archive older material.Read references/context-budget.md when context size becomes a risk or when designing a long-running loop.
Read references/automation-runner.md when the user asks to add scheduled, repeated, local, CI, or runner-driven automation around the loop.
Stop immediately and report Blocked when the loop needs:
Docs/TARGET.md.The built-in hard stops in this section and references/environment-escalation.md are authoritative. Docs/STOP_RULES.md may add stricter project rules. It may not loosen hard stops unless a human approval is recorded under Docs/STOP_RULES.md -> Overrides with scope and expiration, and that override still cannot permit secret exposure, production data access, or irreversible action without explicit human confirmation for that run.
The allow_* flags in Docs/LOOP_CONFIG.md cannot override hard stops. They only control whether otherwise safe, project-local whitelist actions are allowed by default.
Stop on budget when:
max_loops is reached.max_consecutive_failures is reached.max_runtime_minutes is reached.Record every stop in Docs/EVALUATION.md, Docs/PENDING.md, Docs/NEXT_ACTIONS.md, and Docs/LOOP_RUNS.jsonl.
When max_context_files_per_loop would be exceeded, queue optional reads, summarize already-read material first, and continue only if the loop can still be completed safely. If the agent cannot decide without exceeding the budget, stop as Blocked.
Use only these states:
Done: all success criteria are satisfied and at least two evidence classes support completion, including automatic verification and functional verification.Done with Risk: the core goal is met, but there are explicit unverified edges, skipped checks, or environment limits.Blocked: work cannot continue or completion cannot be judged without human input, permission, credentials, environment access, or a direction decision.Continue: bounded next action exists and no stop rule is triggered.Read references/completion-gate.md before declaring Done or Done with Risk.
Before ending any loop, run the checklist in references/self-check.md.
This skill is runner-neutral. Use references/runner-adapters.md when adapting the loop to Codex, Claude Code, OpenCode, Cline, Qoder, CodeBuddy, Trae, Gemini CLI, Aider, GitHub Actions, or a local scheduler.
Use references/automation-runner.md when designing the outer automation mechanism that repeatedly starts one-loop agent runs, parses stop states, enforces budgets, and stops on human gates.
All adapters must:
Docs/.For each loop, report concisely:
Loop status: Continue / Done / Done with Risk / Blocked
- Target alignment:
- Work completed:
- Verification:
- Risks/blockers:
- Files updated:
- Next action:
Use the user's language by default.
The chat report is for the user. Also append the decision and evidence to Docs/EVALUATION.md.