Skip to main content

stagehands

stagehands manages coding agents across Git repositories and keeps an exact binding to their native conversations. This MIT-licensed CLI supports local Codex and Claude Code sessions and explicit handoffs. It runs on macOS and Linux with Python 3.11+, Git, and at least one installed provider CLI.

User guide · Video walkthrough

Terminal workspace

stagehands board
stagehands board cache-fix

The board opens in tmux. The Orchestrator pane shows your agents, their current activity, assignments, explicit routes, and inbox. Each role has a separate live pane showing its provider, selected model, task, and output.

The tmux workspace shows the Orchestrator, implementer, reviewer, and test roles in separate panes.

  • N adds a role and asks for its provider, model, assignment, and Git checkout. A new role starts inactive.
  • E edits the selected role's assignment and model. The model selection applies to the next turn and keeps the same native conversation ID.
  • U starts the role. Its saved assignment becomes its first prompt unless a handoff is ready to deliver.
  • S sends a follow-up. D stops the role while retaining its worktree and conversation. Enter focuses its pane.
  • A opens the selected role's live Activity view. See commands, file edits, approvals, turn results, and handoffs as the provider reports them. Use the arrow keys to scroll, End to jump to the latest activity, and Esc to go back.
  • R opens the role's Git diff. Press C there to read GitHub PR checks for the branch. Review a role
  • T filters to roles that need attention. I shows the selected role's usage and any allowance the provider reported. Activity and usage
  • P opens the selected role's pending approval. Read the request and choose Approve or Deny. Board controls
  • X archives the selected task after confirmation. Reopen it with stagehands task restore TASK. Workspace setup and archive
  • ? opens shortcut help. Prompts, assignments, and handoff messages wrap and support multiline paste. Ctrl+N adds a new line and Enter submits.
  • L creates a directional link. The board shows an AGENT sender for native tool handoffs or OPERATOR for a handoff you initiate.
  • W sets the selected role's wake mode. Automatic wake requires an eligible recipient and a link set to wake on handoff.
  • Ctrl+b d detaches the view. The daemon keeps the agents running.

The Activity view shows a file change, a test command, and a completed turn.

Use stagehands board --detach to create the workspace and print its tmux attach command. The board requires tmux. The remaining CLI commands work from an ordinary terminal.

The same model and assignment settings are available through the installed CLI. Edit a role on the board (15 sec)

stagehands role configure cache-fix/reviewer --model sonnet \
  --assignment 'Review the implementer’s diff for compatibility regressions.'

Install

uv tool install stagehands    # or: pipx install stagehands
stagehands doctor
stagehands daemon start

To install from source instead:

git clone https://github.com/duriantaco/stagehands.git
cd stagehands
python3 -m venv .venv
.venv/bin/python -m pip install .
source .venv/bin/activate

Sign in to each provider using its native CLI. stagehands starts codex app-server or Claude's headless CLI with the saved configuration directory. Codex 0.172.0 app-server mode and Claude Code 2.1.332 headless mode report a compatibility error for unsupported named profiles. Use CODEX_HOME or CLAUDE_CONFIG_DIR before starting a daemon to select a separate provider configuration directory. Codex app-server protocol · Claude CLI reference

Reuse a workflow

Workflow tutorial showing an implementer and reviewer in two separate repositories.

Watch the multi-repo workflow (3 min 26 sec) · English captions

Run these commands from the repo you want the agents to work in. workflow init creates stagehands.yaml in the current directory. Edit the generated task name, prompts, and expected outcomes before applying it. Generated example

stagehands repo add app .
stagehands workflow init --repo app
stagehands workflow apply

Open the board for the task named in the file and press U to start a role. Applying the file prepares roles and links. Each role gets its prompt and expected outcome as its saved assignment.

task: checkout-v2
repo: app
agents:
  implementer:
    provider: codex
    prompt: Fix checkout validation and run the tests.
    expected_outcome: The validation tests pass and the diff is ready for review.
  reviewer:
    provider: claude
    prompt: Inspect checkout validation and flag compatibility risks.
    expected_outcome: A list of risks with supporting file references.

Set repo under an agent to choose its primary repo. You can also supply a default with workflow apply --repo app or pass a different YAML file as a positional argument.

Give one role several worktrees with extra_repos: [api, docs] under that agent, or repeat --extra-repo when setting up a new role from the CLI. Several repos for one role

Roles run independently on a new task by default. To give the implementer a route to the reviewer, add this to the same file.

handoffs:
  - from: implementer
    to: reviewer
    wake: manual

The link lets you send a handoff with H on the board. You can also ask a managed Codex role to send one using its handoff tool. With manual wake, the handoff waits in the reviewer's inbox until you start the role. Use wake: on-handoff to let an incoming handoff start an eligible recipient. The recipient gets the handoff along with its saved assignment. Applying the YAML reuses matching roles and links. Use the board or CLI to change existing roles and routes.

Work on a task

Register a local Git repository. This creates no agent or worktree. Run stagehands up for the terminal picker, or specify the task and role directly.

stagehands repo add cli ~/src/my-cli
stagehands up cache-fix/implementer --repo cli --provider codex \
  --prompt 'Find why changes to imported modules can leave the scan cache stale.'

The short form records the task and role and provisions its Git worktree. For an existing role, up uses its saved provider and checkouts. Defining roles with task new and role add leaves them unstarted. Use --worktree existing for the registered checkout, a registered worktree path to select it directly, or role add --checkout-of TASK/ROLE --access read to share an exact checkout. Codex confirms its read-only sandbox for a read-only role.

In another terminal:

stagehands ps --watch
stagehands watch cache-fix/implementer --follow

Pressing Ctrl-C in the watcher detaches it. Use --json for finite output, or --jsonl --after SEQUENCE with watch --follow to replay from a cursor and continue live.

printf '%s\n' 'Check which tests cover that case.' |
  stagehands send cache-fix/implementer --stdin --request-id cache-tests-1
stagehands approvals
stagehands inspect cache-fix/implementer
stagehands down cache-fix/implementer
stagehands daemon stop
stagehands daemon start
stagehands resume cache-fix/implementer --detach

down keeps the worktrees and exact native ID, reports Git changes for the primary repo, and stops turn delivery. Send with --queue to leave a message for a stopped conversation. Use up to reopen it and drain its queued prompts, or resume to reopen without submitting a prompt. interrupt cancels the active turn. history and inspect read local state without launching a provider. Press P on the board or use approve ID or deny ID in the CLI to answer a pending native permission request.

Open a native conversation directly

stagehands native cache-fix/implementer --print-command
stagehands native cache-fix/implementer --release

The command contains the exact native ID, checkout, and saved Codex configuration directory. Use --release before running it in another terminal so the daemon releases the session. In Codex's picker, use codex resume --all --include-non-interactive to include app-server conversations. Codex 0.172.0 can reopen a new thread directly before its first prompt, while the picker lists it after a user turn is recorded.

Claude has a reserved UUID before its first turn. That turn creates its native history and sets the friendly label. Afterward, native prints the exact claude --resume command with the original checkout and Claude configuration directory.

If the original conversation cannot be opened, the error includes its saved ID, checkout, and profile. session relink TASK/ROLE --native-id ID validates a replacement before changing the mapping. session fresh TASK/ROLE explicitly creates a new conversation. session import TASK/ROLE --native-id ID binds a native chat whose original checkout matches the role. Old bindings and their queued messages stay associated with the old session.

Connect independent roles

Watch a handoff from Codex to a Claude Code reviewer (45 sec)

stagehands role add cache-fix/reviewer --provider claude \
  --checkout-of cache-fix/implementer --access read
stagehands link cache-fix/implementer cache-fix/reviewer --on handoff --wake manual
stagehands handoff cache-fix/implementer cache-fix/reviewer \
  --message 'Review the cache invalidation change and check the stale-cache case.' \
  --diff --request-id cache-review-1
stagehands inbox cache-fix/reviewer
stagehands up cache-fix/reviewer

Roles start with zero links. This route sends the message and selected diff in one direction. With manual wake, the handoff remains in the inbox until the operator starts the recipient. Use --file, --test-result, or --ci-url for other evidence. Claude's restricted tool inventory is verified in read-only roles. inspect distinguishes that provider restriction from Codex's read-only sandbox.

For automatic wake, set the target's role activation to on_event and the link's wake policy to on-handoff. An explicit down, a disabled role, or automation pause TASK blocks automatic dispatch. A handoff bound to a conversation stays with that conversation after a replacement. Managed Codex threads started with the handoff tool can submit a scoped handoff over an enabled route.

Local state and verification

By default, the daemon stores data under ${XDG_STATE_HOME:-~/.local/state}/stagehands. Set STAGEHANDS_HOME to an isolated state directory for a test. The daemon opens a private Unix socket and stores bindings, turns and ordered events in SQLite WAL mode. A daemon restart leaves stopped roles stopped and records interrupted in-flight turns.

python3 -m unittest discover -s tests -v

The test suite includes real daemon subprocesses, named Unix sockets, and deterministic provider fixtures. Installed CLI acceptance also ran on Linux with Codex 0.172.0 and Claude Code 2.1.332 against isolated loopback model endpoints. It checked exact native recall after restart, CLI-level approvals and interruption, and shared-checkout handoffs.

Run python3 examples/verify_codex.py --provider codex or --provider claude with the installed command on PATH to test live recall in two temporary worktrees. It submits turns through the daemon, restarts it, renames one task, reopens the conversations in reverse order, and checks recall through the native CLI by exact ID.

Metadata

Release files for stagehands 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stagehands 0.2.0
File Size Uploaded Provenance Actions
stagehands-0.2.0.tar.gz 150.6 kB Without provenance Details for stagehands-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stagehands 0.2.0
File Interpreter ABI Platform Actions
stagehands-0.2.0-py3-none-any.whl Python 3 none any Details for stagehands-0.2.0-py3-none-any.whl

Total release size: 275.0 kB

Release files / stagehands-0.2.0.tar.gz

Download URL stagehands-0.2.0.tar.gz
Size 150.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fca27aac4fff8791ef923b15855f34a79310f5202b40cd89e76dc3ef68d1b0da
BLAKE2b-256 checksum
How to use checksums
96a2b2b91ba0b324af872d2cae9ff4bb178b1a5cb3c7885afdf767c2adac0799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / stagehands-0.2.0-py3-none-any.whl

Download URL stagehands-0.2.0-py3-none-any.whl
Size 124.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb6497ae482280accf0d3b1d7d6afb0f32ebd3ce5ec6faef27f857ebc2a7503b
BLAKE2b-256 checksum
How to use checksums
e69aa4efa22abbc328c98dc98214a44cbeba3d197d2a52ed39c88f90d7596899
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for stagehands 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page