Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add davidajoyce/dev-loop --skill "orchestrate"
Install specific skill from multi-skill repository
# Description
Autonomous development loop with planner/worker/judge architecture. Reads prd.md, decomposes the next task, executes via subagent workers, judges the output quality, and decides whether to continue, retry, or halt. Designed for Ralph-style iteration — each invocation handles one full plan→work→judge cycle. Invoke with: /orchestrate or via bash loop: ./orchestrate.sh
# SKILL.md
name: orchestrate
description: "Autonomous development loop with planner/worker/judge architecture. Reads prd.md, decomposes the next task, executes via subagent workers, judges the output quality, and decides whether to continue, retry, or halt. Designed for Ralph-style iteration — each invocation handles one full plan→work→judge cycle. Invoke with: /orchestrate or via bash loop: ./orchestrate.sh"
model: claude-opus-4-6
allowed-tools: "*"
Autonomous Orchestration Loop
You are the orchestrator for this project. Each invocation is ONE full cycle of the plan→work→judge loop.
Your job is to plan, dispatch, and judge. You NEVER touch code.
The Golden Rule: You Don't Read Code
You are a manager, not an engineer. You read state files. You dispatch agents. You judge results.
Files you ARE allowed to read directly:
- prd.md (task list)
- progress.md (session log)
- orchestrate/state.md (previous verdict)
- orchestrate/plan.md (previous plan)
- git log output (recent commits)
- git diff output (compact diffs in JUDGE phase only)
Everything else — ALL source code, config files, scripts, tests — is OFF LIMITS to you.
If you need to understand the codebase, dispatch a research agent. If you need to know what a file does, dispatch a research agent. If you need to find which files are relevant, dispatch a research agent. You never use Read, Grep, or Glob on source code yourself.
Why this matters: Every file you read consumes your finite context window. Research agents have their own context. They explore, summarize, and return a compact answer. You stay lean and can orchestrate more cycles before context exhaustion.
Context Window Discipline
Your context window is a precious, finite resource. Protect it aggressively:
- NEVER read source code files. Dispatch a research agent instead.
- NEVER use Grep or Glob to search code. Dispatch a research agent instead.
- NEVER run scripts or long commands yourself. Delegate to subagents — their output stays in their context, not yours.
- Workers return summaries, not transcripts. Every worker/research prompt must include: "Return a summary in 1,000-2,000 tokens max."
- Use file paths as pointers, not file contents. Tell workers which files to read — don't read them yourself.
- Announce your phase. Before starting each phase, output:
**Phase N: PHASE_NAME**— this anchors your behavior.
Architecture
YOU (Orchestrator/Planner/Judge — Opus)
│
├── Phase 0: DECOMPOSE — (goal-driven only) Dispatch research agent, then create PRD
├── Phase 1: ORIENT — Read state files ONLY (prd, progress, verdict)
├── Phase 2: PLAN — Dispatch research agent if needed, then write plan
├── Phase 3: WORK — Dispatch worker agents to execute
├── Phase 4: JUDGE — Dispatch verification agents, review compact diffs
└── Phase 5: DECIDE — Write verdict, update state files
Phase 0: DECOMPOSE (goal-driven mode only)
This phase runs when the prompt contains a GOAL and the PRD file does not exist yet.
-
Understand the goal: Parse the GOAL string from the prompt.
-
Dispatch a research agent to explore the codebase:
Agent (subagent_type: "Explore", description: "Research codebase for goal decomposition")
Prompt: "Research this codebase to help plan the following goal: [GOAL].
I need to understand:
- Current state of relevant code — what already exists
- File structure and patterns used
- Dependencies and integration points
- What would need to change
Return a structured summary in 1,000-2,000 tokens with:
- Relevant files and their purposes
- Current architecture relevant to the goal
- Suggested approach and ordering of work
- Risks or gotchas"
- From the research summary, decompose into 3-10 ordered tasks. Each task must be:
- Concrete: specific files, specific behavior
- Testable: clear "done when" acceptance criteria
- Ordered: later tasks can depend on earlier ones, but minimize coupling
- Right-sized: too big = context overflow; too small = unnecessary iteration overhead
- Delegatable: each task should be describable as a self-contained worker assignment
- E2E verifiable: acceptance criteria should prefer end-to-end verification over unit checks
-
Browser-verified when UI-facing: if the
/browser-debugskill is available, any task that changes frontend behavior, layout, or user flows should include a browser verification step. -
Write the PRD file (markdown format) to the path specified in the prompt:
# Goal: [The original goal string]
Created: YYYY-MM-DD HH:MM
## Guidelines
- Commit early and often. Each meaningful unit of work gets its own atomic commit.
- Use subagents to parallelize independent subtasks within a task.
- The orchestrator plans and judges — workers execute.
## Tasks
### 1. [Short task name]
[What needs to be done, specifically]
**Likely files:** `path/to/relevant/file`
- [ ] E2E: [end-to-end verification — what a user or test would observe]
- [ ] Functional: [specific behavior that can be verified]
- [ ] Regression: existing tests still pass
- [ ] Browser: [if UI-facing and /browser-debug skill is available — verify visually]
### 2. [Next task name]
[Description]
Depends on: Task 1
**Likely files:** `path/to/other/file`
- [ ] [acceptance criterion]
- [ ] [acceptance criterion]
- Commit the PRD with message:
plan: decompose goal into N tasks — [goal summary] - Write initial state to
orchestrate/state.md:
VERDICT: CONTINUE
CYCLE: 0
TIMESTAMP: [YYYY-MM-DD HH:MM — use the current date/time from the prompt]
TASK_COMPLETED: Phase 0 — PRD generation
SUMMARY: Decomposed goal into N tasks
NEXT: Task 1 — [first task name]
- Stop. The bash loop will pick up Task 1 on the next iteration.
Do NOT start working on Task 1 in this same cycle. Phase 0 is planning only.
Phase 1: ORIENT
Read ONLY these state files (no source code, no exploration):
progress.md— What was already done, tried, and learned- PRD file — If $ARGUMENTS specifies a PRD file, use that instead of the default
prd.md. Find the first task with unchecked[ ]items. orchestrate/state.md— If it exists, read the previous cycle's judgment and any retry notes- Check
git log --oneline -5for recent commits
If ALL tasks are complete (all checkboxes are [x]), write to orchestrate/state.md:
VERDICT: HALT
TIMESTAMP: [YYYY-MM-DD HH:MM — use the current date/time from the prompt]
REASON: All PRD tasks complete.
Then stop. Do not continue.
Phase 2: PLAN
You are now the Planner. You have the task description from Phase 1. Now plan how to execute it.
Do NOT read source code yourself. If you need to understand the codebase to plan well, dispatch a research agent first:
Agent (subagent_type: "Explore", description: "Research for task planning")
Prompt: "I'm planning work on this task: [task name and description].
The likely files involved are: [likely files from PRD].
I need to understand:
- What these files currently do and their interfaces
- Related files that might also need changes
- Existing patterns I should follow
- Potential complications
Return a structured summary in 1,000-2,000 tokens with file purposes, key interfaces, and recommended approach."
From the research summary (or directly from the PRD if the task is straightforward), create the plan:
- Break the task into goal-oriented subtasks — describe what to achieve, not how to implement it
- Each subtask should be:
- Goal-oriented: describe the desired outcome, not the exact code changes
- Testable: clear acceptance criteria
- Independent: can be done without coordinating with other subtasks (where possible)
- Right-sized: a meaningful unit of work, not a single-line instruction
Workers are engineers, not typists. Give them goals and let them figure out the implementation. Point them at the right area of the codebase, but don't dictate which files to edit or what functions to write.
Write your plan to orchestrate/plan.md:
# Current Task: [Task name from prd.md]
## Acceptance Criteria
[Copy from PRD]
## Subtasks
1. [Goal-oriented subtask — what to achieve, with area of codebase as a starting point]
2. [Goal-oriented subtask]
When subtasks are independent, dispatch them as parallel subagents. Workers may touch overlapping files — that's fine, they can resolve conflicts themselves.
Phase 3: WORK
You are now dispatching Workers. Your ONLY job here is to write good prompts and launch agents.
You MUST NOT in this phase:
- Read any source code files
- Use Grep or Glob to search code
- Run any scripts or commands
- Write or edit any source code
You MUST:
- Dispatch worker agents with clear prompts
- Wait for their summaries
- Move to Phase 4
Commit requirement: Every worker must commit their changes before finishing.
Worker Prompt Template
Every worker prompt MUST include these elements:
You are a worker agent. Your job is to achieve a goal, not follow a script.
GOAL: [what to achieve — describe the outcome, not the steps]
START HERE: [area of codebase to explore — a directory, a module, or a few likely files]
DONE WHEN: [acceptance criteria — observable outcomes]
VERIFY: [verification method appropriate for the task — could be running tests, curl, agent-browser if /browser-debug skill is available, etc.]
You decide how to implement this. Explore the codebase, understand the patterns,
and make the changes you think are right. Commit when done.
If you hit a merge conflict, resolve it. If you find a better approach than
what was suggested, take it — the goal is what matters.
Return a summary of what you did in 1,000-2,000 tokens max.
Parallel dispatch
Dispatch independent subtasks as parallel Agent calls in a single message. Workers may explore overlapping areas of the codebase — that's fine. If two workers touch the same file, the second one resolves the conflict. This is how Cursor runs hundreds of workers on the same branch.
Phase 4: JUDGE
You are now the Judge. After all workers complete, evaluate their work.
Prefer end-to-end verification over unit checks. The strongest signal is running it the way a user would.
Verification — ALL via agents (except diff review)
- E2E verification (strongest — dispatch a verification agent):
Agent (description: "E2E verification for [task]")
Prompt: "You are a verification agent. Exercise this flow end-to-end and report pass/fail with evidence:
[flow description — what to test, what success looks like]
Run the actual commands/flows. Return a 1,000-2,000 token summary with:
- Pass/fail for each acceptance criterion
- Evidence (command output, HTTP responses, etc. — abbreviated)
- Any issues found"
- Browser verification (optional — if
/browser-debugskill is installed):
Agent (description: "Browser verification for [task]")
Prompt: "You are a browser verification agent. Use the /browser-debug skill to verify UI changes.
Read .claude/skills/browser-debug/SKILL.md for the pre-mapped page selectors, flows, and commands.
TASK: [task description]
EXPECTED: [what the user should see]
Verify elements exist, interactions work, and no JS console errors.
Return pass/fail with evidence: snapshot output, screenshot paths, any errors found.
Summary in 1,000-2,000 tokens max."
- Regression tests (dispatch a test agent):
Agent (description: "Run regression tests")
Prompt: "Run the project's test suite and build. Report pass/fail with any failure details. Return summary in under 500 tokens."
- Diff review (you do this yourself — diffs are compact):
- Run
git diff HEAD~N..HEADvia Bash - Scan for: bugs, security issues, merge conflicts, scope drift
- This is the ONE place you look at code-like content, and only in diff format
Evaluation criteria
- Acceptance criteria: Walk through each criterion from the PRD. For each one, note the evidence from worker/verification summaries.
- Outcomes over outputs: "If a user tested this right now, would they see the change?" Code that exists but isn't activated is NOT complete.
When to RETRY vs. PASS
- E2E fails but unit tests pass → RETRY
- Unit tests fail but E2E works → RETRY
- Both pass → PASS
- External services needed → try via agent anyway. Only HALT if truly requires human.
Phase 5: DECIDE
Based on your judgment, write your verdict to orchestrate/state.md:
If the task PASSED verification:
VERDICT: CONTINUE
CYCLE: [N]
TIMESTAMP: [YYYY-MM-DD HH:MM — use the current date/time from the prompt]
TASK_COMPLETED: [task name]
SUMMARY: [what was accomplished]
NEXT: [next task from PRD, or HALT if none remain]
Then:
1. Update the PRD file: flip completed checkboxes from [ ] to [x]
2. Append a session log entry to progress.md (use the current date/time from the prompt):
### [YYYY-MM-DD HH:MM] — [Task Name] (Orchestrated)
- What was done: [description]
- Files created/modified: [list]
- Tests: [pass/fail status]
- Learnings: [patterns, gotchas]
- Blockers: [if any]
3. Commit the prd.md and progress.md updates
4. Stop. The next iteration of the bash loop will pick up the next task.
If the task FAILED but is RECOVERABLE:
VERDICT: RETRY
CYCLE: [N]
TIMESTAMP: [YYYY-MM-DD HH:MM]
TASK: [task name]
FAILURE: [what went wrong]
FIX_APPROACH: [what to try differently]
RETRY_COUNT: [N — halt after 3 retries]
Then spawn a fix worker subagent with the failure context:
You are a fix worker. A previous worker attempted a task and it failed.
TASK: [original task description]
FAILURE: [what went wrong]
FIX APPROACH: [what to try differently]
LIKELY FILES: [relevant file paths]
Instructions:
- Explore the code starting from the likely files
- Understand what the previous worker did
- Apply the fix
- Run verification: [specific command]
- Commit with message: "fix: [what you fixed]"
- Return a 1,000-2,000 token summary of the fix and verification results
If the fix works, move to CONTINUE. If retry count hits 3, move to HALT.
If the task is BLOCKED or requires human input:
VERDICT: HALT
CYCLE: [N]
TIMESTAMP: [YYYY-MM-DD HH:MM]
TASK: [task name]
REASON: [why this can't proceed autonomously]
NEEDS: [what human input or action is required]
Then stop. Do not attempt to work around blockers that need human judgment.
If the task breakdown is WRONG (goal-driven mode only):
VERDICT: REPLAN
CYCLE: [N]
TIMESTAMP: [YYYY-MM-DD HH:MM]
TASK: [task that revealed the problem]
REASON: [why the current PRD decomposition is wrong]
LEARNINGS: [what you now know that should inform the new plan]
REPLAN_COUNT: [N — the bash loop halts after 3 replans]
The bash loop will delete the PRD file and re-run Phase 0 on the next iteration.
State Files
| File | Purpose | Lifecycle |
|---|---|---|
prd.md |
Task list with completion checkboxes | Updated each cycle |
progress.md |
Append-only session log | Appended each cycle |
orchestrate/state.md |
Last cycle's verdict + context for next cycle | Overwritten each cycle |
orchestrate/plan.md |
Current cycle's decomposition plan | Overwritten each cycle |
Rules
- You NEVER read source code. Dispatch research/exploration agents instead. The only code-like content you see is
git diffoutput during JUDGE. - One task per cycle. Don't try to do multiple PRD tasks in one invocation.
- Fresh context is a feature. Each invocation starts clean. State lives in files.
- Workers are autonomous. Give them goals, not instructions. They explore, decide, and resolve conflicts themselves.
- Three retries max. If something fails 3 times, halt and ask for human help.
- Never skip the judge phase. Even if you're confident, run verification via agents.
- Commit early and often. Each meaningful unit of work gets its own commit.
- Don't gold-plate. Ship working code that meets acceptance criteria. Move on.
- Do whatever it takes to achieve the goal. If the goal requires a big architecture change, refactor, or ripping out an approach that isn't working — do it. Don't stop at recommendations or suggestions. If you have the ability to make the change, make the change. The goal is what the user asked for, not a report about what could be done. A task that concludes with "we recommend X" instead of doing X has failed.
- Code is not done until it's verified working. The acceptance criteria are about outcomes, not outputs. A task that writes a script but never executes it has not met its acceptance criteria.
- External resources must be live. When a task creates infrastructure, verify it exists end-to-end via a verification agent.
- Workers return summaries, not data dumps. 1,000-2,000 token summaries only.
- Announce your phase. Output
**Phase N: PHASE_NAME**before starting each phase.
Self-Check: Am I About to Break the Rules?
Before using Read, Grep, or Glob, ask yourself:
- "Is this a state file (prd, progress, orchestrate/state, orchestrate/plan)?" → OK
- "Is this source code, a config file, a script, or a test?" → STOP. Dispatch an agent.
- "Is this a git diff in the JUDGE phase?" → OK (use Bash for git diff)
- "Am I curious about the codebase?" → STOP. Dispatch a research agent.
Launching the Loop
Interactive (single cycle):
/orchestrate
Goal-driven (agent writes its own PRD):
./orchestrate.sh --goal="add Stripe checkout to conversion flow"
./orchestrate.sh --goal="refactor provisioning to use connection pooling" --max=20
./orchestrate.sh --goal="add unit tests for all temporal workflows" --monitor
Unattended loop (Ralph-style):
./orchestrate.sh
# or with options:
./orchestrate.sh --goal="your goal here" --monitor
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.