/agentsop-test-fix-loop
Decision protocol for wiring a verify-then-fix loop around a code-editing LLM agent. The agent edits → runs lint/test → reads the output → fixes → re-runs, bounded by an iteration cap and an escalation rule. Activates whenever a coder agent has a verifiable success criterion
$ npx -y skills add agentsope/SkillAlchemy --skill agentsop-test-fix-loop --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/agentsop-test-fix-loop
Context preview
The summary Claude sees to decide when to auto-load this skill.
Decision protocol for wiring a verify-then-fix loop around a code-editing LLM agent. The agent edits → runs lint/test → reads the output → fixes → re-runs, bounded by an iteration cap and an escalation rule. Activates whenever a coder agent has a verifiable success criterion
SKILL.md
agentsop-test-fix-loop.SKILL.mdname: agentsop-test-fix-loop
version: 0.1.0
description: |
Decision protocol for wiring a verify-then-fix loop around a code-editing LLM
agent. The agent edits → runs lint/test → reads the output → fixes → re-runs,
bounded by an iteration cap and an escalation rule. Activates whenever a coder
agent has a verifiable success criterion (exit code, type-checker output,
failing assertion) and the user wants the agent to converge to "green" on its
own. Framework-agnostic — wraps Aider's `--auto-lint`/`--auto-test`, an
OpenHands SWE-Bench loop, a manual LangGraph cycle, or Claude Code's bash
tool just the same.
domain: coder-agent / tool-result-feedback
audience: engineers wiring LLM agents that must converge on a verifiable spec
trigger_keywords:
- "auto-lint"
- "auto-test"
- "test-fix loop"
- "fix until tests pass"
- "verify-then-fix"
- "iterate until green"
- "agent feedback loop"
- "iteration cap"
when_to_use:
- "any code-edit flow with a verifiable success command (pytest, ruff, mypy, eslint, tsc, go test, cargo check)"
- "wrapping a coding agent so it doesn't return until lint+tests are clean"
- "SWE-Bench-style runs (one issue → patch → tests → fix → submit)"
- "CI guardrail where a PR must be green before the agent declares done"
when_not_to_use:
- "the success criterion is subjective ('looks good') — there's no signal to feed back"
- "the verifier takes >5 min and you need the agent interactive — async the loop"
- "human review is the gate (use HITL skill instead)"
- "edits are exploratory / WIP — the loop will fight the user's incomplete code"Test-Fix Loop · SOP
> One-liner: **The test result IS the next prompt.** Wiring the verifier is > 20% of the work; framing its output as a useful feedback message is 80%.
---
1. 何时激活 (Activation Rules)
Activate this skill when **any** of the following triggers fire:
- The user says "have the agent fix until tests pass", "run lint and tests
automatically", "iterate until green", or invokes `aider --auto-test`, `cline --yes`, or an OpenHands-style headless agent.
- The task has a **verifiable success command**: a non-zero exit code on
failure (pytest, ruff, mypy, eslint, tsc, go test, cargo check, npm run build, make check, …).
- You're wrapping a code-editing LLM in a script/CI step and need to decide:
*when does the agent return?*
- The agent just made an edit and the next message in the loop would be
"here's what the verifier said".
**Do not activate** when:
- Success is **subjective** (writing prose, designing UX). The loop has no
feedback signal worth replaying.
- The verifier is **slow + interactive** (full E2E suite, multi-min builds).
Either async-ify the loop, or run a fast subset (`pytest -x -k changed`) in the loop and gate the slow suite at PR review.
- The gate is **human approval**, not a machine check — use the HITL skill.
---
2. 核心心智模型 (Core Mental Model)
2.1 The test result IS the next prompt
The agent's *next turn* is conditioned almost entirely on the message you inject between edit-N and edit-N+1. That message — formatted from `stdout`, `stderr`, `exit_code` — **is the prompt**. The framework labels it "tool result" or "verifier output" but mechanically it is a user-role message the LM consumes verbatim.
⇒ **Framing the feedback dominates the model choice.** A 4000-line raw pytest dump prompts a worse fix than a 30-line "first failing test, traceback, the diff you just applied" digest, *regardless of the model behind it*.
2.2 Four primitives
+-----------------+ +-----------------+ +-----------------+ +-----------------+
| 1. Verifier | | 2. Capture | | 3. Format | | 4. Iteration |
| command | | (stdout + | | feedback | | bound |
| | | stderr + | | message | | |
| - pytest -x | | exit_code) | | - first error | | - max N tries |
| - ruff check | | - timeout cap | | - last K lines | | - escalate / |
| - mypy --strict | | - byte cap | | - drop noise | | commit / skip |
| - eslint . | | - kill on hang | | - keep colors=0 | | |
+-----------------+ +-----------------+ +-----------------+ +-----------------+
Drop any one of these and the loop fails:
- No verifier → no signal; the agent guesses "done".
- No capture → the model can't read stderr; tracebacks live in stderr.
- No formatting → 25k-token output distracts the model
(see Aider's 25k context-drift threshold).
- No iteration bound → infinite loop; the OpenHands SWE-Bench infinite-loop
bug `[oh/6357]` is the canonical failure case.
2.3 Why a separate skill (vs "just give the agent a bash tool")
Naively: "let the agent run `pytest` and read the output". This breaks because:
1. The agent doesn't know **which** command to run (project-specific). 2. The agent dumps the **full output** into context every iteration, blowing the 25k threshold by iter 3. 3. The agent has **no termination contract** — it'll keep trying after the test passes "to be safe", or keep trying after 30 failures "to be helpful". 4. The agent makes **edits with no audit trail** — if iter 4 was the right fix, you can't bisect because nothing is committed.
The loop is a contract: *verifier wiring + output capture + feedback framing
- iteration cap + per-fix git commit*. Treat it as one operation, not five.
2.4 What "green" means
| Verifier returns | Interpretation | Next action | |---|---|---| | `exit 0`, no diagnostics | True success | Commit + exit loop | | `exit 0`, warnings | Soft success | Commit + log; optionally surface to user | | `exit != 0`, parseable error | Actionable failure | Format → feed back → next iter | | `exit != 0`, unparseable (e.g. segfault, OOM) | Environment / infra failure | Escalate; do not re-prompt the LM | | Timeout / hang | Likely infinite loop in
Read more
name: agentsop-test-fix-loop
version: 0.1.0
description: |
Decision protocol for wiring a verify-then-fix loop around a code-editing LLM
agent. The agent edits → runs lint/test → reads the output → fixes → re-runs,
bounded by an iteration cap and an escalation rule. Activates whenever a coder
agent has a verifiable success criterion (exit code, type-checker output,
failing assertion) and the user wants the agent to converge to "green" on its
own. Framework-agnostic — wraps Aider's `--auto-lint`/`--auto-test`, an
OpenHands SWE-Bench loop, a manual LangGraph cycle, or Claude Code's bash
tool just the same.
domain: coder-agent / tool-result-feedback
audience: engineers wiring LLM agents that must converge on a verifiable spec
trigger_keywords:
- "auto-lint"
- "auto-test"
- "test-fix loop"
- "fix until tests pass"
- "verify-then-fix"
- "iterate until green"
- "agent feedback loop"
- "iteration cap"
when_to_use:
- "any code-edit flow with a verifiable success command (pytest, ruff, mypy, eslint, tsc, go test, cargo check)"
- "wrapping a coding agent so it doesn't return until lint+tests are clean"
- "SWE-Bench-style runs (one issue → patch → tests → fix → submit)"
- "CI guardrail where a PR must be green before the agent declares done"
when_not_to_use:
- "the success criterion is subjective ('looks good') — there's no signal to feed back"
- "the verifier takes >5 min and you need the agent interactive — async the loop"
- "human review is the gate (use HITL skill instead)"
- "edits are exploratory / WIP — the loop will fight the user's incomplete code"Test-Fix Loop · SOP
> One-liner: **The test result IS the next prompt.** Wiring the verifier is > 20% of the work; framing its output as a useful feedback message is 80%.
---
1. 何时激活 (Activation Rules)
Activate this skill when **any** of the following triggers fire:
- The user says "have the agent fix until tests pass", "run lint and tests
automatically", "iterate until green", or invokes `aider --auto-test`, `cline --yes`, or an OpenHands-style headless agent.
- The task has a **verifiable success command**: a non-zero exit code on
failure (pytest, ruff, mypy, eslint, tsc, go test, cargo check, npm run build, make check, …).
- You're wrapping a code-editing LLM in a script/CI step and need to decide:
*when does the agent return?*
- The agent just made an edit and the next message in the loop would be
"here's what the verifier said".
**Do not activate** when:
- Success is **subjective** (writing prose, designing UX). The loop has no
feedback signal worth replaying.
- The verifier is **slow + interactive** (full E2E suite, multi-min builds).
Either async-ify the loop, or run a fast subset (`pytest -x -k changed`) in the loop and gate the slow suite at PR review.
- The gate is **human approval**, not a machine check — use the HITL skill.
---
2. 核心心智模型 (Core Mental Model)
2.1 The test result IS the next prompt
The agent's *next turn* is conditioned almost entirely on the message you inject between edit-N and edit-N+1. That message — formatted from `stdout`, `stderr`, `exit_code` — **is the prompt**. The framework labels it "tool result" or "verifier output" but mechanically it is a user-role message the LM consumes verbatim.
⇒ **Framing the feedback dominates the model choice.** A 4000-line raw pytest dump prompts a worse fix than a 30-line "first failing test, traceback, the diff you just applied" digest, *regardless of the model behind it*.
2.2 Four primitives
+-----------------+ +-----------------+ +-----------------+ +-----------------+ | 1. Verifier | | 2. Capture | | 3. Format | | 4. Iteration | | command | | (stdout + | | feedback | | bound | | | | stderr + | | message | | | | - pytest -x | | exit_code) | | - first error | | - max N tries | | - ruff check | | - timeout cap | | - last K lines | | - escalate / | | - mypy --strict | | - byte cap | | - drop noise | | commit / skip | | - eslint . | | - kill on hang | | - keep colors=0 | | | +-----------------+ +-----------------+ +-----------------+ +-----------------+
Drop any one of these and the loop fails:
- No verifier → no signal; the agent guesses "done".
- No capture → the model can't read stderr; tracebacks live in stderr.
- No formatting → 25k-token output distracts the model
(see Aider's 25k context-drift threshold).
- No iteration bound → infinite loop; the OpenHands SWE-Bench infinite-loop
bug `[oh/6357]` is the canonical failure case.
2.3 Why a separate skill (vs "just give the agent a bash tool")
Naively: "let the agent run `pytest` and read the output". This breaks because:
1. The agent doesn't know **which** command to run (project-specific). 2. The agent dumps the **full output** into context every iteration, blowing the 25k threshold by iter 3. 3. The agent has **no termination contract** — it'll keep trying after the test passes "to be safe", or keep trying after 30 failures "to be helpful". 4. The agent makes **edits with no audit trail** — if iter 4 was the right fix, you can't bisect because nothing is committed.
The loop is a contract: *verifier wiring + output capture + feedback framing
- iteration cap + per-fix git commit*. Treat it as one operation, not five.
2.4 What "green" means
| Verifier returns | Interpretation | Next action | |---|---|---| | `exit 0`, no diagnostics | True success | Commit + exit loop | | `exit 0`, warnings | Soft success | Commit + log; optionally surface to user | | `exit != 0`, parseable error | Actionable failure | Format → feed back → next iter | | `exit != 0`, unparseable (e.g. segfault, OOM) | Environment / infra failure | Escalate; do not re-prompt the LM | | Timeout / hang | Likely infinite loop in
Other skills on skillalchemy.
- /LEAP
LEAP — 落地执行引擎。内含两条管线:A 分支蒸馏(从 raw data 提取 skill)、 B 分支融合(多 skill 编织为一个)。被 SkillAlchemy 编排器调用。 Use when 编排器判断需要蒸馏或融合时。
Open skill - /Lens
Lens — 给你的问题加一层认知镜片。输入任意任务描述,输出增强版 description, 发现「你不知道自己不知道」的隐性维度、前置条件和认知路线。 Use when 用户说「帮我想想」「分析一下」「生成 skill」「蒸馏」「融合」 或输入看起来太简单需要展开。
Open skill - /agentsop-agent-topology-selection
Cross-framework enhancement overlay for choosing a multi-agent topology BEFORE writing any agent. A binary-question rubric — is single-agent + tools enough? do agents need to know about each other? does the output need one voice? — maps the answer to single-agent / supervisor /
Open skill - /agentsop-aider
SOP for terminal-based, git-native AI pair programming with Aider (git work-tree + tree-sitter repo-map + edit-format + human-in-loop REPL). Use when editing code in an existing git repo via an LLM, when you need to converge a change to 2-5 files, pick an edit format that fits
Open skill - /agentsop-bio-fraud-forensics
Screens biomedical / life-science papers for signs of data fabrication, image manipulation, and statistical anomalies, using the detection techniques distilled from the field's canonical exposure platforms (PubPeer, Data Colada, Science Integrity Digest, For Better Science) and
Open skill - /agentsop-bounded-loop
Universal discipline for any LM-driven loop — agent retries, plan-act-observe, multi-agent handoffs, optimiser passes, test-fix cycles. Encodes the one rule every framework documents quietly and every team relearns expensively: the LM in the loop is NEVER a reliable terminator.
Open skill

