Agent Orchestrator for OpenCode and Claude Code

Project: claude-opencode-subagents (source private)  ·  Stack: TypeScript, OpenCode plugin API, Claude Agent SDK, Vitest

Timeline: 22 March to 26 April 2026  ·  244 commits  ·  96 tagged releases (v0.1.2 to v0.1.100)  ·  373 tests in 17 files, CI on lint, knip, typecheck, test, build

The deep dive covers the code and tradeoffs.

Problem

I wanted one agent to own a task while the hands-on work ran in Claude Code. One session that investigates, edits, and checks itself tends to edit early. A fresh session per step loses the context the last one built.

Constraints

  • Investigation must not edit files, enforced in code, not in the prompt.
  • Engineers keep their Claude session across assignments and process restarts.
  • Two OpenCode sessions in one repo must not share engineers.
  • Undo in the manager session must also undo the engineers’ work.

Design

1
2
3
4
5
6
cto (OpenCode, reads and delegates, never edits)
 ├─ dispatch_engineer ─> Tom | John | Maya | Sara | Alex   (persistent Claude Code sessions)
 ├─ plan_with_team ────> lead + challenger in parallel ─> write-restricted synthesis
 ├─ run_browser_qa ────> BrowserQA (Playwright, never writes)
 ├─ run_code_review ───> fresh read-only reviewer, focus inferred from changed paths
 └─ git, approval policy, team status, reset
  • Modes: explore sessions get write tools and write-like Bash denied in the SDK canUseTool callback.
  • State: one team file per CTO session, per-team write queue, atomic rename. Busy is a 15-minute lease, not a lock.
  • Context: token, cost, then turn-count estimates drive warnings. Sessions reset only on a real context-exhausted error.
  • Signals: implement raises review and verify flags. Verify clears only on VERIFY_STATUS: pass. Commits warn but do not block.
  • Undo: a CTO revert sends /undo to each engineer’s Claude session once per later assignment.

What changed and why

DateChangeWhy
23 MarRemoved per-run git worktreesOne shared worktree, one implementing engineer at a time
26 MarWorktree-wide “active team” replaced by one team per CTO session, 17 hours after shippingTwo sessions could share engineers
16 to 17 AprRemoved the engineer wrappers, the architect/planner wrapper, and the claude bridge toolTwo model hops per assignment; assignments now reach Claude verbatim
23 to 26 AprReviewer moved from Claude to an OpenCode agent on the CTO’s model, fresh session per reviewA different model family reviews, without the CTO’s reasoning

Results

  • 373 passing tests, including restart recovery, concurrent writes, and 19 undo cases.
  • /reflect asks each engineer used in a session what in its instructions misled it.
  • Known limits: single-writer is a prompt rule; Bash write detection is a regex list.

Telescope / search portfolio

:help keys

j k
Scroll down / up
gg G
Jump to top / bottom
/ Ctrl K
Search the portfolio
?
Show this help
Esc
Close