Skip to content

Loop Engineering

Loop Engineering, a skill for designing & reviewing autonomous/semi-autonomous agent loops (Claude Code, Codex, Copilot, Gemini).

Install: git clone https://github.com/maxmilian/loop-engineering

Works with Claude Code, Codex, GitHub Copilot · 29 GitHub stars

Install

$git clone https://github.com/maxmilian/loop-engineering

Install command taken from the project's README or registry entry. Always review code before running it.

English · 繁體中文 · 简体中文 · 日本語 · 한국어

Loop Engineering — a skill for designing & reviewing autonomous agent loops

Loop engineering is the discipline that comes after prompt engineering. A prompt optimizes a single interaction; a loop optimizes the autonomous behavior that surrounds it — when an agent runs, what triggers it, how it verifies its own work, when it stops, and when it hands back to a human.

This skill gives a coding agent a battle-tested framework for two jobs:

  • Design mode — build a new self-running agent / loop / background worker.
  • Review mode — audit an existing loop's stopping conditions, guardrails, verification, and escalation paths.

It distills 12 sources (Anthropic's context-engineering guidance, the Ralph loop / RPI methodology, Claude Code's agent-loop docs, and the 2026 "loop engineering" writing) into seven load-bearing principles plus reference material.

Quick start (Claude Code):

git clone https://github.com/maxmilian/loop-engineering ~/.claude/skills/loop-engineering

Start a new session — that's it. (Other tools: Install.)

In benchmark testing against a no-skill baseline on deliberately tricky cases, the skill raised the pass rate from 87% → 100% while producing more consistent, cheaper answers — its edge shows up on the subtle failure modes a strong model otherwise misses (cron stale-prompt drift, blind-retry waste, missing human-gates on irreversible actions). Reproduce it →

On a weaker model (Haiku class) the lift is far larger — +16 points (74% → 90% on an 8-case subset) — which is exactly where a coverage guarantee matters most.

The seven principles (TL;DR)

  1. Leverage moved from the prompt to the loop — design the control flow, not one mega-prompt.
  2. "Done" must be machine-checkable — tests pass ✓, improve the code ✗.
  3. Verify with deterministic tools, never the agent's self-report.
  4. Define all exits before going live — success / failure / budget exits, no-progress detection, escalation path.
  5. Treat context as a finite resource — trim tool outputs; use compaction, note-taking, sub-agents.
  6. Use the filesystem as memory; start each cycle with fresh context.
  7. The hard part is verification, stopping, and escalation — not autonomy. Prefer semi-autonomous: gate irreversible/outward actions behind a human.

What's in here

loop-engineering/
├── SKILL.md                          # the skill itself (frontmatter + instructions)
├── references/
│   ├── loop-patterns.md              # heartbeat / cron / hook / goal + Ralph loop
│   ├── context-engineering.md        # compaction, note-taking, sub-agents, JIT retrieval
│   ├── review-checklist.md           # per-principle diagnostic, severity-ordered
│   └── sources.md                    # the 12 source articles, with one-line summaries
├── evals/                            # validation case library + benchmark evidence
│   ├── evals.json                    # 11 graded design / review / diagnose cases
│   ├── RESULTS.md                    # with-skill vs no-skill results, 3 iterations
│   └── files/                        # input scripts the review cases point at
└── assets/                           # README hero image

Similar plugs

Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable knowledge graph. A /graphify skill for Claude Code, Cursor, Codex, and Gemini CLI: local…

Why use many token when few token do trick. Viral skill + proxy for coding agents that cuts 65% of tokens by talking like a caveman.

Persistent Context Across Sessions for Every Agent, Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future…

Explore related