Skip to content

About

Manager/worker orchestration plugin for Claude Code — delegate implementation and token-hungry work to headless workers backed by any Anthropic-compatible API (z.ai GLM, Kimi, DeepSeek, LiteLLM...)

Resources

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

model-orchestration

Manager/worker orchestration for Claude Code. Keep your smartest model as the manager — planning, judging, reviewing — and delegate implementation and token-hungry work to isolated, headless Claude Code workers backed by any Anthropic-compatible API: z.ai GLM, Kimi, DeepSeek, MiniMax, LiteLLM/other proxies, or anything else that speaks the Anthropic Messages API.

Why: flat-rate coding plans (like z.ai's GLM Coding Plan) make near-frontier implementation effectively free, while your premium subscription is reserved for the judgment work that actually needs it. Every worker is a separate Claude Code identity (~/.claude-workers/<name>/) — your main Anthropic login, settings, and history are never touched.

Install

/plugin marketplace add divyamrastogi/model-orchestration
/plugin install model-orchestration@model-orchestration

Quick start

/model-orchestration:setup-worker

That's the whole command: Claude shows you a picker of known providers — z.ai GLM, Moonshot Kimi, MiniMax, DeepSeek, or any custom Anthropic-compatible endpoint — and configures the ones you select (endpoints and model mappings come from bundled presets). The only thing you supply is your API key: Claude tells you where to get it and which file to put it in (keys are never passed on the command line or requested in chat). A live smoke test confirms each worker before it's used.

That's it — delegation is now the default. A SessionStart hook injects orchestration rules into every session: for every task, Claude breaks the work into subtasks and routes them to external workers, Sonnet subagents (tasks needing in-session tools), or Haiku subagents (mechanical work), keeping planning and review on your premium model. With no workers configured, the defaults route to Claude subagents only. The hook exits silently when MODEL_ORCHESTRATION_DELEGATION is off (0/false/no/disabled, any case), honors a conversational "don't delegate" for the rest of the session, and has Claude load the orchestrating-model-workers skill before its first dispatch.

Turning delegation off

{"env": {"MODEL_ORCHESTRATION_DELEGATION": "off"}}

Set it in ~/.claude/settings.json (everywhere) or a project's .claude/settings.json (that project only); takes effect next session. Saying "don't delegate" in chat opts out for the current session only.

You can also delegate explicitly:

/model-orchestration:delegate glm implement the pagination fix described in docs/plan.md

Either way, the manager writes the spec, dispatches the worker, audits the result against the acceptance criteria, sends it back with revision notes if it misses, and only escalates after a second miss. Judge the output, not the price tag.

What's inside

Piece Purpose
skills/orchestrating-model-workers/ The knowledge: setup workflow, dispatch patterns, revision gate, and the non-obvious traps (env-var inheritance breaking auth, headless onboarding)
scripts/setup-worker.sh Generic worker manager: create / set-key / finalize / refresh-models / list / remove
commands/setup-worker.md /model-orchestration:setup-worker — guided setup
commands/delegate.md /model-orchestration:delegate — explicit dispatch + audit loop
commands/savings.md /model-orchestration:savings — full token-savings report
hooks/session-start.sh Makes delegation the default: injects rules + worker inventory each session, plus the all-time savings line; auto-refreshes each worker's models daily, skipping local (localhost) workers (opt out: touch <worker-dir>/.no-auto-refresh); opt out of delegation via env or "don't delegate" in chat
hooks/post-dispatch.sh PostToolUse hook: one-line savings notice after each worker dispatch
agents/worker-dispatch.md Bridge agent so Workflow scripts and the Agent tool can fan tasks out to workers (agentType: 'model-orchestration:worker-dispatch')
scripts/usage.py Token-savings accounting: parses manager + worker transcripts, keeps the usage ledger, prints the notices and the report
tests/test_usage.py Unit tests for the savings accounting (python3 -m unittest discover -s tests)
skills/.../templates/delegation-rules.md Drop-in CLAUDE.md section to make delegation a standing behavior

Local models

Ollama (≥ v0.14.0) exposes a native Anthropic-compatible endpoint, so fully local workers work too: ollama is a built-in preset, and the setup command offers your locally pulled models as tier mappings (API key is the literal string ollama). llama.cpp's llama-server, LM Studio, and LiteLLM/Olla proxies plug in the same way via --base-url. See the skill's local-models section for verified caveats (MLX variants, older-Ollama count_tokens hangs) and realistic expectations — local workers suit privacy/offline and simple bulk tasks rather than primary implementation.

Seeing your savings

The plugin tracks how much work your workers took off Claude in fresh tokens: input_tokens + cache_creation_input_tokens + output_tokens per assistant message, deduplicated by message id. Cache reads are deliberately excluded — they re-send text the provider already held in context at a steep discount, so counting them would drown the signal (a big cached prompt is ~90% cache reads on either side). Savings % is worker fresh tokens over all fresh tokens in the sessions that dispatched workers.

It surfaces in three places:

  • after every worker dispatch, a one-line notice like model-orchestration: workers handled 22% of this session's tokens (glm 35k vs Claude 123k)
  • at session start, an all-time line like model-orchestration: workers have handled 1.2M tokens (31% of the total across 8 sessions)
  • on demand: /model-orchestration:savings prints a full per-worker, per-model report

The numbers come from a small ledger at ~/.claude-workers/.usage/ledger.json built from the JSONL transcripts Claude Code already writes (your manager session and subagents on one side, each worker's own project transcripts on the other). To silence the savings lines, set MODEL_ORCHESTRATION_SAVINGS=off (settings.json "env", same value style as MODEL_ORCHESTRATION_DELEGATION).

Known limits: a new worker transcript is credited to whichever session's dispatch hook sees it first, so two sessions dispatching at the same time can swap credit. A dispatch run in the background reports at launch, before the worker finishes; its tokens land on the next notice or in /savings.

Requirements

  • Claude Code ≥ 2.x with your normal Anthropic login (the manager)
  • An API key for a provider exposing an Anthropic-compatible endpoint
  • python3 on PATH (used for safe JSON editing)
  • macOS or Linux

Security notes

  • API keys live only in ~/.claude-workers/<name>/settings.json (chmod 600).
  • The setup script refuses keys as CLI arguments (shell-history leak); add them by editing the file or piping via stdin from a secret manager.
  • Workers run with whatever --permission-mode you dispatch them with; default is Claude Code's normal prompting.

Privacy

No telemetry, no analytics, no plugin-operated endpoints — keys and task content go only to the providers you configure. See PRIVACY.md.

License

MIT

About

Manager/worker orchestration plugin for Claude Code — delegate implementation and token-hungry work to headless workers backed by any Anthropic-compatible API (z.ai GLM, Kimi, DeepSeek, LiteLLM...)

Resources

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages