# kuberwastaken/subagentmaxxing architecture

> Architecture diagram of the GitHub repository kuberwastaken/subagentmaxxing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kuberwastaken/subagentmaxxing
- Repository: https://github.com/kuberwastaken/subagentmaxxing

## Overview

#### Purpose and Entry Points
`subagentmaxxing` is a dependency-free Python CLI that normalizes coding-agent execution across Codex, Cursor, and Claude CLIs. It lets an external orchestrator run one agent, fan a prompt out to multiple models, or manage detached jobs through a common interface.

Primary executables:
- `bin/subagent` — main local CLI and backend adapter.
- `bin/subagent-remote` — SSH-forwarding client for a remote `subagent` host.
- `install.sh` — installs both commands and the Claude Code skill.

#### CLI Control Plane
The `subagent` command is the core control plane. Its command families cover synchronous execution (`run`), parallel multi-target consensus (`fanout`), background lifecycle (`jobs`, `wait`, `logs`), backend discovery (`models`, `doctor`), and session continuation (`--resume`).

It translates normalized options—model, CWD, sandbox level, system prompt, schema, worktree, JSON envelope—into backend-specific invocations.
- `bin/subagent`
- `docs/backends.md`
- `docs/feature-matrix.md`

#### Backend Execution Boundary
The CLI delegates actual model work to already-installed, authenticated provider CLIs rather than embedding SDKs or credentials. Supported execution backends are:
- Codex via `codex exec`
- Cursor via `cursor-agent`/Cursor prompt execution
- Claude via `claude -p`

This boundary isolates differing flags, output conventions, model aliases, sandbox semantics, and session behavior behind the common CLI.
- `bin/subagent`
- `docs/backends.md`

#### Single-Run Flow
A `run` request accepts a backend, prompt, model selection, working directory, and permissions level. The CLI constructs and launches the native backend command, then returns the agent’s final answer; `--json` exposes a richer envelope including session, usage, duration, worktree, and exact command.

Optional worktree isolation protects the caller’s checkout when allowing edits; structured output is supported where the underlying backend supports schemas.
- `bin/subagent`
- `docs/feature-matrix.md`

#### Parallel and Detached Execution
`fanout` sends a shared prompt to independently selected backend/model targets concurrently and returns a JSON array, enabling cross-model review or consensus. Background runs detach execution and persist enough state for later polling, logs, and result collection.

These are orchestration mechanisms, not a distributed worker service: process execution remains local to the host running `subagent`.
- `bin/subagent`
- `examples/cross-model-consensus.sh`
- `examples/review-diff.sh`

#### Remote-Host Operation and Authentication
`subagent-remote` forwards arguments and stdin safely over SSH to a remote machine that has the agent CLIs and credentials. `SUBAGENT_HOST` selects that host, while `-C` refers to remote filesystem paths.

Authentication belongs to the native CLIs: Codex uses `~/.codex`, Claude uses `~/.claude`, and Cursor’s headless-host token can be copied from a Mac keychain through the dedicated helper. `doctor` verifies installations, auth, and Cursor token expiry.
- `bin/subagent-remote`
- `bin/lift-cursor-token`
- `docs/auth.md`

#### Orchestrator Integration
The included Claude Code skill teaches a parent coding agent when to delegate scoped execution, request a read-only review, or use multi-model fanout. The intended architecture is a capable orchestrator planning and validating work while external model CLIs perform bounded coding tasks.
- `skills/subagentmaxxing/SKILL.md`
- `bin/subagent`

#### Validation Surface
Live parity and smoke scripts validate the CLI against real authenticated Codex and Cursor environments, including prompting, system instructions, resume behavior, effort, worktrees, background jobs, and structured output.
- `tests/parity.sh`
- `tests/smoke.sh`

Main entry points: [`bin/subagent`](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent) (Command router), [`install.sh`](https://github.com/kuberwastaken/subagentmaxxing/blob/main/install.sh) (Installer), [`skills/subagentmaxxing/SKILL.md`](https://github.com/kuberwastaken/subagentmaxxing/blob/main/skills/subagentmaxxing/SKILL.md) (Claude Code skill), [`bin/subagent-remote`](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent-remote) (subagent-remote)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Local control plane"]
  node_subagent["subagent CLI<br/>Python CLI"]
  node_command_router["Command router<br/>CLI commands"]
  node_option_adapter["Backend adapter<br/>invocation builder"]
  node_single_run["Single run<br/>execution flow"]
  node_fanout["Fanout<br/>parallel orchestration"]
  node_job_store[("Detached jobs<br/>local process state")]
  node_worktree["Worktree isolation<br/>Git worktree"]
end

subgraph group_providers["Native agent backends"]
  node_codex{{"Codex CLI<br/>native backend<br/>[backends.md]"}}
  node_cursor{{"Cursor CLI<br/>native backend<br/>[backends.md]"}}
  node_claude{{"Claude CLI<br/>native backend<br/>[backends.md]"}}
end

subgraph group_remote["Remote operation"]
  node_remote_client["subagent-remote<br/>SSH client"]
  node_remote_host["Remote subagent host<br/>SSH target"]
  node_cursor_token["Cursor token helper<br/>authentication helper"]
end

subgraph group_integration["Orchestrator integration"]
  node_claude_skill["Claude Code skill<br/>orchestrator guidance<br/>[SKILL.md]"]
  node_parent_agent["Parent orchestrator<br/>coding agent"]
end

node_installer["Installer<br/>[install.sh]"]

node_installer -->|"installs"| node_subagent
node_installer -->|"installs"| node_remote_client
node_installer -->|"installs"| node_claude_skill
node_subagent -->|"dispatches"| node_command_router
node_command_router -->|"run requests"| node_option_adapter
node_command_router -->|"synchronous execution"| node_single_run
node_command_router -->|"parallel execution"| node_fanout
node_command_router -->|"background lifecycle"| node_job_store
node_option_adapter -->|"codex exec"| node_codex
node_option_adapter -->|"Cursor invocation"| node_cursor
node_option_adapter -->|"claude -p"| node_claude
node_single_run -.->|"optional edit isolation"| node_worktree
node_fanout -->|"one invocation per target"| node_option_adapter
node_remote_client -->|"SSH forwards args and stdin"| node_remote_host
node_remote_host -.->|"runs locally"| node_subagent
node_cursor_token -->|"provisions Cursor auth"| node_remote_host
node_parent_agent -->|"uses delegation guidance"| node_claude_skill
node_claude_skill -->|"delegates bounded tasks"| node_subagent

click node_installer "https://github.com/kuberwastaken/subagentmaxxing/blob/main/install.sh"
click node_subagent "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_command_router "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_option_adapter "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_single_run "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_fanout "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_job_store "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_worktree "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent"
click node_codex "https://github.com/kuberwastaken/subagentmaxxing/blob/main/docs/backends.md"
click node_cursor "https://github.com/kuberwastaken/subagentmaxxing/blob/main/docs/backends.md"
click node_claude "https://github.com/kuberwastaken/subagentmaxxing/blob/main/docs/backends.md"
click node_remote_client "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent-remote"
click node_cursor_token "https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/lift-cursor-token"
click node_claude_skill "https://github.com/kuberwastaken/subagentmaxxing/blob/main/skills/subagentmaxxing/SKILL.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_subagent,node_command_router,node_option_adapter,node_single_run,node_fanout,node_job_store,node_worktree toneBlue
class node_codex,node_cursor,node_claude toneAmber
class node_remote_client,node_remote_host,node_cursor_token toneMint
class node_claude_skill,node_parent_agent toneRose
class node_installer toneNeutral
```

## Components

### Local control plane

Common CLI orchestration on the local host.

- [subagent CLI](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): Python CLI · Normalizes execution across agent backends. · `bin/subagent`
- [Command router](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): CLI commands · Routes run, fanout, jobs, wait, logs, models, and doctor. · `bin/subagent`
- [Backend adapter](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): invocation builder · Translates normalized options into native CLI commands. · `bin/subagent`
- [Single run](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): execution flow · Returns final answers or a rich JSON envelope. · `bin/subagent`
- [Fanout](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): parallel orchestration · Runs independent backend/model targets concurrently. · `bin/subagent`
- [Detached jobs](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): local process state · Persists local background-run state for polling, logs, and results. · `bin/subagent`
- [Worktree isolation](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent): Git worktree · Optionally isolates editing runs from the caller checkout. · `bin/subagent`

### Native agent backends

Installed and authenticated provider CLIs execute model work.

- [Codex CLI](https://github.com/kuberwastaken/subagentmaxxing/blob/main/docs/backends.md): native backend · Executed through codex exec. · `docs/backends.md`
- [Cursor CLI](https://github.com/kuberwastaken/subagentmaxxing/blob/main/docs/backends.md): native backend · Executed through cursor-agent or Cursor prompt execution. · `docs/backends.md`
- [Claude CLI](https://github.com/kuberwastaken/subagentmaxxing/blob/main/docs/backends.md): native backend · Executed through claude -p. · `docs/backends.md`

### Remote operation

SSH forwarding to a host with local agent credentials.

- [subagent-remote](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/subagent-remote): SSH client · Forwards arguments and stdin to a selected remote host. · `bin/subagent-remote`
- **Remote subagent host**: SSH target · Hosts subagent, native CLIs, and their credentials.
- [Cursor token helper](https://github.com/kuberwastaken/subagentmaxxing/blob/main/bin/lift-cursor-token): authentication helper · Copies a headless-host token from the Mac keychain. · `bin/lift-cursor-token`

### Orchestrator integration

Guidance for parent coding agents.

- [Claude Code skill](https://github.com/kuberwastaken/subagentmaxxing/blob/main/skills/subagentmaxxing/SKILL.md): orchestrator guidance · Teaches delegation, review, and multi-model fanout. · `skills/subagentmaxxing/SKILL.md`
- **Parent orchestrator**: coding agent · Plans and validates work while delegating bounded tasks.

### Other components

- [Installer](https://github.com/kuberwastaken/subagentmaxxing/blob/main/install.sh): shell installer · Installs commands and the Claude Code skill. · `install.sh`

## Connections

- Installer → subagent CLI: installs
- Installer → subagent-remote: installs
- Installer → Claude Code skill: installs
- subagent CLI → Command router: dispatches
- Command router → Backend adapter: run requests
- Command router → Single run: synchronous execution
- Command router → Fanout: parallel execution
- Command router → Detached jobs: background lifecycle
- Backend adapter → Codex CLI: codex exec
- Backend adapter → Cursor CLI: Cursor invocation
- Backend adapter → Claude CLI: claude -p
- Single run → Worktree isolation: optional edit isolation
- Fanout → Backend adapter: one invocation per target
- subagent-remote → Remote subagent host: SSH forwards args and stdin
- Remote subagent host → subagent CLI: runs locally
- Cursor token helper → Remote subagent host: provisions Cursor auth
- Parent orchestrator → Claude Code skill: uses delegation guidance
- Claude Code skill → subagent CLI: delegates bounded tasks
