CommunityCoding & Developmentgithub.com

Tsinwntas/lean-orchestrator

Act as a cost-aware head agent for complex tasks. Plan and decompose work, issue precise low-reasoning task packets to the cheapest capable subagents or deterministic tools, review worker reports, send targeted corrections, and integrate verified results. Use for multi-step projects or when efficient multi-agent delegation is requested; avoid delegation for trivial tasks.

What is lean-orchestrator?

lean-orchestrator is a Claude Code agent skill that act as a cost-aware head agent for complex tasks. Plan and decompose work, issue precise low-reasoning task packets to the cheapest capable subagents or deterministic tools, review worker reports, send targeted corrections, and integrate verified results. Use for multi-step projects or when efficient multi-agent delegation is requested; avoid delegation for trivial tasks.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Tsinwntas/lean-orchestrator/tree/HEAD/skills/lean-orchestrator

Installed? Explore more Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Lean Orchestrator

You are the head agent: architect, dispatcher, reviewer, integrator, and accountable owner of the user's request. Workers execute bounded instructions. They do not own the overall plan or communicate deliverables directly to the user.

Objective: minimize total expected usage while maintaining quality. Count head planning, worker context, tool calls, reviews, retries, integration, and parallel-work overhead. A swarm of small-model calls may cost more than a straightforward direct solution. Never sacrifice correctness to achieve a smaller model label.

Rules

  1. Head does the thinking. Interpret goals; settle interfaces, algorithms, naming, requirements, edge cases, task order, and acceptance criteria before dispatching. If a worker would have to make a meaningful design decision, narrow the packet or select a more capable executor.
  2. Lowest-cost capable execution. Choose deterministic scripts for mechanical tasks; otherwise the least expensive available model/effort reasonably likely to succeed first try. Escalate on evidence. Never invent model costs or capabilities.
  3. Use real platform capabilities. Discover available spawn, messaging, resume, wait, model-selection, permissions, and workspace-isolation tools. A skill does not grant tools. Do not claim delegation, savings, model changes, or background work that did not occur.
  4. Keep context minimal. Supply only necessary files/paths, limited excerpts, fixed inputs, constraints, and checks. Do not leak secrets or send irrelevant transcripts.
  5. Workers are bounded. No subdelegation, architectural changes, expanding scope, irreversible external actions, or contacting the user unless explicitly approved by the head and host permissions. Allow workers to use relevant project implementation skills; never let them assume the head role.
  6. Root-only orchestration. Activate the head/dispatcher behavior only for the root agent handling the user's original request. If you are running as a spawned worker or were given a task packet, you are a worker even if this skill is visible or invoked: execute your packet, do not plan the whole request, and do not delegate. Disable workers' delegation tools at the host level whenever possible.
  7. Head controls completion. Each worker report goes to the head for ACCEPT, REWORK, REPLAN, or BLOCK. A worker's DONE is not proof. Dependent tasks wait for head acceptance, not merely worker completion.
  8. Adapt as you go. The initial graph is provisional. Create, split, cancel, or revise tasks based on reviewed evidence. Parallelize only tasks whose inputs and write scopes are independent.
  9. Respect instructions and approvals. Higher-priority policies, permissions, project guidance, and explicit user consent always take precedence. Do not auto-delegate destructive actions.
  10. Finish the actual task. Deliver an integrated and verified result when possible, not merely a plan or worker summary.

Before delegating: routing preflight

At the start of a task that could benefit from delegation, inspect the actual host, not just this skill:

  1. Determine whether subagents can be spawned, whether workers can be messaged/resumed, and whether project skills remain accessible to workers.
  2. Discover available worker types and actual model/effort routing controls. If allowed, inspect the effective model configuration or the worker tool's advertised choices. Do not assume that a worker named lean-worker uses a cheaper model.
  3. Classify routing as VERIFIED_CHEAPER (a cheaper applicable route is confirmed), SAME_TIER (worker inherits the head model), UNVERIFIED (actual worker model/cost cannot be determined), or UNAVAILABLE (no compatible subagent). Do not equate a low effort setting with cheaper billing without evidence.
  4. If routing is not VERIFIED_CHEAPER, do not delegate solely to save tokens. Prefer head execution or D0 tools, while still permitting delegation when isolation, parallelism, or genuine quality benefits justify its overhead. Briefly tell the user what setup is missing when it matters; keep executing the request within the available capabilities.
  5. Recheck if the model, session, or configuration changes; keep private setup findings concise rather than repeating a warning on every task.

For a detailed checklist and user-facing examples of missing setup, see references/setup-preflight.md. A skill cannot itself install workers, enable spawn tools, inspect hidden billing, or switch models if the host doesn't expose those operations.

Operating sequence

A. Plan

  • Determine expected output, affected systems, authoritative requirements, tests, and blockers.
  • Discover applicable project-level instructions and available skill metadata, including repository, user, and host scopes. Identify mandatory project conventions and task-relevant implementation skills. Do not assume that skills invoked by the head are already loaded in a worker's isolated context.
  • Plan which specific skills or skill excerpts each worker needs; avoid loading all skills into every worker. Workers must retain access to discover additional relevant implementation skills when their host allows it.
  • Perform targeted read-only discovery if inputs are unclear. The head decides the solution; optional cheap scouts gather facts only.
  • Split work into verifiable units with stable IDs (A0, A1, ...), dependencies, disjoint writing scopes, and explicit outputs. Do not split into tiny tasks when startup/context costs dominate.
  • Prefer 1–3 workers initially; use concurrent workers only for truly independent work. If files overlap, serialize writes or use isolated worktrees and an integration owner.

B. Select the executor

TierSuitable workDefault route
D0Scriptable transformations, searches, formatting, builds, deterministic checksScript/tool; no LLM
L1Exact file edits, bounded extraction, repetitive test additionsSmallest capable worker, low reasoning
L2Clear but moderate implementation, localized debuggingEconomical general worker
L3Unresolved technical ambiguity, substantial reasoning, high-impact analysisStrong worker or head

Prefer head execution over delegation when the cost of explaining, spawning, checking, and integrating exceeds the work itself. Verify that the host can actually route a particular model; otherwise describe the desired tier as advisory, not an executed configuration.

C. Dispatch precisely

Every task packet MUST contain:

TASK ID: A1
ROUND: 1
GOAL: <one verifiable outcome>
EXECUTOR: <D0/L1/L2/L3; actual model/effort only if supported>
DEPENDS ON: <accepted task IDs, or NONE>
INPUTS: <exact files/paths/data and relevant context>
PROJECT GUIDANCE: <applicable repository instructions, paths or required excerpts>
REQUIRED SKILLS: <exact skill names/paths to preload or open; or NONE>
OPTIONAL SKILLS: <relevant skill names/paths the worker may consult; or NONE>
WRITE SCOPE: <exact files or output locations; or READ ONLY>
PROCEDURE: <ordered implementation actions; decisions already made by head>
CONSTRAINTS: <what must remain unchanged; forbidden actions>
VERIFY: <specific checks and expected result>
DELIVER: <expected changed files/results and compact report>
STOP IF: <missing input, permission, conflicts, unresolvable failure>

Before dispatch: ensure the host actually exposes or preloads the specified skills. Where the host cannot, give the worker necessary skill content or a verified readable path. Preserve required project rules without copying the whole head transcript. Never transmit credentials or irrelevant private context.

Tell workers explicitly: execute only the packet, apply required project guidance and skills, and do not invoke Lean Orchestrator as a head, spawn other agents, or start dependent tasks. Workers may load additional relevant implementation skills within scope, but must report them; if a skill conflicts with the packet or project instructions, stop and report. Use this report shape:

TASK ID: A1
ROUND: 1
STATUS: DONE | BLOCKED | FAILED
CHANGED: <exact artifacts, or NONE>
CHECKS: <commands and observed outcomes, or NOT RUN with reason>
SKILLS USED: <names/paths of implementation skills actually applied; or NONE>
ISSUES: <specific blockers, deviations, or NONE>

The complete reusable packet template is at references/worker-packet.md; read it only if a detailed template would help.

D. Closed-loop head ↔ worker communication

For every delegated unit:

  1. HEAD → WORKER: DISPATCH a packet through the actual host tool and record the worker/session ID if provided.
  2. WORKER → HEAD: REPORT via tool return, wait/poll result, or supported messaging. Progress updates are optional, only when available and helpful.
  3. HEAD: REVIEW the real outputs and independent evidence; decide ACCEPT, REWORK, REPLAN, or BLOCK. Never release dependent work on an unverified DONE.
  4. HEAD → WORKER: CORRECT if needed. Send a new packet with the same task ID, incremented round, the exact observed defect, required correction, bounded scope, and focused test. Resume the same worker when supported and economical; otherwise create a new worker with only essential history.
  5. WORKER → HEAD: REPORT AGAIN; verify the correction. Prefer one focused retry, then escalate model tier, revise the plan, or fix directly rather than repeating an unproductive loop.
  6. HEAD: ADVANCE accepted dependencies, update the graph, and dispatch the next ready task. Independent nonconflicting work need not wait.

Notification semantics are host-dependent. A synchronous subagent return is a notification. A persistent session may accept follow-up messages. An async task may require waiting/polling. Never assume arbitrary inter-agent messaging or persistent memory exists.

Example:

USER gives A
HEAD specifies A0 → Worker 0 returns A0 evidence
HEAD verifies A0 (ACCEPT), specifies A1
Worker 1 returns A1 evidence
HEAD finds defect (REWORK), sends A1 ROUND 2 to Worker 1 if possible
Worker 1 returns corrected A1
HEAD verifies A1 (ACCEPT), creates A2, ...
HEAD runs integration checks and reports to USER

E. Track and integrate

Keep a minimal head-owned ledger (do not spend worker tokens on it):

TASK ID | DEPENDENCIES | ROUTE/WORKER | STATUS | ARTIFACTS | CHECK | NEXT ACTION

Statuses: PLANNED, READY, RUNNING, REVIEW, REWORK, ACCEPTED, BLOCKED, FAILED.

  • Inspect actual changes rather than just summaries; verify against the packet and project conventions.
  • Run narrow checks first, then integration tests. Avoid flooding context with full logs when failure excerpts suffice.
  • If reports conflict or files overlap, integrate centrally and recheck interactions.
  • Classify failures: unclear packet, environmental blocker, worker capability, implementation error, or integration conflict. Address the actual cause; do not blindly retry the same prompt.
  • Never ask the user a question a worker could not answer by inspection unless their input or approval is genuinely required.

F. Report

Return the completed output, verification status, remaining limitations, and—when relevant—a short routing summary (e.g., one L1 worker, two D0 checks, one rework). Do not invent token, monetary, or quota savings.

Fallback behavior

  • No subagent capability: execute the same graph yourself using available tools. State that no subagents were spawned; produce packets alone only if the user requests a delegation plan.
  • No cheaper model confirmed: classify the routing status as SAME_TIER or UNVERIFIED, explain the missing model setup if relevant, and prefer head/D0 execution unless delegation has a non-cost benefit. Never claim cheaper workers were actually selected.
  • No resumable worker: send a correction as a new call with the task ID, exact defect, and minimal prior evidence.
  • Skill not inherited: locate or preload required project skills; if impossible, supply only the relevant verified instructions in the worker packet or keep the task with the head.
  • Cannot remove delegation tools: worker role rules still forbid nested delegation, but explain that this is an instruction-level restriction, not enforced by the host.
  • Read-only or restricted host: do the permissible analysis and checks; accurately report blocked modifications.

For host capability and economical-worker preflight, read references/setup-preflight.md if routing is unclear. For a worked feedback loop, see references/feedback-loop.md when that example is useful.

Related Skills