orch

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: MIT

README

Orch

Orch is a development orchestrator for AI coding agents — currently the Claude Code CLI and the Codex CLI. You keep working in your agent of choice the way you already do; Orch sits underneath it and does two things:

  1. Spends your tokens where they matter. A strong "frontier" model stays in charge of planning, architecture, and final review, while routine work — exploring the codebase, writing the code, reviewing diffs — is delegated to cheaper, faster models at tuned reasoning-effort levels. You choose exactly which model does which job; Orch enforces that choice mechanically instead of hoping the agent remembers.

  2. Keeps changes disciplined. No matter which model wrote the code, every change to tracked files goes through the same pipeline: a GitHub issue, an isolated git worktree, a pull request, an independent review by a different model, CI, and finally a merge that only a human can approve. An agent can never quietly edit your working tree — writes outside the pipeline are blocked at the tool level, not by prompt instructions.

The full product definition lives in ORCH-PRD.md.

Status: pre-alpha. The shared core (a single Go binary) is complete and tested; the host adapters that plug it into Claude Code and Codex are the current phase of work. Until an adapter lands you can install the binary, initialize a repository, and manage configuration — but the end-to-end orchestrated workflow is not yet drivable from an agent session.

How it works, in short

Orch has two operating modes:

  • Assist (the default): the agent can read anything and answer questions, but writes to tracked files are blocked. This is the safe everyday mode — investigation, explanation, planning.
  • Delivery: entered only for an approved, task-scoped plan. Each task in the plan becomes a GitHub issue and an isolated worktree; an implementer model does the work there; a reviewer model reviews it; CI runs; you approve the merge on GitHub. When every task is merged or abandoned, Orch returns to Assist automatically.

Work inside Delivery is divided among five roles, each pinned to a model and effort level you configure:

Role What it does
Architect Plans, routes work, makes final calls — your strongest model
Scout Read-only exploration and fact-finding — cheap and fast
Implementer Writes the code in the isolated worktree
Specialist Takes over risky or hard tasks (security, concurrency, migrations…)
Reviewer Independently reviews every PR — never the model that wrote it

Routing is deterministic: risky domains or hard tasks force the Specialist and a strong Reviewer, and when a model fails at a task it is retired for that task permanently and the next candidate steps up — escalating back to the Architect if everything else is exhausted.

Install

Download the static binary for your OS and architecture from GitHub Releases (orch_<os>_<arch>, Windows binaries end in .exe), then verify its SHA-256 against the SHA256SUMS file published with the release before running it — don't skip this:

# Linux / macOS
sha256sum --check --ignore-missing SHA256SUMS

# Windows (PowerShell): compare against the matching SHA256SUMS line
(Get-FileHash orch_windows_amd64.exe -Algorithm SHA256).Hash

Rename it to orch (or orch.exe) and place it on your PATH. orch status and orch doctor print the binary's release version on their first line; adapters and docs pin a release version.

Alternatively, build from source with Go 1.26+ (source builds report version dev):

git clone https://github.com/kninetimmy/orch.git
cd orch
go build ./cmd/orch        # produces ./orch (orch.exe on Windows)

or install straight onto your PATH:

go install github.com/kninetimmy/orch/cmd/orch@latest

Delivery mode additionally needs git and the GitHub CLI (gh) authenticated against the repository's remote. Assist mode works without a remote.

Using it

Run orch init in the repository you want to orchestrate. It detects your environment (hosts, git, gh, memhub), interviews you about which hosts to enable and which models to use — sensible defaults are offered for every question — and then bootstraps everything through its own pipeline: the configuration lands as a pull request you review and merge, not as a silent write to your working tree.

Day-to-day commands:

orch status           Show mode and configuration summary
orch doctor           Check environment and configuration health
orch configure        Change committed settings (delivered as a PR)
orch configure-local  Change machine-local overrides (applied directly)
orch resume           Reconcile an interrupted Delivery run and continue
orch abort            Stop a Delivery run and return to Assist
orch metrics          Local usage metrics (not implemented yet)

orch run and orch guard also exist but are plumbing — the host adapters drive them; you never call them by hand.

Settings — what you can tune

Configuration lives in two TOML files under .orchestrator/:

  • config.toml — committed to git, shared by everyone on the repo. Changed via orch configure, which delivers the edit as a reviewable PR.
  • config.local.toml — machine-local and gitignored, for personal preferences. Changed via orch configure-local, applied directly.

Policy decisions can only live in the committed file — a local override can never weaken the shared workflow rules. What goes where:

Setting Values (default) Local override?
hosts.claude / hosts.codex enable a host by giving it a role table no (committed)
hosts.<host>.roles.<role>.model exact model version string yes
hosts.<host>.roles.<role>.effort low medium high (+ xhigh on claude) yes
concurrency.max_subagents integer ≥ 1 (3) yes
metrics.enabled true / false (false) yes
merge.strategy squash rebase merge-commit (squash) no (committed)
memhub.mode required best-effort off (no default — you choose) no (committed)

The six roles per enabled host are architect, scout, implementer, specialist, reviewer, and review_downgrade (the cheaper reviewer Orch is allowed to use only when a task is provably low-risk). Every role pins an exact model version — never an alias — so what ran is always auditable. The defaults orch init offers:

Role Claude Code Codex
Architect claude-opus-4-8 / xhigh gpt-5.6-sol / high
Scout claude-sonnet-5 / low gpt-5.6-terra / low
Implementer claude-sonnet-5 / xhigh gpt-5.6-terra / high
Specialist claude-opus-4-8 / high gpt-5.6-sol / medium
Reviewer claude-opus-4-8 / high gpt-5.6-sol / medium
Review downgrade claude-sonnet-5 / high gpt-5.6-terra / high

Typical tuning: point a role at a bigger/smaller model on one machine via configure-local (e.g. run the Architect on a frontier model only where you have the subscription), raise max_subagents on a beefy machine, or enable local metrics while experimenting. Every applied override is listed by orch status and orch doctor, so the exact models in effect are always visible.


Under the hood

This section is for contributors and the curious; nothing here is needed to use the tool.

Enforcement, not convention

The mode rules are enforced mechanically. Host adapters wire the agent CLI's pre-write hooks to orch guard, which resolves a closed decision table: in Assist, any write to a tracked file inside the repo is denied (git-ignored paths are allowed); in Delivery, writes are allowed only inside a worktree registered to the active run, in a writable phase, with the worktree's HEAD on the registered branch. .orchestrator/ state and anything under .git are never writable. The guard fails closed: if it cannot determine the facts, it denies.

Delivery is exclusive across hosts and machines: a lock file (.orchestrator/delivery.lock, created O_CREATE|O_EXCL) is the lock, and there is no automatic staleness takeover — recovery is always an explicit orch abort or orch resume. Run state is schema-versioned JSON at .orchestrator/state.json (machine-local, atomic writes, fail-closed loads), persisted after every sub-step so a crash at any point is recoverable.

The Delivery pipeline

A run starts at the plan gate: a schema-versioned plan document (issues, dependency waves, risk facts) is validated fail-closed, and a gate document derives each issue's executor and reviewer from facts alone via the routing table — the model never picks its own reviewer. Activation then creates the GitHub label taxonomy, one issue per task carrying a structured audit record (rendered markdown plus canonical JSON in a managed body region — exact model, effort, and routing rationale, mirrored onto the PR), and one branch + isolated worktree per issue under .orchestrator/worktrees/.

Each issue then walks a closed lifecycle driven by plumbing verbs: dispatch (dependencies must be merged; branch fast-forwarded onto the default branch) → pr-open (clean, strictly-ahead, orphan-PR guarded) → review (routed reviewer verified against the live PR head) → ci → merge-report (pins the approved head SHA) → merge (human-approved, re-checked against the live PR, pinned with --match-head-commit) → cleanup → complete (fast-forward the primary checkout, auto-return to Assist). Failures route through escalate (the routing ladder), block (closed failure classes; a secret found stops the whole run), or abandon. Errors never mutate state; state advances only on success.

orch resume reconciles an interrupted run against GitHub reality in three strict stages — observe (all reads up front), classify (a pure 30-row decision table), apply (one state write, skipped when already converged). It never fabricates approval, never advances past the human merge gate, and never deletes or recreates anything.

Routing and escalation

internal/routing is pure and deterministic: a first-match-wins table over a closed nine-domain risk enum plus difficulty/consensus facts. Reviewer downgrade requires four affirmative facts; any conflict silently takes the stronger route and says so in the rationale. On failure, escalation retires the failed model permanently for that issue (an effort bump is still a retry; a model swap is not), restores the strong reviewer on any reroute, and resolves exhaustion to an explicit return-to-Architect — the code never ranks model strength on its own.

Package layout
Path Purpose
cmd/orch/ CLI entry point
internal/cli/ Command dispatch: human commands plus the run/guard plumbing verbs
internal/config/ Committed-config schema, fail-closed validation, local-override overlay, canonical TOML writer
internal/state/ Assist/Delivery mode and per-issue run state (schema-versioned JSON, atomic writes)
internal/lockfile/ Exclusive cross-host Delivery lock
internal/paths/ Safe-path primitives: canonical paths, containment, repo-root discovery
internal/execx/ Injectable external-command runner shared by the git/gh callers (+ scripted test fake)
internal/gitops/ Delivery git mechanics: branches, worktrees, push, fast-forward — policy-free
internal/ghops/ GitHub mechanics via the gh CLI: labels, issues, PRs, gated merge, CI state
internal/manifest/ The issue/PR audit record — lossless render/parse over a managed body region
internal/routing/ Pure role routing and the escalation ladder
internal/guard/ Mechanical pre-write enforcement behind host PreToolUse hooks
internal/run/ The Delivery run engine: plan gate, activation, per-issue lifecycle, resume
internal/instructions/ Managed instruction-block engine for AGENTS.md/CLAUDE.md
internal/question/ Host-neutral native question contract (documents out, answer sets back)
internal/interview/ Pure question engines for init, configure, and configure-local
internal/bootstrap/ Mechanical PR-flow executors behind init --bootstrap and configure --deliver
adapters/claude/, adapters/codex/ Host-adapter artifacts (skills, hooks, templates) — in progress
ORCH-PRD.md Product requirements — source of truth for v1
Design principles
  • Fail closed. Unknown config keys, schema drift, unreadable locks, indeterminate checks — everything unprovable is denied with a named remediation.
  • Mechanics are policy-free. gitops/ghops/manifest know how; internal/run alone decides when and why.
  • Humans gate merges. Orch pins the approved head SHA and refuses if the PR moved after approval; the merge itself happens on GitHub.
  • Everything auditable. Exact model versions and routing rationale live in the issue/PR audit record and in orch status.
Build / test

Requires Go 1.26+.

go build ./...            # build everything
go test ./...             # run the test suite
go vet ./...              # static checks
gofmt -l .                # list unformatted files (CI fails on any)
go run ./cmd/orch status  # or: doctor, help

License

MIT — see LICENSE.

Directories

Path Synopsis
adapters
claude
Package claude anchors the adapters/claude directory as a Go package so its validation tests (plugin_test.go) build and run under the module's ordinary `go test ./...`.
Package claude anchors the adapters/claude directory as a Go package so its validation tests (plugin_test.go) build and run under the module's ordinary `go test ./...`.
codex
Package codex anchors the adapters/codex directory as a Go package so its validation tests (plugin_test.go) build and run under the module's ordinary `go test ./...`.
Package codex anchors the adapters/codex directory as a Go package so its validation tests (plugin_test.go) build and run under the module's ordinary `go test ./...`.
cmd
orch command
Command orch is the shared-core CLI for the Orch development orchestrator (see ORCH-PRD.md).
Command orch is the shared-core CLI for the Orch development orchestrator (see ORCH-PRD.md).
internal
adaptertest
Package adaptertest is the PRD §23 shared parity layer both host adapters' plugin tests consume: fixtures (the committed §10 role profiles) and assertion helpers (skill/manifest drift pins) so cross-host invariants — the run-verb allowlist, the four anti-forgery statement literals, the plan/merge gate option text, the setup interview's terminal forms, hook command portability, and matcher/guard parity — have exactly one source instead of a copy per adapter that can silently drift apart.
Package adaptertest is the PRD §23 shared parity layer both host adapters' plugin tests consume: fixtures (the committed §10 role profiles) and assertion helpers (skill/manifest drift pins) so cross-host invariants — the run-verb allowlist, the four anti-forgery statement literals, the plan/merge gate option text, the setup interview's terminal forms, hook command portability, and matcher/guard parity — have exactly one source instead of a copy per adapter that can silently drift apart.
bootstrap
Package bootstrap executes PRD §18 steps 10-15: given the answers an interview (internal/interview, internal/question) collected, it re-derives the terminal question.Complete document itself and composes internal/config, internal/instructions, internal/gitops, and internal/ghops into the one mechanical act that turns an approved interview into an open bootstrap pull request — a mechanical in-binary executor, no model subagent (decision 30).
Package bootstrap executes PRD §18 steps 10-15: given the answers an interview (internal/interview, internal/question) collected, it re-derives the terminal question.Complete document itself and composes internal/config, internal/instructions, internal/gitops, and internal/ghops into the one mechanical act that turns an approved interview into an open bootstrap pull request — a mechanical in-binary executor, no model subagent (decision 30).
cli
Package cli implements the orch command surface (PRD §22).
Package cli implements the orch command surface (PRD §22).
config
Package config parses and validates the committed Orch configuration at .orchestrator/config.toml (PRD §17), then layers on the machine-local override file at config.local.toml when present.
Package config parses and validates the committed Orch configuration at .orchestrator/config.toml (PRD §17), then layers on the machine-local override file at config.local.toml when present.
execx
Package execx defines the injectable external-command runner the orchestration core uses for git and gh (PRD §5, §12).
Package execx defines the injectable external-command runner the orchestration core uses for git and gh (PRD §5, §12).
execx/execxtest
Package execxtest provides a scripted fake execx.Runner for transcript tests: each expected call is asserted in order and answered with a recorded result, so tests pin the exact argument vectors the core sends to git and gh without running either.
Package execxtest provides a scripted fake execx.Runner for transcript tests: each expected call is asserted in order and answered with a recorded result, so tests pin the exact argument vectors the core sends to git and gh without running either.
ghops
Package ghops executes the GitHub mechanics of the Delivery workflow (PRD §12 steps 6, 9, 13-17) through the authenticated gh CLI (PRD §5), via an injected execx.Runner: repository resolution, the PRD §13 label taxonomy, issue lifecycle, and PR open, status, required-CI state, and merge.
Package ghops executes the GitHub mechanics of the Delivery workflow (PRD §12 steps 6, 9, 13-17) through the authenticated gh CLI (PRD §5), via an injected execx.Runner: repository resolution, the PRD §13 label taxonomy, issue lifecycle, and PR open, status, required-CI state, and merge.
gitops
Package gitops executes the git mechanics of the Delivery workflow (PRD §12): per-issue feature branches and worktrees, post-merge cleanup, cleanliness and protected-branch preconditions (PRD §5, §15), and base-branch checkouts for reproducing failures (PRD §16).
Package gitops executes the git mechanics of the Delivery workflow (PRD §12): per-issue feature branches and worktrees, post-merge cleanup, cleanliness and protected-branch preconditions (PRD §5, §15), and base-branch checkouts for reproducing failures (PRD §16).
guard
Package guard is the mechanical write-enforcement core behind the host-adapter PreToolUse hooks (PRD §23: "Assist reliably blocks tracked-file changes" and "Delivery cannot write outside registered worktrees").
Package guard is the mechanical write-enforcement core behind the host-adapter PreToolUse hooks (PRD §23: "Assist reliably blocks tracked-file changes" and "Delivery cannot write outside registered worktrees").
instructions
Package instructions renders, detects, upgrades, and removes the Orch-managed instruction block inside a repository's root AGENTS.md/CLAUDE.md file (PRD §19):
Package instructions renders, detects, upgrades, and removes the Orch-managed instruction block inside a repository's root AGENTS.md/CLAUDE.md file (PRD §19):
interview
Package interview implements the pure `orch init` question engine (PRD §18): given the environment Detect found and the answers collected so far, Next derives the next question.Document to show — a batch of independent questions, the pre-approval summary, the terminal hand-off document, or an abort notice.
Package interview implements the pure `orch init` question engine (PRD §18): given the environment Detect found and the answers collected so far, Next derives the next question.Document to show — a batch of independent questions, the pre-approval summary, the terminal hand-off document, or an abort notice.
lockfile
Package lockfile implements the exclusive cross-host Delivery lock (PRD §14): one active Delivery coordinator per repository across both hosts.
Package lockfile implements the exclusive cross-host Delivery lock (PRD §14): one active Delivery coordinator per repository across both hosts.
manifest
Package manifest renders and parses the PRD §13 audit record that every Orch issue and PR body carries: the selected role, the exact executor/reviewer model+effort, the routing rationale, escalations and substitutions, the config revision, and named verification commands and results.
Package manifest renders and parses the PRD §13 audit record that every Orch issue and PR body carries: the selected role, the exact executor/reviewer model+effort, the routing rationale, escalations and substitutions, the config revision, and named verification commands and results.
paths
Package paths provides the safe-path and containment primitives (PRD §6, §15) the orchestration core builds on: canonical absolute paths with symlinks resolved, segment-aware containment checks for worktree enforcement, and discovery of the repository root that holds .orchestrator/.
Package paths provides the safe-path and containment primitives (PRD §6, §15) the orchestration core builds on: canonical absolute paths with symlinks resolved, segment-aware containment checks for worktree enforcement, and discovery of the repository root that holds .orchestrator/.
question
Package question defines the native-question-tool compatibility contract (PRD §18, §24 — resolving the deferred "native question-tool compatibility handling" decision): a JSON document the Go core emits describing 1-4 mutually independent questions, and the AnswerSet an adapter submits back.
Package question defines the native-question-tool compatibility contract (PRD §18, §24 — resolving the deferred "native question-tool compatibility handling" decision): a JSON document the Go core emits describing 1-4 mutually independent questions, and the AnswerSet an adapter submits back.
routing
Package routing is Orch's pure role-routing and escalation policy core (PRD §9 roles, §10 default profiles, §11 routing and escalation).
Package routing is Orch's pure role-routing and escalation policy core (PRD §9 roles, §10 default profiles, §11 routing and escalation).
run
This file holds the shared infrastructure for the per-issue Delivery lifecycle verbs (PRD §12 steps 8-22), each in its own file:
This file holds the shared infrastructure for the per-issue Delivery lifecycle verbs (PRD §12 steps 8-22), each in its own file:
state
Package state persists the Assist/Delivery operating mode (PRD §7) in .orchestrator/state.json, machine-local and gitignored.
Package state persists the Assist/Delivery operating mode (PRD §7) in .orchestrator/state.json, machine-local and gitignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL