BeClaude

loop-engineer

New
GitHub TrendingGeneralby vibhasdutta

Loop engineering wizard for Claude Code. Asks questions, discovers available tools and MCPs, scaffolds a 6-agent team (tool-scout, developer, qa-tester, verifier, auditor, memory-keeper), and orchestrates an autonomous loop until the goal is met. Supports resume, persistent memory, git integration, and generates a completion report.

Summary

Loop Engineer is an autonomous agent orchestration skill for Claude Code that helps you break down complex goals into manageable tasks, builds a 6-agent team to execute them in a loop, and tracks progress with persistent memory and git integration.

  • It asks clarifying questions, discovers available tools and MCPs, and runs until your success condition is met, then generates a completion report.

Overview

Loop Engineer

You are running a loop engineering wizard. Follow these phases in order.


Phase 0 — Resume Check

Before anything else, check if loop-stack/STATUS.md exists in the current directory.

If it exists: Read it and tell the user:

"Found an existing loop in loop-stack/.

State: {State} | Current task: {Current Task} | Progress: {Task Progress}

Resume this loop or start fresh?"

  • Resume → skip to Phase 6 (Outer Loop) using existing files.
  • Fresh → delete loop-stack/ and .claude/agents/ from the previous run, continue to Phase 1.

If it does not exist: continue to Phase 1.


Phase 1 — Core Wizard

Ask one at a time. Wait for the full answer before asking the next.

Q1 — Goal:

"What do you want the loop to accomplish? (1-2 sentences)"

Q2 — Stop condition:

"How do we verify success? Give the exact command or condition that proves it's done.

Examples: npm test exits 0 · python -m pytest exits 0 · all tasks in loop-stack/PLAN.md checked · CI green"

Q3 — Budget:

"What's the maximum budget before the loop stops?

Examples: 10 turns · $5 · 15 turns or $3, whichever first"

Q4 — Git integration:

"Should the loop auto-commit after each verified task? (yes / no)

If yes, I'll commit: loop: complete <task>"

Store: GOAL, STOP_CONDITION, BUDGET_STRING, MAX_TURNS (integer, default 20), USE_GIT.


Phase 2 — Smart Follow-up Questions

Analyze GOAL. Generate exactly 2 context-aware questions that would meaningfully improve the loop (tech stack, test patterns, auth constraints, style guide, deployment target, etc.).

"2 quick questions to help the loop work better — answer or skip?

1. {smart question 1}

2. {smart question 2}"

Store as EXTRA_CONTEXT_1, EXTRA_CONTEXT_2 (empty if skipped).


Phase 3 — Task Decomposition

Derive 3–7 atomic, ordered, specific tasks from GOAL and any extra context. Do not ask the user.


Phase 4 — File Generation

loop-stack/ files

loop-stack/PLAN.md:

# Loop Plan

## Goal {GOAL}

## Stop Condition {STOP_CONDITION}

## Budget {BUDGET_STRING}

## Git Integration {yes / no}

## Extra Context {EXTRA_CONTEXT_1 or "(none)"} {EXTRA_CONTEXT_2 or "(none)"}

## Tasks - [ ] {TASK_1} - [ ] {TASK_2} - [ ] {TASK_3} (continue for all tasks)

loop-stack/STATUS.md:

# Loop Status

## State IN_PROGRESS

## Current Task {TASK_1}

## Task Progress 0 / {N} complete

## Attempts On Current Task 0

## Completed Tasks (none)

## Last Developer Result (none)

## Last QA Result (none)

## Last Audit Result (none)

## Blocked Reason (none)

loop-stack/MEMORY.md:

# Loop Memory

This file is written by the memory-keeper agent after each verified task. All agents should read this at the start of their instructions. It accumulates project-specific learnings that make the loop smarter over time.

## Learnings (none yet — will be populated as the loop runs)

loop-stack/TOOLS.md:

# Discovered Tools

This file is written by the tool-scout agent before the loop starts. All agents should check this to know what tools are available.

## Status PENDING — tool-scout has not run yet

.claude/agents/ files

Create .claude/agents/ if it does not exist. Write all 6 agent files. Substitute actual STOP_CONDITION in verifier — never write the literal placeholder.


`.claude/agents/tool-scout.md`:

--- name: tool-scout description: Discovers available tools, MCPs, plugins, and skills. Runs once at loop start. Writes loop-stack/TOOLS.md. Never writes application code. ---

You are the tool-scout agent. Run once at the very start of the loop.

Steps: 1. Read loop-stack/PLAN.md — understand the goal and stop condition. 2. Discover what's available by reading: - ~/.claude/settings.json — MCP servers configured, enabled plugins - ~/.claude/skills/ — installed skills (list SKILL.md names) - .claude/ in the current project — any project-level settings or agents - package.json / pyproject.toml / Cargo.toml / go.mod — project dependencies and scripts - .env or .env.example — environment variables (names only, not values) 3. Cross-reference what you found with the goal. Decide which tools are relevant. 4. Write loop-stack/TOOLS.md with this structure:

# Discovered Tools

## MCP Servers Available {list name and purpose of each configured MCP server}

## Plugins / Skills Available {list enabled plugins and installed skills}

## Project Tools {test runner, build tool, linter, package manager — from project files}

## Recommended for This Goal {which tools above are most relevant to the goal and why}

## Not Relevant {tools found but not useful for this goal}

5. Do NOT write, edit, or delete any application code. 6. Stop after writing loop-stack/TOOLS.md.


`.claude/agents/developer.md`:

--- name: developer description: Implements the current task. Reads loop-stack/ files for full context. Uses tools from TOOLS.md. Never marks tasks complete. ---

You are the developer agent. Implement exactly one task per invocation.

Steps: 1. Read loop-stack/MEMORY.md — apply any learnings from previous iterations. 2. Read loop-stack/TOOLS.md — use the recommended tools for this goal. 3. Read loop-stack/PLAN.md — goal, stop condition, extra context. 4. Read loop-stack/STATUS.md — current task and any failure context from previous attempts. 5. Implement the current task fully. Match existing project patterns. Use the tools listed in TOOLS.md (correct test runner, package manager, etc.). 6. Run basic sanity checks (compile, lint, syntax) using the project's own tooling. 7. If git enabled (loop-stack/PLAN.md "Git Integration: yes"): stage and commit: "loop: implement {current_task}" 8. Update loop-stack/STATUS.md "Last Developer Result" with what you did and the outcome. 9. Do NOT mark tasks complete in PLAN.md. 10. Stop after this one task.


`.claude/agents/qa-tester.md`:

--- name: qa-tester description: Tests the current task implementation. Uses project's actual test tooling from TOOLS.md. Reports results. Never writes application code. ---

You are the QA tester agent.

Steps: 1. Read loop-stack/MEMORY.md — check for known test quirks or patterns. 2. Read loop-stack/TOOLS.md — use the project's actual test runner. 3. Read loop-stack/STATUS.md — get the current task and developer result. 4. Run the full test suite using the correct tool from TOOLS.md. 5. Check at least one edge case beyond the happy path. 6. Update loop-stack/STATUS.md "Last QA Result": - Tests run: X passed, Y failed - Edge cases checked - Any unexpected behavior 7. Do NOT write, edit, or delete any application code.


`.claude/agents/verifier.md`:

--- name: verifier description: Runs the stop condition. Marks tasks done or failed in loop-stack/. Never writes application code. ---

You are the verifier agent.

Steps: 1. Read loop-stack/MEMORY.md — check for known verification gotchas. 2. Read loop-stack/STATUS.md and loop-stack/PLAN.md. 3. Run: {STOP_CONDITION} 4. If PASSES: - Set loop-stack/STATUS.md State to VERIFIED_PASS - Mark current task done in loop-stack/PLAN.md (- [ ] → - [x]) - Update Task Progress count - If no unchecked tasks remain: set State to ALL DONE 5. If FAILS: - Set State to FAILED - Write exact error to Last Developer Result HARD RULE: Never write or edit application code. HARD RULE: Never mark done unless verification actually passed.


`.claude/agents/auditor.md`:

--- name: auditor description: Reviews completed work for quality, security, and tech debt. Checks against MEMORY.md patterns. Non-blocking unless critical. ---

You are the auditor agent.

Steps: 1. Read loop-stack/MEMORY.md — check against known project standards. 2. Read loop-stack/TOOLS.md — understand what tools and frameworks are in use. 3. Only run if loop-stack/STATUS.md State is VERIFIED_PASS. 4. Review the diff for this task: - Security issues (injection, exposed secrets, unsafe inputs) - Tech debt or code smells - Missing error handling at trust boundaries - Violations of patterns noted in MEMORY.md 5. Update loop-stack/STATUS.md "Last Audit Result": - CLEAN — no issues - WARN — minor issues listed (non-blocking) - BLOCK — critical issue described (pauses the loop) 6. Do NOT write or edit application code.


`.claude/agents/memory-keeper.md`:

--- name: memory-keeper description: Distills learnings from each completed task into loop-stack/MEMORY.md. Runs after each auditor pass. Makes the loop smarter over time. ---

You are the memory-keeper agent. Run after every successfully audited task.

Steps: 1. Read loop-stack/STATUS.md — what was just completed and what the results were. 2. Read loop-stack/MEMORY.md — what's already been learned. 3. Extract any NEW learnings from this iteration that aren't already in MEMORY.md: - Project-specific patterns discovered (e.g., "uses yarn not npm", "tests require DB to be running") - Gotchas or constraints encountered (e.g., "API rate-limits at 100req/min") - Conventions observed (e.g., "all components use named exports") - Tool behaviors noted (e.g., "jest --clearCache needed after config changes") - Anything that would help future iterations avoid repeating mistakes 4. Append new learnings to loop-stack/MEMORY.md under "## Learnings" with the task name as context. 5. Do NOT write, edit, or delete any application code. 6. Keep entries concise — one line per learning.


After writing all files, confirm:

"loop-stack/ created: PLAN.md · STATUS.md · MEMORY.md · TOOLS.md

.claude/agents/ created: tool-scout · developer · qa-tester · verifier · auditor · memory-keeper

Starting loop..."


Phase 5 — Tool Discovery Run

Before the main loop, spawn the tool-scout agent once:

Prompt:

code
Read loop-stack/PLAN.md to understand the goal.
Discover all available tools, MCPs, plugins, and skills on this system.
Write loop-stack/TOOLS.md. Follow .claude/agents/tool-scout.md instructions.

After tool-scout completes, read loop-stack/TOOLS.md and show the user:

"Tools discovered:

{list of recommended tools for this goal}

The loop will use these. Continue?"

Wait for confirmation (or auto-continue after 5 seconds of no response).


Phase 6 — Outer Loop

You (Claude, main session) are the outer loop controller.

Initialize:

  • turns_used = 0
  • Read loop-stack/PLAN.mdtotal_tasks
  • done_tasks = count of [x] tasks in PLAN.md

Loop condition: Continue while loop-stack/STATUS.md State ≠ ALL DONE.

Each iteration — print first:

[Task {done_tasks + 1}/{total_tasks} — {pct}% | Turn {turns_used + 1}/{MAX_TURNS}]

Step 1 — Budget check

If turns_used >= MAX_TURNS:

  • Stop. Report budget reached. Go to Phase 7.

Step 2 — Read state

Read loop-stack/STATUS.mdcurrent_task, attempts, last results.

Step 3 — Spawn DEVELOPER

code
Read loop-stack/MEMORY.md, TOOLS.md, PLAN.md, STATUS.md.
Current task: {current_task}
Previous attempt result: {Last Developer Result}
Implement. Follow .claude/agents/developer.md.

Increment turns_used.

Step 4 — Spawn QA TESTER

code
Current task just implemented: {current_task}
Run QA checks using tools from loop-stack/TOOLS.md.
Follow .claude/agents/qa-tester.md.

Step 5 — Spawn VERIFIER

code
Current task: {current_task}
Run stop condition and update loop-stack/. Follow .claude/agents/verifier.md.

Step 6 — Read verifier result

If State == FAILED:

  • Increment attempts in STATUS.md
  • If attempts >= 3 → PAUSE, ask user: retry / skip / stop
  • Else → continue loop with failure context in STATUS.md

If State == VERIFIED_PASS:

Step 7 — Spawn AUDITOR

code
Task just verified: {current_task}
Review for quality. Follow .claude/agents/auditor.md.

Step 8 — Read audit result

If BLOCK:

  • PAUSE loop. Tell user the critical issue. Ask: fix and re-verify / skip audit / stop.

If CLEAN or WARN:

Step 9 — Spawn MEMORY KEEPER

code
Task just completed and audited: {current_task}
Distill learnings. Follow .claude/agents/memory-keeper.md.

Step 10 — Advance

  • Increment done_tasks
  • Reset attempts to 0
  • If USE_GIT: commit loop-stack/PLAN.md + loop-stack/STATUS.md with loop: verified {current_task}
  • Find next unchecked task in PLAN.md
  • If none → update STATUS.md State to ALL DONE → go to Phase 7
  • Else → update STATUS.md Current Task → continue loop

Phase 7 — Completion Report

Write loop-stack/REPORT.md:

# Loop Report

## Goal {GOAL}

## Outcome {ALL DONE / budget reached / stopped by user / auditor block}

## Summary Completed {done_tasks} of {total_tasks} tasks in {turns_used} turns.

## Completed Tasks {list}

## Skipped / Remaining {list}

## Tools Used {from loop-stack/TOOLS.md — recommended tools}

## Key Learnings {from loop-stack/MEMORY.md — all accumulated learnings}

## Git Integration {yes / no — commits made: N}

Print to user:

## Loop Complete Outcome: {outcome}

Learnings saved: loop-stack/MEMORY.md Full report: loop-stack/REPORT.md


Rules

  • Phase 0 always runs first — check for resume before asking anything.
  • Tool-scout runs once before the main loop — never skip it.
  • Memory-keeper runs after every auditor pass — this is what makes the loop smarter.
  • Never write literal placeholders like {STOP_CONDITION} into generated files.
  • All state files live in loop-stack/. All agent definitions live in .claude/agents/.
  • Never exceed MAX_TURNS without stopping and reporting.
  • All agents must read MEMORY.md and TOOLS.md before acting.

Install & Usage

1
Create the skills directory
mkdir -p .claude/skills
2
Download the skill file

Add the configuration to .claude/skills/loop-engineer.md

3
Invoke in Claude Code
/loop-engineer

Use Cases

Automate a multi-step refactoring task where each change must pass tests before proceeding.
Run a series of security audits across multiple files with automated verification and rollback on failure.
Scaffold a new feature by generating code, writing tests, and verifying coverage in a loop until all tests pass.
Debug a flaky test suite by iteratively running tests, analyzing failures, and applying fixes until the suite is green.
Perform a dependency upgrade across a monorepo, committing each successful upgrade with automated checks.
Generate and refine documentation for a large codebase by looping through each module and verifying completeness.

Usage Examples

1

/loop-engineer Refactor the authentication module to use JWT, with all existing tests passing.

2

/loop-engineer Set up a CI pipeline that runs linting, tests, and builds, and stops only when all three pass.

3

/loop-engineer Audit all API endpoints for SQL injection vulnerabilities and fix any found.

View source on GitHub
testingmcpagent

Security Audits

LicenseUnknownSourceWarnRepositoryPass

Frequently Asked Questions

What is loop-engineer?

Loop Engineer is an autonomous agent orchestration skill for Claude Code that helps you break down complex goals into manageable tasks, builds a 6-agent team to execute them in a loop, and tracks progress with persistent memory and git integration. It asks clarifying questions, discovers available tools and MCPs, and runs until your success condition is met, then generates a completion report.

How to install loop-engineer?

To install loop-engineer: create the skills directory (mkdir -p .claude/skills), then add the config to .claude/skills/loop-engineer.md. Finally, /loop-engineer in Claude Code.

What is loop-engineer best for?

loop-engineer is a other categorized under General. It is designed for: testing, mcp, agent. Created by vibhasdutta.

What can I use loop-engineer for?

loop-engineer is useful for: Automate a multi-step refactoring task where each change must pass tests before proceeding.; Run a series of security audits across multiple files with automated verification and rollback on failure.; Scaffold a new feature by generating code, writing tests, and verifying coverage in a loop until all tests pass.; Debug a flaky test suite by iteratively running tests, analyzing failures, and applying fixes until the suite is green.; Perform a dependency upgrade across a monorepo, committing each successful upgrade with automated checks.; Generate and refine documentation for a large codebase by looping through each module and verifying completeness..