build-loop
Use when an agent should work continuously or on a schedule. The user asks to "build a loop", "set up a self-directed cycle", "run this nightly", or "keep X green/tidy automatically". Also when an existing loop burns tokens, repeats failed fixes, opens duplicate PRs, or ships unreviewed changes.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- build-loop
- license
- MIT
- metadata
- { "summary": "Designs a continuous agent loop using LOOP.md, a seeded state file, a loop prompt, and a report-only-first rollout.", "category": "Automation" }
- description
- Use when an agent should work continuously or on a schedule. The user asks to "build a loop", "set up a self-directed cycle", "run this nightly", or "keep X green/tidy automatically". Also when an existing loop burns tokens, repeats failed fixes, opens duplicate PRs, or ships unreviewed changes.
02 资源文件 9
- 其他evals/cases.jsonl11.4 KB
- 参考文档evals/fixtures/misbehaving-loop/LOOP.md468 B
- 参考文档evals/fixtures/misbehaving-loop/README.md993 B
- 参考文档evals/fixtures/misbehaving-loop/STATE.md542 B
- 参考文档evals/results/README.md4.4 KB
- 参考文档evals/results/tier2scope-2026-08-01.md5.5 KB
- 参考文档evals/skill-brief.md5.7 KB
- 参考文档references/loop-formats.md4.8 KB
- 参考文档references/pressure.md1.7 KB
03 SKILL.md 正文
Build Loop
A loop discovers work, acts, verifies, records state, and chooses the next move. Build four portable artifacts: LOOP.md, STATE.md, a loop prompt, and a rollout plan. Add a runner adapter only for a concrete runner. A prompt that only says "keep going" is not a loop design. Give a run credentials only once LOOP.md defines its guards. The maker never verifies completion. Start every loop report-only.
Scope
Use for recurring or unattended work, including repairing an existing loop.
Do not use when:
- The job runs once: a plain session (ending with
verify-work, if installed) beats a one-iteration loop - The "loop" is multi-step work inside one session: that's a todo list, not a loop
- The job is vague: pin it first with
create-specwhen installed. A loop amplifies vague goals into scheduled mistakes. - The job only reads and reports within one session, or is a reminder: use the harness's loop or schedule command directly. Come back here when the job mutates anything, holds credentials, or runs unattended.
Required Context
- The job: what the loop discovers, what it may change, what "healthy" looks like
- The runner: a harness loop, CI schedule, or OS cron plus a headless CLI. Keep the design runner-agnostic.
- The budget reality: tolerable per-run cost and who reviews the output
Workflow
Load references/loop-formats.md before writing any artifact (templates, pattern table, runner mapping).
Repairing an existing loop? First ask the human to pause the schedule, or give them the exact command. Say what keeps happening until they do. Do not disable it yourself. Then read its files and state ledger. Map each failure to its missing guard:
- token burn → no budget;
- repeated failed fix → no breaker;
- duplicate branch or PR → no lock;
- unreviewed change → no gate or a self-written level.
Add the missing guards. Create LOOP.md or STATE.md when absent. Demote the loop to L1 and reset promotion counters. Then hand over through step 6.
-
Name a verifiable goal. Write the exact check a fresh verifier runs. Replace "keep CI green" with "latest main CI is green." Add an anti-gaming clause. For code, forbid deleted tests, weaker thresholds, and hidden failures. Translate the same risk for other domains.
Done when the condition and anti-gaming clause are written.
-
Design the run. Use triage → act → verify → persist → decide. Act only when triage finds actionable work. Give verification to another agent or the human gate. Never let the maker self-certify.
A deterministic check may verify a machine-checkable goal. The loop must hold no credential that can alter that checker. A human still reviews the anti-gaming diff.
End every run as verified-done, progress-with-state-written, or escalated. Any other ending is invalid.
Done when
LOOP.mdcontains the phases and three endings. -
Give it a spine. Make
STATE.mdanswer three questions:- What is active now?
- What was tried, and what happened?
- What awaits a human?
Read state before acting. Write it before every exit, especially failures.
Done when
STATE.mdcontains all three sections. -
Set all four guards explicitly in LOOP.md:
- Budget: Calculate worst-case run cost × cadence before choosing the schedule. Add a numeric per-run cap in iterations or tokens. If pricing is unknown, write
unknown. Keep the loop unscheduled at L1. Name the measurement needed before choosing cadence. Never invent a price. - Circuit breaker: Stop after two attempts at the same failure signature without progress. There is no third attempt. Count attempts within and across runs.
- Overlap lock: A run that finds the previous run alive exits at once and writes nothing. This is the only exit outside the three endings. A run that hits its budget cap ends escalated.
- Human gate: Name outcomes only a human may cause. Examples: main changes, data deletion, or user-visible publication. Name outcomes, not verbs: a list such as "never force-push" leaves every unlisted verb open. Below L3, enforce the gate by withholding credentials. For a read-only loop, gate any mutation or external publication.
nothing gatedis invalid.
Done when
LOOP.mdcontains all four guards. Monetary cost is numeric or explicitly unknown. - Budget: Calculate worst-case run cost × cadence before choosing the schedule. Add a numeric per-run cap in iterations or tokens. If pricing is unknown, write
-
Stage the rollout. Use L1 report-only → L2 assisted → L3 unattended. L3 may perform only actions outside the human gate. Require 5 consecutive clean runs before promotion. Only the independent verifier or human may certify a clean run. Start every loop at L1.
Keep
level:andclean-runs-at-level:inLOOP.mdonly; the loop rewritesSTATE.mdevery run, so a level stored there is one the loop can raise. The loop's credentials must not be able to writeLOOP.md: use branch protection, CODEOWNERS, or a read-only mount. Only the independent verifier or human edits those fields. Where the runner cannot enforce that, say so in the handover and treat a loop-written level as void.Done when
LOOP.mdcontains the ladder and counters. -
Hand over. Write the artifacts and runner adapter. Do not activate the loop: install no crontab entry, enable or push no schedule, and run no first cycle. The human starts it, so an unreviewed design never runs unattended. Implement guards as mechanisms. Use a concurrency group or pidfile for the lock. Use token scope for the gate. Put cadence in the runner schedule. State the human gate and L1 restriction.
Say the loop is not running yet. End with two commands for the human: one that starts the loop and one that stops it. With known cost, the start command enables the first scheduled L1 run. With unknown cost, leave the schedule out of the adapter; the start command is one manual report-only measurement run.
Done when the files exist, nothing is scheduled or running, and the start and stop commands are stated.
Example: goal, guard, ending
Goal: latest
mainCI run green; cycle diff shows no test deleted, skipped, or weakened. Breaker: same failure signature two runs running → escalate, both attempt diffs linked from STATE.md. Endings: green+verified → verified-done · fix pushed as PR → progress, state written · breaker tripped → escalated.
Pressure
Read references/pressure.md when urgency, authority, sunk cost, or an uncertain shortcut threatens the workflow. Those pressures do not waive its evidence or authority requirements.
Failure Modes
- The goal resists verifiability: the job isn't loop-shaped: it's a recurring reminder for a human. Say so instead of shipping a loop with a vibes-based stop condition.
- The breaker keeps tripping: the job is beyond the loop's reach (flaky infra, missing access). The escalation notes are the evidence; hand them to a human rather than widening the loop's permissions.
- Review bandwidth saturates: the ceiling is the human, not the tooling. Slow the cadence; never skip the gate.
Verification
Confirm the goal, four guards, state spine, independent verification, L1 rollout, and runnable handover. Unknown pricing leaves scheduling disabled.
04 同仓库更多 Skills
write-agent-instructions
Make the smallest evidence-backed change to persistent project instructions and test downstream behavior.
verify-work
Use when a finished, runnable artifact (a script, config, parser, prompt, or CLI, not a diff under review) must survive hostile input before shipping: the user asks to "verify this script", "find the loopholes", "test this properly against bad input", or asks "is this ready to ship" about one. Also when a shipped artifact failed on an input nobody tried, or when verification so far is a happy-path smoke test.
understand-codebase
Use when the user asks to "understand this codebase", "how does this feature work in this repo?", "trace this feature through the code", or needs onboarding, an architecture explanation, or answers about unfamiliar code. Also use for read-only code-path questions before a change.
tdd
Use when writing or changing production behavior: implementing a feature, fixing a bug whose cause is already known, or altering stored, transformed, migrated, serialized, or externally transmitted data. Also use when a user says "use TDD", "test first", or "red-green-refactor", and when code is being written before a failing test. For a failure whose cause is unknown, diagnose first.
simplify-code
Use when the user asks to "simplify this code", "remove the fluff", or "clean up this over-engineered module", or wants working code that is bloated, duplicated, over-abstracted, or dependency-heavy reduced without changing behavior.
review-session
Review an agent session for evidence-backed friction and the smallest measurable remedies.