Agentic Coding Loop
Use this when a coding task should move through a closed loop: understand the
spec, create or identify checks, implement the smallest slice, run evidence,
fix the root cause, and repeat until the acceptance criteria are met or the
loop hits a real blocker.
This is not a general instruction to "keep trying." The loop must be bounded,
observable, and grounded in checks that would catch the behavior users or
systems depend on.
Loop Contract
Before changing code, name:
- Goal: the user-visible or system-visible behavior that should change.
- Acceptance criteria: what must be true before the work can be called done.
- Evidence path: the tests, type checks, lint, API checks, browser checks,
or runtime probes that will prove the criteria.
- Budget: the maximum useful attempts, time, or escalation threshold.
- Authority boundary: actions the agent may take autonomously and actions
that require a human decision.
Derive acceptance criteria from the current governing spec, user request, and
observed behavior; use code and existing tests as evidence, not as the authority
for what the product should do. If criteria are missing, infer only a small,
unambiguous set. Ask for a high-impact missing decision while continuing
independent authorized work. A regression check should fail for the reported
bug and retain a valid positive control, rather than mirror the proposed fix.
The Loop
- Orient. Read the relevant code, docs, tests, issue, or spec. Identify the
existing patterns before adding a new one.
- Ratchet first when possible. If the task fixes a bug or adds observable
behavior, create the cheapest check that should fail before the change and
turn green after it. Use [[regression-ratchet]] and
[[feature-coverage-not-just-line-coverage]] when they apply.
- Implement the smallest coherent slice. Prefer one behavior change over a
broad refactor. Keep mechanical cleanup separate from logic changes.
- Run the nearest checks. Start with fast local checks, then escalate to
integration, browser, API, or live verification when the behavior depends on
those surfaces.
- Inspect failures. Treat failing checks as signal. Read the actual error,
identify the root cause, and make the smallest correction that explains it.
- Repeat with memory of prior attempts. Each iteration must use evidence
from the previous one. Do not rerun the same failing command without a code,
data, environment, or hypothesis change.
- Close with evidence. Report what changed, which artifacts were checked,
which commands or live paths verified it, and any remaining gaps.
Verification Ladder
Use the cheapest layer that can actually prove the claim:
| Claim |
Minimum useful evidence |
| Pure code behavior |
Unit or behavior test that names the behavior |
| Type or interface contract |
Type check, schema check, or contract test |
| Cross-module flow |
Integration test or fixture that spans the boundary |
| UI behavior |
Browser check, screenshot, or interaction trace |
| API behavior |
Request/response check against the target environment |
| Runtime or deployment state |
Real artifact check, rollout state, or service probe |
Passing a lower layer does not prove a higher-layer claim. A green unit test
does not prove a browser flow works; a successful build does not prove the
deployed artifact changed. Use [[verify-real-artifact]] and
[[process-aware-done]] for final claims.
Continuous Backlog Handoff
In a multi-worker backlog, hand the tested PR, exact head, acceptance evidence,
and gaps to the existing PR shepherd. That role owns review, CI, conflicts,
qualified merges, and post-merge verification; the worker may take the next
disjoint authorized slice within the WIP limit. One PR's CI wait does not stall
unrelated workers. Preserve holds and repository-required checks, and use
[[verify-delegated-work]] for policy-permitted exact-artifact evidence reuse.
PR handoff alone does not complete acceptance that requires merge or runtime proof.
Stop Conditions
Stop and report success only when:
- acceptance criteria are satisfied;
- evidence came from the right layer for the claim;
- the final diff is scoped to the task; and
- any follow-up is genuinely separate from the shipped behavior.
Stop and escalate as blocked when:
- required credentials, dependencies, data, or environment access are missing;
- the same failure repeats after a bounded number of distinct hypotheses;
- the task requires a product, security, legal, financial, or operational
decision outside the agent's authority;
- the implementation would exceed the agreed scope; or
- verification cannot be made independent of the implementation.
Call a partial result "partial" or "blocked." Do not upgrade it to done because
time ran out or the latest command looked promising.
Output Shape
Use this compact closeout:
Change: <what changed>
Evidence: <checks or live paths run>
Result: <succeeded, partial, or blocked>
Gaps: <none or explicit remaining uncertainty>
Next: <only if a separate follow-up is warranted>
Anti-Patterns
- Iterating without an acceptance criterion or budget.
- Treating retries as progress when no hypothesis changed.
- Adding broad refactors inside a behavior loop.
- Accepting proxy evidence for a user-visible claim.
- Creating tests that only assert the implementation detail you just wrote.
- Continuing autonomously after the loop crosses a human decision boundary.
1---2name: agentic-coding-loop3description: Use when implementing code from a spec through a bounded build-test-fix loop with explicit acceptance criteria, automated checks, live verification when needed, and clear stop conditions.4metadata:5 source: https://skillmd.com/skills/selamy-labs/agentic-coding-loop6---78# Agentic Coding Loop910Use this when a coding task should move through a closed loop: understand the11spec, create or identify checks, implement the smallest slice, run evidence,12fix the root cause, and repeat until the acceptance criteria are met or the13loop hits a real blocker.1415This is not a general instruction to "keep trying." The loop must be bounded,16observable, and grounded in checks that would catch the behavior users or17systems depend on.1819## Loop Contract2021Before changing code, name:2223- **Goal:** the user-visible or system-visible behavior that should change.24- **Acceptance criteria:** what must be true before the work can be called done.25- **Evidence path:** the tests, type checks, lint, API checks, browser checks,26 or runtime probes that will prove the criteria.27- **Budget:** the maximum useful attempts, time, or escalation threshold.28- **Authority boundary:** actions the agent may take autonomously and actions29 that require a human decision.3031Derive acceptance criteria from the current governing spec, user request, and32observed behavior; use code and existing tests as evidence, not as the authority33for what the product should do. If criteria are missing, infer only a small,34unambiguous set. Ask for a high-impact missing decision while continuing35independent authorized work. A regression check should fail for the reported36bug and retain a valid positive control, rather than mirror the proposed fix.3738## The Loop39401. **Orient.** Read the relevant code, docs, tests, issue, or spec. Identify the41 existing patterns before adding a new one.422. **Ratchet first when possible.** If the task fixes a bug or adds observable43 behavior, create the cheapest check that should fail before the change and44 turn green after it. Use [[regression-ratchet]] and45 [[feature-coverage-not-just-line-coverage]] when they apply.463. **Implement the smallest coherent slice.** Prefer one behavior change over a47 broad refactor. Keep mechanical cleanup separate from logic changes.484. **Run the nearest checks.** Start with fast local checks, then escalate to49 integration, browser, API, or live verification when the behavior depends on50 those surfaces.515. **Inspect failures.** Treat failing checks as signal. Read the actual error,52 identify the root cause, and make the smallest correction that explains it.536. **Repeat with memory of prior attempts.** Each iteration must use evidence54 from the previous one. Do not rerun the same failing command without a code,55 data, environment, or hypothesis change.567. **Close with evidence.** Report what changed, which artifacts were checked,57 which commands or live paths verified it, and any remaining gaps.5859## Verification Ladder6061Use the cheapest layer that can actually prove the claim:6263| Claim | Minimum useful evidence |64| --- | --- |65| Pure code behavior | Unit or behavior test that names the behavior |66| Type or interface contract | Type check, schema check, or contract test |67| Cross-module flow | Integration test or fixture that spans the boundary |68| UI behavior | Browser check, screenshot, or interaction trace |69| API behavior | Request/response check against the target environment |70| Runtime or deployment state | Real artifact check, rollout state, or service probe |7172Passing a lower layer does not prove a higher-layer claim. A green unit test73does not prove a browser flow works; a successful build does not prove the74deployed artifact changed. Use [[verify-real-artifact]] and75[[process-aware-done]] for final claims.7677## Continuous Backlog Handoff7879In a multi-worker backlog, hand the tested PR, exact head, acceptance evidence,80and gaps to the existing PR shepherd. That role owns review, CI, conflicts,81qualified merges, and post-merge verification; the worker may take the next82disjoint authorized slice within the WIP limit. One PR's CI wait does not stall83unrelated workers. Preserve holds and repository-required checks, and use84[[verify-delegated-work]] for policy-permitted exact-artifact evidence reuse.85PR handoff alone does not complete acceptance that requires merge or runtime proof.8687## Stop Conditions8889Stop and report success only when:9091- acceptance criteria are satisfied;92- evidence came from the right layer for the claim;93- the final diff is scoped to the task; and94- any follow-up is genuinely separate from the shipped behavior.9596Stop and escalate as blocked when:9798- required credentials, dependencies, data, or environment access are missing;99- the same failure repeats after a bounded number of distinct hypotheses;100- the task requires a product, security, legal, financial, or operational101 decision outside the agent's authority;102- the implementation would exceed the agreed scope; or103- verification cannot be made independent of the implementation.104105Call a partial result "partial" or "blocked." Do not upgrade it to done because106time ran out or the latest command looked promising.107108## Output Shape109110Use this compact closeout:111112```text113Change: <what changed>114Evidence: <checks or live paths run>115Result: <succeeded, partial, or blocked>116Gaps: <none or explicit remaining uncertainty>117Next: <only if a separate follow-up is warranted>118```119120## Anti-Patterns121122- Iterating without an acceptance criterion or budget.123- Treating retries as progress when no hypothesis changed.124- Adding broad refactors inside a behavior loop.125- Accepting proxy evidence for a user-visible claim.126- Creating tests that only assert the implementation detail you just wrote.127- Continuing autonomously after the loop crosses a human decision boundary.