How Orchestrator runs and approves Claude Code agents
Orchestrator is a Windows desktop app that I designed, directed and shipped as an AI-assisted project. This note covers how it runs many agent sessions at once and why its security model looks the way it does.
How work is split
You give a piece of work to one lead agent, the orchestrator. It splits the work into tasks and hands each one to a thread. A thread is a full Claude Code session working in the project folder, and several run at once. When a thread finishes, its report goes to the orchestrator, which checks the work before reporting back to me.
I didn't reimplement an agent. Each turn drives the real claude CLI in streaming JSON mode, so threads use my own Claude Code login, settings, CLAUDE.md files and MCP servers. The app adds its own tools over a local MCP server: a task list, questions, media display, and for the orchestrator, tools to start, message and wait for threads.
Every turn runs with Claude Code's own cross-session and scheduling tools turned off. Sessions talk to each other only through the app, so no agent can reach my other Claude sessions directly.
Approvals as cards
Each project has a permission level, from full access down to plan-only. Below full access, the app passes Claude Code a permission-prompt tool that points at its own approve endpoint. A tool call that needs a decision becomes a card in that thread's chat showing the tool and its exact input, and I pick Allow, Always allow or Deny, with an optional note for the agent. My own allow and deny rules in Claude Code still apply on top of the level.
Treating agents as untrusted
The main security decision was to treat the agents as untrusted callers of the app itself. At full access, a thread can run any command. The local server behind the UI can start and steer those threads, so anyone who can call it effectively has remote code execution. That shaped several choices:
- The server listens on the loopback interface only, checks the Host header against DNS rebinding, and requires a random token that changes every launch, compared in constant time.
- The token alone isn't enough to act as a session. Every agent can read that token, so each session's MCP endpoint also needs that session's own secret, and the config file that holds it is deleted once the CLI has read it.
- Decisions never travel over HTTP. In business workspaces, agents can propose outbound actions (publishing, messaging, spending) but can't carry them out. An approval click reaches the app through the webview's private IPC channel, because threads can read the HTTP token. A unit test fails the build if any agent-facing tool name looks like it could approve, reject or decide.
- An approval stores a hash of everything it covers: the action type, the payload, who executes it and the bytes of every attachment. Agents only get items whose hash still matches, so a file swapped after I approve it voids the approval.
The tradeoff is friction. A one-click approve from an agent's own chat would have been simpler, but it would have let a compromised thread approve itself.
Secrets and redaction
Secrets are encrypted with Windows DPAPI and kept in their own file, never in the app's state. By default a secret is available only to run_approved, which runs the exact PowerShell command of an approved item, once, with that secret set. Every value is replaced with [secret:NAME] in transcripts, live views, queue items and logs. Streamed text has to hold back enough bytes that a secret split across two chunks is still caught. And free text may only be cut in one place, after redaction, because cutting through a secret leaves a fragment that no longer matches. A source scan in the tests enforces that. One limit is documented: Claude Code's own session files sit outside the app and aren't redacted.
Phone approvals and the audit log
The app also accepts signed approvals from a paired phone. The phone signs its decision with a P-256 key behind Face ID, over a string that includes the item's current payload hash, a timestamp within 120 seconds and a nonce it hasn't used before. Pairing goes through a native Windows dialog where I type the fingerprint my phone shows. The dialog accepts only hardware keystrokes, so an agent that can script the window can't type into it. The source documents where that stops: a same-user process with a UIAccess token could still get past it.
Every queued, approved, rejected, executed or voided item is appended to an audit log. Each line ends with a hash over the previous line's hash and its own text, so an edited, inserted or deleted line breaks the chain, and the next entry the app writes records a TAMPER: line.