Agent skill · Testing & QA

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 (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.

agentsopegithub.com/agentsopeGitHub ↗
claude-codeMIT
Install
npx skills add agentsope/SkillAlchemy --skill agentsop-test-fix-loop --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 5
SKILL.md size: 28 KB
Bundled scripts: none
Version: 0.1.0
Path: skills/agentsop-test-fix-loop/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 255
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Wires a verify-then-fix loop around a code-editing LLM agent. The agent edits, runs lint/test, reads the verifier output, applies fixes, and re-runs, bounded by an iteration cap and escalation rules. Activates when a coder agent has a verifiable success criterion (exit code, type-checker output, failing assertion) and the user wants convergence to green. Works framework-agnostic by wrapping various tooling chains (auto-lint/auto-test, SWE-Bench loop, LangGraph, Claude Code bash tool).

How it works

Follows a workflow with five steps:

  • Step 1: Wire the verifier command by selecting a fast-to-slow sequence (format, lint, type, test, build) and binding lint and test commands into one shell command.
  • Step 2: Capture stdout, stderr, and exit_code from the verifier run; always capture all streams and set NO_COLOR=1; include a timeout.
  • Step 3: Format the verifier feedback into a concise, hard-cap digest (≤2k tokens) highlighting the first failure, last traceback frame, and anchor to the changed file/lines, with a hypothesis.
  • Step 4: Bound the iterations with a hard cap (MAX_ITERS) and stall detection (same error twice triggers early exit); commit after each edit.
  • Step 5: Per-iteration commit using a structured message: git commit -am "agent[iter N]: <one-line>" to keep an auditable history.
  • Step 6: Detect success precisely via signals like exit 0 with no diagnostics, or exit 0 with warnings; handle false positives (no tests, swallowed commands) accordingly.
  • Step 7: Escalate or commit on exit, surface the last feedback, and tag the escalation reason (exhausted, stalled, env_failure, timeout).

When to use it

Use when there is a verifiable success command (pytest, ruff, mypy, eslint, tsc, go test, cargo check) and the goal is to have the agent converge to green, including SWE-Bench-style runs or CI guardrails requiring green before completion. Do not use when success is subjective, verifier is slow/interactive, human review gates the process, or edits are exploratory.

What it can touch

The skill relies on tools such as the verifier commands (lint/test), a shell or subprocess interface, and git for per-iteration commits. It references the use of commands like aider --auto-lint --lint-cmd "ruff check ." --auto-test --test-cmd "pytest -x --tb=short" and concrete subprocess invocations in Python illustrating how to capture stdout, stderr, and exit_code. It uses file anchors from git diffs and formatting of verifier messages but does not expose additional external touch points beyond those described commands.

Caveats

The protocol depends on a reliable verifier signal (exit_code or parseable output). It requires an explicit iteration cap (MAX_ITERS) and an escalation path if the loop cannot converge. It emphasizes not feeding raw verifier output; it requires formatting into a focused digest. The approach assumes environment availability for commands and that per-iteration commits are possible; it warns about false positives (e.g., tests skipped, swallowed exit codes). The skill itself licenses as MIT and is framework-agnostic, wrapping various toolchains as described.

From the SKILL.md

# 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 *

What's inside
Steps it walks through
  1. 1. 何时激活 (Activation Rules)
  2. 2. 核心心智模型 (Core Mental Model)
  3. 2.1 The test result IS the next prompt
  4. 2.2 Four primitives
  5. 2.3 Why a separate skill (vs "just give the agent a bash tool")
  6. 2.4 What "green" means
  7. 3. SOP 工作流 (Agentic Protocol)
  8. Step 1 · Wire the verifier command
  9. Step 2 · Capture stdout + stderr + exit code (all three)
  10. Step 3 · Format the feedback message (the load-bearing step)
  11. Step 4 · Bound the iterations
  12. Step 5 · Per-iteration commit (the audit lever)
  13. Step 6 · Detect success precisely
  14. Step 7 · Escalate or commit on exit
Ships with 4 files
  • README.md
  • intermediate/operation_candidates.json
  • references/R1-source-material.md
  • references/R2-feedback-formatting-recipes.md
Commands it runs
aider --auto-lint --lint-cmd "ruff check ." \
git log -p $(git merge-base HEAD origin/main)..HEAD -- '*.py' \
More from SkillAlchemy
All skills →
About this skill
What does the agentsop-test-fix-loop skill do?

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.

How do I install it?

Run `npx skills add agentsope/SkillAlchemy --skill agentsop-test-fix-loop --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From agentsope/SkillAlchemy, a repository with 255 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going