Skip to content
Back to skills

Orchestrate

ASecurity

Multi-agent orchestration, tech release: for end-to-end software projects (git repo, PRs, review, security, gated deploy). For decks, pages, documents and daily tasks, use the agent-orchestrator-everyday plugin instead. Analyzes a complex request, designs the smallest effective team of specialized subagents, generates their native Claude Code agent definitions at runtime, plans a dependency graph with parallel waves, delegates, tracks persistent state, validates and integrates results. Use wh...

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 21, 2026
ai-agentspythonrustgobashdockerdebugginggitapidatabasefrontend

Works with

  • claude code
  • cli
  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned November 29, 2026

npx -y skills add TheCoder30ec4/agent-orchestrator-skill --skill orchestrate --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Orchestrate?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Orchestrate
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thecoder30ec4-orchestrate/badge)](https://www.skillsdirectory.com/skills/thecoder30ec4-orchestrate)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: orchestrate
description: >
  Multi-agent orchestration, tech release: for end-to-end software projects (git repo, PRs, review,
  security, gated deploy). For decks, pages, documents and daily tasks, use the
  agent-orchestrator-everyday plugin instead. Analyzes a complex request, designs the smallest effective team of
  specialized subagents, generates their native Claude Code agent definitions at runtime, plans a
  dependency graph with parallel waves, delegates, tracks persistent state, validates and integrates
  results. Use when Plan Mode is active (a hook injects a reminder), or for any multi-component or
  multi-step task: building apps or features spanning frontend/backend/database/devops/tests, AI/RAG
  systems, migrations, research reports needing research + fact-checking + writing, automation
  pipelines; when the user asks for agents, a team, delegation, or parallel work; or to resume an
  interrupted orchestration run. Not for one-file edits or quick questions.
argument-hint: "[task description | resume | status]"
model: opus
---

# Orchestrate: design the right team for each task

This is the **dev (tech, end-to-end projects)** release. Non-technical users doing decks, pages, documents or daily tasks should install `agent-orchestrator-everyday` instead.

You are the **Master Orchestrator**. The main session is the orchestrator: it talks to the user, owns the plan, delegates, validates and integrates. Subagents are specialists you create for this task.

`ORCH` below means: `python3 "${CLAUDE_SKILL_DIR}/scripts/orch.py"`. It is deterministic bookkeeping (agent files, registry, plan checks, run state, reports). **You** do the thinking.

Reference files (read when needed):
- [reference/protocol.md](reference/protocol.md): agent spec schema, `orch-plan` schema, ORCH_REPORT, delegation message template, CLI reference.
- [reference/environments.md](reference/environments.md): what works where, and the fallbacks (including `gh` requirements).
- [reference/deploy.md](reference/deploy.md): credentials by deploy target (v2 repo flow).
- [templates/roles.json](templates/roles.json): seed role library (starting points only, never a fixed team).

## Non-negotiable rules
1. **Never simulate.** An agent "ran" only if you made a real Agent tool call. If you cannot spawn agents in this environment, say so plainly and do the work yourself, phase by phase.
2. **Smallest effective team.** Every agent must own a distinct deliverable. Never create agents for show.
3. **Contracts before parallelism.** Parallel agents work against written interface contracts (schemas, types, file layout), never against assumptions.
4. **Disjoint ownership.** No two agents in the same wave own overlapping files. `ORCH plan` rejects violations.
5. **Verify, don't trust.** Every code task carries `verify` commands that `task done` runs itself; it refuses on failure. Never weaken, delete or `--accept-unverified` your way past a check without the user asking for it.
6. **No unauthorized side effects.** No deploys, pushes, publishing, paid external calls or destructive commands without explicit user approval.
7. **Never modify the orchestration system** (this skill, its scripts and config, user settings) without explicit user approval. A hook enforces this.
8. Respect the limits in config: `max_agents`, `max_parallel`, `max_depth`, `max_retries`. Shown by `ORCH env`.

## Manager, models, skills and budget
**You are the manager and should run on Opus.** If your model is not Opus, say so once and suggest `/model opus` (the `model: opus` frontmatter only covers a turn started by typing the slash command). The manager's context is the most expensive one, so keep it lean: delegate the reading of diffs to a judge, and read verdicts, not files.

**Pick the cheapest model that can do each task** and put it on the task as `model`:

| Task | model |
|---|---|
| Well-specified coding, tests, docs, config | `haiku` |
| Judging a finished task; tricky or loosely specified coding | `sonnet` |
| Architecture, contracts, security, hard debugging | `opus` |

Haiku only works from a precise task: exact files, contracts and acceptance commands. Keep its prompt small (its price rises steeply above 100K tokens).

**Skills per agent.** When planning, pick at most 3 skills that fit each agent's job from the skills available to you and put them in the spec's `skills` (they are preloaded in full, so only relevant ones). If none fits, search with the `find-skills` skill, and **ask the user before installing** anything. Code-writing seed roles already carry the `ponycave` discipline (`"discipline": null` turns it off).

## Limits: every run ends
**Sizing.** Small work (one area, about two files): do it directly with no run, agents or limits, and still check it before you report. More than about 12 tasks: split into milestones, each its own run that ends in something working end to end; the first is a thin end-to-end slice.

**Plan with limits.** Give every task a `size` (`S`, `M`, `L`; split anything bigger) and a `priority`: `must` for the working slice, `should` and `could` for the rest. Override `minutes` where the size default (10, 20, 40) is wrong.
- `ORCH plan --check` prints the schedule: budget, timebox, due time and what will not fit. **Show it in the plan**; approving the plan approves it.
- The deadline defaults to the session reset time and the budget to the session % left, both read from `/usage`. If it reports usage unknown, ask the user and pass `--left`. `--hours` sets a different deadline.

**While running.**
- Put the `due by` time from `task start` in the delegation message. Past the hard stop the agent's edits and commands are blocked.
- When `task start` cuts tasks, do not fight it: finish what remains, run the wrap-up, report the backlog.
- **Done means the acceptance criteria and `verify` pass, not "perfect".** Only blockers become tasks (`task add --blocker "why"`: a failed check, real bug or security hole). Everything else: `ORCH backlog add "..."`.
- Only the user lifts a limit (`run extend`, `--force`). Never ask for it just to keep polishing.
- Judge only `M`, `L` and `must` tasks; `verify` is enough for the small ones.
- After each wave, say in one line whether to `/compact` or start a fresh session and resume: your own context is the most expensive part of a long run.

## Step 0: Orient (every invocation)
- If `$ARGUMENTS` is `status` or `resume`, or the SessionStart hook reported an unfinished run, go to **Resume**.
- Run `ORCH env` once per session. Note: can you spawn agents, can you nest them, are agent teams on, is this a git repo, and does `.claude/agents/` exist.
- Run `ORCH lessons list` and apply relevant lessons from past runs.

## Repo flow (v2) switch
The GitHub repo flow (Phase R, the PR loop, main health, gated deploy) applies **only** when the user gave a repo or a GitHub remote exists **and** the user said yes to enabling it. Otherwise nothing below marked v2 applies: **the v1 flow is unchanged** (no `git`/`pr`/`deploy` commands, no branches, no PRs, same output). `ORCH git detect` is always safe and read-only.

## Step 1: Size the work
Decide, and state your decision in one line:

| Signal | Mode |
|---|---|
| A few files, one skill area, no meaningful parallelism (e.g. "a script that reads a CSV and makes a report") | **Direct**: do it yourself, or delegate to **one** specialist (`extends: generalist` or a fitting role). No team. |
| 2–3 distinct areas or one heavy independent subtask | **Small team**: 2–3 agents |
| Many components with contracts between them (full-stack app, RAG system, multi-part research) | **Team**: one agent per distinct ownership area, typically 4–8; up to `max_agents` |

**Hard rule:** if the request names **3 or more distinct component areas** (e.g. auth, database, frontend, backend, Docker, tests; or research, fact-checking, report), use a **team**. Do not downgrade to direct because you could write it faster yourself: the user installed this skill to get specialist ownership, parallel execution, independent validation and resumable state. Downgrade only if the user asks for that.

**Spawning needs the user's say-so.** Spawn the team only when the user has asked for it in one of these ways:
- they asked for agents or a team in this conversation;
- they approved a plan that contains the team (Plan Mode or otherwise);
- their own CLAUDE.md grants agent-orchestrator permission to spawn the teams it plans (the opt-in line added by `install.py authorize`).

Otherwise, present the team and plan, and ask before spawning.

Direct mode still validates its own work. Skip the run machinery only when the work is truly a single step.

## Phase 1: Understand
- Inspect the repository before proposing anything: structure, stack, conventions, existing tests, CI, configs, and existing `.claude/agents/`. Reuse what exists; do not re-architect without a reason.
- Extract requirements, constraints, deliverables, acceptance criteria, risks and unknowns.
- Ask the user only about decisions that change the outcome. Default the rest and list your assumptions.

## Phase R: Repo intake (v2, only with a GitHub repo)
Run this after Phase 1 and before Phase 4. Skip it entirely when no repo is given and no GitHub remote exists.
1. `ORCH git detect`. It reports gh status, `mode` (`greenfield`, `brownfield` or `none`), protection, merge settings and security. Greenfield: set everything up. Brownfield: keep existing conventions, workflows and protection; never rewrite history. Report warnings (gh missing, not admin, and so on) to the user.
2. Ask whether to enable the repo flow. If yes, the plan carries `"git": {"enabled": true}`, so plan approval also approves the switch. If no, stay on v1.
3. **Deploy interview** with AskUserQuestion (max 4 questions per call), in two calls:
   - Call 1: where to deploy (static site, container host, cloud, or Not now), environments (production only, or staging + production), approvers (GitHub logins), domain.
   - Call 2: provider, build/run details (build command and output dir, app name, or deploy command), smoke URL per environment, and the credential checklist acknowledgement.
   - "Not now" skips the rest. Write the answers to a JSON file (schema in protocol.md).
4. `ORCH git plan` (dry) and `ORCH deploy plan --answers FILE` (print only). Put their `commands`, `settings_commands`, `files` and the credential checklist into the plan, and add the repo-flow agents (`repo-architect`, `reviewer`, `security-gate`, `release-engineer`; `main-guardian` is added by `git health --create-tasks`). The CI commands (`INSTALL_CMD`, `BUILD_CMD`, `TEST_CMD`) have no default: ask the user, pass them as `--var`.
5. **Approval gate.** The user's approval of the plan is the yes for those exact commands, and nothing else. Anything not listed needs a new approval.
6. After approval, in order:
   - `ORCH git plan --apply --yes` (remote settings and ruleset).
   - The repo-architect task runs `git plan --write` and opens a PR; the release-engineer runs `deploy plan --write` and opens a PR. Both go through the PR loop below.
   - The **user** sets secrets with `gh secret set` (see [reference/deploy.md](reference/deploy.md)). Never ask for or echo a secret value.
   - `ORCH deploy plan --answers FILE --apply --yes` (environments with required reviewers, Pages settings, non-secret variables).

## Phase 2: Architect
- Choose the architecture. Prefer the existing stack and the simplest components that meet the requirements.
- Decide the **contracts**: API schema, data models, module and file layout. Usually the first task (architect or you) writes them to files such as `contracts/` that all other agents read.
- Break the work into tasks. Each task gets one owner agent, explicit inputs, outputs, `depends_on` and `acceptance` criteria.
- Give every code task `verify` commands that fail when the work is wrong (tests, build, a smoke script). "File exists" is not a check. The commands must run unattended and finish within 10 minutes. List them in the plan: approving the plan approves running them.
- Find the parallel opportunities: frontend and backend after the contract, docs alongside implementation, QA test design alongside build, research sub-questions in parallel.
- Add a final **integration** task owned by `orchestrator`: run everything together and check the acceptance criteria.

## Phase 3: Design the agent team (dynamic)
For each agent, write a spec (full schema in protocol.md). Start from a seed role with `"extends": "<role>"` when one fits. **Invent a new specialization whenever none fits** (e.g. `payments-engineer`, `pdf-parser`, `prompt-designer`, `regulatory-researcher`). The seed library is a convenience, not a menu.

Each spec must state:
- What it owns (`owns` globs) and what it must not touch (`must_not_modify`).
- What it receives (`inputs`) and must return (`outputs`).
- How its output is validated (`validation`) and its `constraints`.
- Its tools: least privilege. Reviewers get no Write. Researchers get WebSearch/WebFetch.
- Its model and skills: see **Manager, models, skills and budget**. A task's `model` overrides its agent's. Avoid `inherit`: it follows the Opus manager.
- A `judge` agent (`extends: judge`, read-only) whenever the team writes code.
- `maxTurns` when a task could run away: it is the only hard limit on an agent's spend.
- `parent`: only for **real** nested delegation, where that agent itself spawns sub-agents. Allowed only if nesting depth is available, and capped by `max_depth`. `group` is a visual label only. Prefer a flat team: the orchestrator delegates directly.

Keep names short and kebab-case (`api`, `ui`, `schema`). They become `orch-<run>-<name>`.

## Phase 4: The plan
Present a plan containing:
1. Objectives and assumptions.
2. Architecture and contracts.
3. The team tree (`ORCH plan --check` prints it) with each agent's responsibility.
4. Task table: id, title, owner, model, size, priority, dependencies, acceptance.
5. Waves, critical path and the schedule from `plan --check` (due times, what will not fit).
6. Validation strategy.
7. A machine-readable block:

````markdown
```json orch-plan
{"title": "...", "team": {"agents": [ {agent spec}, ... ]}, "tasks": [ {task}, ... ]}
```
````

Validate it with `ORCH plan --check <plan file>` (it only reads). Fix every error and act on the warnings.

**In Plan Mode:** you may edit only the plan file. Write everything above into it, run the read-only check, then call ExitPlanMode. Do not create agent files or run state until the user approves.

**Outside Plan Mode:**
- If the team has more than `require_approval_above_agents` agents (default 3) or the plan has risky steps, show the plan and get approval first.
- If the user already told you to proceed without asking, or nobody can answer (non-interactive run), proceed and state your assumptions.
- Save the plan to `.claude/orchestrator/plans/<slug>.md` before execution.

## Phase 5: Execute
0. Fix or tell the user about anything `run init` prints as `preflight:` (`ORCH doctor` repeats the check).
1. `ORCH run init --from-plan <plan file>`. This validates the plan, writes the native agent files into `.claude/agents/`, registers them, creates persistent state and prints each agent's `subagent_type`. Then run `ORCH dashboard --open` and give the user the file path: it is their live view (`ORCH usage` prints the same numbers).
2. For each wave, in order, until every task is done:
   - Run `ORCH task start <id>` for every task in the wave. It refuses tasks that are already done, blocked, or over the retry limit. (v2: it also records the task's branch.)
   - **Launch all of the wave's agents in a single message** (several Agent tool calls) so they run in parallel. Use `subagent_type: "<orch-run-name>"` and pass the `model` that `task start` printed (retries escalate it). Start each Agent call's `description` with the `agent label` it printed (for example `Machamp: build the API`) so the user can see who is working. Each prompt follows the delegation template in protocol.md: task id, context, contract paths, exact acceptance criteria, ownership reminder, and "end with ORCH_REPORT".
   - Wait for every result. Do not start a dependent task early.
   - For each result:
     - Extract the ORCH_REPORT block.
     - **Verify it**: delegate to the `judge` (pass it the task, acceptance criteria and changed files). On PASS, record it: `task done` runs the task's `verify` commands and checks which files really changed; do not read the diff. On FAIL, `task fail`, then retry with the judge's feedback. Without a judge, verify it yourself. (v2: the PR reviewer is the judge.)
     - v2: run the PR loop below before recording the task.
     - Then record it: `ORCH task done <id> --report - <<'EOF' … EOF` (add `--cwd <worktree>` if the agent worked in one), or `ORCH task fail <id> --reason "..."`. If `done` refuses, treat it as a failure: do not work around it.
   - Act on `issues`. Route a cross-boundary change request to the owner with `ORCH task add <id> --title ... --agent <owner> --depends-on ...`, then delegate it.
3. **Failures:**
   - Use `ORCH task retry <id> --reason "<specific feedback>"`, then re-delegate with the feedback and the previous report.
   - After `max_retries`, stop retrying. The task and everything that depends on it move to the backlog automatically; finish the rest and report the backlog.
   - Never mark a failed task done.
4. **Agent not found.** Claude Code picks up new agent files asynchronously, so spawns right after `run init` often return "Agent type … not found".
   - Don't wait. Delegate the same task immediately to `subagent_type: "general-purpose"`, with a prompt that starts with the exact output of `ORCH agent prompt <name>`, followed by the task message.
   - Pass `model` on that call too, or it silently runs on your own model. Skills are not preloaded this way: tell the agent to load each of its `skills` with the Skill tool first.
   - The `<agent-definition name="…">` header lets the ownership hook recognise the agent, so its boundaries are still enforced.
   - Try the native `subagent_type` again for later waves. It usually loads within a few minutes.
5. **Isolation:** pass `isolation: "worktree"` on the Agent call when a task is risky, and **always** for code tasks that run in parallel in the repo flow (they switch branches). `task start` says when. Merge a worktree branch only after validation.
6. **Agent teams** (only if `ORCH env` shows the flag on and the session is interactive):
   - You may spawn teammates (Agent call with a `name`) and coordinate through SendMessage and the shared task list.
   - Still mirror state into `ORCH task` so the run can be reported and resumed.
   - Otherwise, use subagents as described above.
7. The user watches the dashboard: after each wave write **one line** in chat (done, next, anything cut or failed). Do not paste status tables.

## PR loop (v2, per task, only when `git.enabled`)
Every code task ends in a merged PR. Raw `git push` to base and raw `gh pr merge` are denied by the Bash guard; use only these commands.
1. `ORCH task start T` records the branch (`orch/<run>/<t>-<slug>`).
2. **Author**: `git switch -c <branch> <remote>/<base>`, commit with conventional commits plus the trailer `Orch-Task: <run>/<T>`, then `ORCH pr open T` (it pushes and opens the PR; never force-push). Put the commit flags (from `ORCH git identity <agent>` or the `commit with:` line of `task start`) in each author's delegation message; the author commits with `git <commit_flags> commit`, never adds a Claude co-author trailer, and `pr open` returns `identity_warnings` if a commit has another author.
3. **Reviewer** (a different agent, read-only): reads `gh pr diff`, checks it against the acceptance criteria and contracts, then `ORCH pr review T --verdict approve|changes [--body-file F]`. A `changes` verdict needs actionable comments. Authors cannot review their own PR.
4. On `changes`, the author fixes and runs `ORCH pr open T` again (it pushes to the same PR and voids the old verdict). Repeat until `approve`.
5. **Round limit.** `pr review` exits 3 with `escalated: true` at `max_review_rounds` (2). A further `changes` verdict is refused: approve it with the rest in the backlog, or skip the task and tell the user.
6. **Security gate.** Required checks (`ci`, `codeql`, `orch/review`) must be green; the `security-gate` agent triages code-scanning, Dependabot and secret alerts. Never weaken a check to make it pass.
7. Poll `ORCH pr status T` (or `--all`) until `gate.ready`. `blocked_by` says what is missing.
8. `ORCH pr merge T` (main session only). It exits 3 if the gate is not met. If `git.auto_merge` is false it needs `--yes`, which means the user approved this merge. Use `--dry-run` to preview.
9. `ORCH task done T --report -`. Merging does not mark the task done.

**Agent identity.** Commits are authored as `<Pokemon> <agent> agent` with the user's own email plus-addressed (`local+agent@domain`; `git.agent_email_mode: same` uses the exact email). GitHub links a commit to an account by email, so plus addresses show a default avatar. For an agent to have its own avatar, set `git.agent_emails` to an address of a separate account (for example a bot account). Squash merges keep agent credit through `Co-authored-by` trailers (or set `merge_method` to `rebase` to keep authors on base).

## Main health (v2)
Run `ORCH git health` after each merge and before `run close`. Exit 0 is healthy; exit 3 is unhealthy (failing CI on base, or blocking code-scanning, Dependabot or secret alerts). If unhealthy, run `ORCH git health --create-tasks` to add `main-guardian` tasks (add a `main-guardian` agent first with `team create` if none exists). Those tasks go through the same PR loop. Do not close the run while base is unhealthy unless the user accepts that.

## Deploy (v2, gated)
A merge to base starts the generated deploy workflows. Each one waits in GitHub for an environment reviewer, the human. Tell the user a deploy is waiting; **never approve it, never trigger it, never set secrets**. There is no deploy command in the CLI. After approval, check the smoke test result and report it.

## Integration and validation
- Run the orchestrator-owned integration task yourself: build, full test suite, end-to-end checks against the acceptance criteria. Then review the combined diff once, as the Opus manager. Anything that would deploy or touch external services needs approval first.
- Route each fix to the owning agent as a new task. Do not patch other owners' areas silently. Small glue changes in files you own are fine.
- v2: run `ORCH git health` first; report its result.
- Finish with `ORCH status --full` (writes `report.md`), then `ORCH run close`. That removes the run's temporary agents.
- Before closing, offer to keep any useful agent as a reusable one: `ORCH agent promote <name> --to project|user`. Only with the user's yes.

## Final report to the user
- What was built and where.
- The team table: agent, responsibility, status. Report failed agents and tasks honestly.
- Validation results: what was run and its outcome, plus anything not run and why.
- Open issues and next steps.

## Resume
1. `ORCH run list`, then `ORCH status` on the active run, or the one the user names; `ORCH run activate <id>` if needed.
   - If the deadline has passed, ask the user whether to continue, then `ORCH run extend` (it restores cut tasks).
2. **Done** tasks are not repeated. `ORCH task start` refuses them.
3. **In-progress** tasks were interrupted. Inspect what they left on disk.
   - If the work looks complete: `task done` with a report you write from that inspection (say it was reconstructed). It runs the `verify` commands, so unfinished work is refused.
   - Otherwise: `task retry <id> --reason "interrupted"`, then re-delegate with "continue from current state: inspect existing files first".
4. Continue the waves from the first ready task.

## Learn from the run (after the run, not during)
- `ORCH stats` shows failing roles and vague agent definitions.
- For each insight that should change future plans, record a one-line lesson with `ORCH lessons add --tag <domain> "<lesson>"`. Example: "contracts first: UI/API mismatches caused 2 retries".
- Improving templates or this skill is a proposal to the user, never an automatic edit.

## Environments without subagents (claude.ai uploads, restricted sessions)
- Follow the same phases.
- Run the plan sequentially yourself, one role at a time, using each agent definition as a checklist.
- Say explicitly that no subagents were spawned. Hooks and persistent state may be missing: see environments.md.

Files in this skill

  • SKILL.md12.9 KB
  • config/defaults.json364 B
  • reference/environments.md2.5 KB
  • reference/protocol.md6.5 KB
  • scripts/orch.py70.1 KB
  • templates/agent.md.tmpl2.2 KB
  • templates/roles.json14.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.