agentleFS
rgaddargadda/frontend-eng-team/skills/loop-engineering/SKILL.md

loop-engineering

Skill8 starsChanged 4 months agoMITView on GitHub

Load this when authoring or editing an agent role, subagent, or slash command that needs a self-critique / iterate / converge inner loop. Documents the Refine-Critique-Converge (RCC) pattern used by every role in .agents/roles/. Triggers — "add self-critique", "add RCC loop", "iterate the plan", "loop engineering", "agent should refine", "critique its own output".

36 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use aegis-gateway, deploy-vercel-render and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • vpeetla-aiSkill

    aegis-gateway

    Integrate AegisAI gateway before tool side effects (notify, publish, deploy). Use when adding Slack/Telegram/WhatsApp notify, content publish, or any irreversible external action in VAP, AegisLoop, or ai-content-factory.

    Also in 6 projects that use this

  • vpeetla-aiSkill

    deploy-vercel-render

    Deploy vpeetla-ai demos: Vercel static/Next.js frontends, Render FastAPI backends, env vars, free tier gotchas. Use when shipping demos, fixing deploy failures, or adding render.yaml / vercel.json.

    Also in 6 projects that use this

  • HermeticOrmusSkill

    langgraph-orchestration

    LangGraph stateful multi-agent graphs with categorical coordination patterns and cyclic workflows. Use when building stateful AI agent systems, implementing multi-agent orchestration with conditional routing, creating cyclic workflows with persistence, or designing graph-based AI pipelines with checkpointing and human-in-the-loop patterns.

    Also in 6 projects that use this

  • junimnjwSkill

    agentic-engineering

    Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing.

    Also in 7 projects that use this

  • +8 more from vpeetla-ai

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 31 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every check must be answerable from the artifact alone: If the check requires reading external files, it belongs in a downstream phase's …

    line 70
  2. Distinctive:

    If a role hits its RCC cap without convergence, the outer loop can still attempt another pass (with a new spec — usually the Verifier's …

    line 82
  3. Distinctive:

    If you want to track how much RCC is costing you on a branch:

    line 101
  4. Distinctive:

    If a role is hitting iteration 3 often, its RCC checklist may be too strict (oscillating) or the upstream spec may be too vague (unfixable …

    line 112

“Common” is measured: kept by at least 6 in 10 of the 31 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Loop Engineering — the RCC pattern

Loop engineering treats iteration as a first-class part of an agent's contract, not an emergent behavior. Every role in this repo uses the same Refine-Critique- Converge (RCC) pattern for its inner loop. This skill is the reference for how to add or modify one.

What RCC is

An agent produces → self-critiques against a phase-specific checklist → refines only the parts flagged CRITICAL → repeats, bounded to 3 iterations. On convergence (no CRITICAL, or no delta from prior iteration, or 3-iteration cap hit) it emits the final artifact plus a compact iteration log.

Why RCC and not "keep iterating"

  • Bounded. 3-iteration cap prevents runaway cost. If the agent cannot converge in 3 passes, the problem is upstream (bad spec, missing context) and further iteration will not fix it — hand back to the human.
  • Same-context. RCC runs inside the same phase's context window. No new agent is spawned. This is the cheapest form of loop engineering.
  • Targeted. Iterations 2 and 3 revise only sections flagged CRITICAL, not the whole artifact. Full rewrites erode the cache and re-introduce bugs.
  • Auditable. Each iteration appends a JSONL record with status: "draft" or "final". You can see the convergence trajectory after the fact.

The template (paste this into a new role)

## Refine-Critique-Converge (RCC) loop

You produce, self-critique, and refine — bounded to 3 iterations.

**Iteration 1** — produce the artifact in the required format.

**Self-critique** — before printing, walk this checklist against your draft.
Any CRITICAL item requires a revision pass.

- CRITICAL: <phase-specific check 1>
- CRITICAL: <phase-specific check 2>
- CRITICAL: <phase-specific check 3>
- RECOMMENDED: <check that's nice-to-have but not blocking>

**Iteration 2** — if any CRITICAL, revise only the affected sections and
re-critique.

**Iteration 3** — final pass. If a CRITICAL remains after 3 iterations, print
the artifact with an "RCC unresolved" note at the top listing open CRITICALs.
Do not loop further — hand off to the human.

Append one JSONL record per iteration to `.agents/memory/<file>.jsonl` via
`.agents/memory/append.sh` (`status: "draft"` for iterations 1-2, `status:
"final"` on the last).

Choosing checklist items

The checklist is the entire ballgame — a good checklist makes RCC valuable, a bad one makes it noise. Rules:

  • CRITICAL only for correctness-blocking items — things that make the artifact wrong or unshippable. Style preferences do not belong here.
  • 3-6 CRITICALs, max. More than that and the agent will oscillate.
  • Every check must be answerable from the artifact alone. If the check requires reading external files, it belongs in a downstream phase's check, not RCC.
  • Prefer specific over general. "No any types introduced?" beats "Types are correct?" — the former is grep-able, the latter is vibes.

Interaction with the outer FAIL loop

The pipeline has an outer Verifier→Implementer FAIL loop, also capped at 3. RCC is the inner loop.

  • RCC iterations do not count against the outer loop cap.
  • If a role hits its RCC cap without convergence, the outer loop can still attempt another pass (with a new spec — usually the Verifier's priority list).
  • Combined cap: at most 3 outer × 3 RCC = 9 iterations per role per branch. In practice, most work converges in 1-2 outer × 1-2 RCC.

When NOT to add RCC

  • Read-only subagents (repo-explorer, frontend-reviewer, prod-readiness) that produce a single structured output already do a focused pass. Adding RCC would just double their cost. Their "critique" is the downstream role that reads their output.
  • Bash / tool-running subagents (test-runner, verifier) — the tool result IS the ground truth. Re-running tests to "self-critique" is not loop engineering, it's just retry.
  • PM-clarify and other one-shot skills — no artifact to converge on.

Cost telemetry

If you want to track how much RCC is costing you on a branch:

BR="$(git rev-parse --abbrev-ref HEAD)"
for f in .agents/memory/*.jsonl; do
  echo "$f:"
  grep "\"branch\":\"$BR\"" "$f" 2>/dev/null | \
    awk -F'"iteration":' '{split($2, a, ","); print "  iteration " a[1]}'
done

If a role is hitting iteration 3 often, its RCC checklist may be too strict (oscillating) or the upstream spec may be too vague (unfixable in-role).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.