Monty is a small OCaml launcher for running a head agent session that plans work and launches Pi, Codex or Claude worker sessions.
Rex is the default execution surface: every tab, split and session is created through the installed rex CLI (see Rex terminal backend).
Ghostty tabs, windows, and splits remain available with --terminal ghostty or monty settings set terminal ghostty.
An optional headless workflow runs server-owned Pi, Codex or Claude processes without opening a terminal.
The model does the planning.
Monty handles the glue around the terminal, wt, worktrees, manifests, agent harnesses, and startup commands.
- OCaml with Dune 3.24 or newer.
- Dune package management, with dependencies declared in
dune-project. - No opam files are used by this repo.
- The configured
pi,codexorclaudeexecutable, matching the selected harness. - Python 3.9+ on the server PATH for native runtime ownership guards; Claude SDK control additionally needs its configured Python 3.10+ environment and pinned dependency.
- A configured Monty client service; see server-owned agents for setup and rollout limitations.
wtonPATH.- The Rex app with its
rexCLI onPATHfor normal launching, or Ghostty on macOS for--terminal ghostty. ghonPATHwhen using GitHub issues as a project task source.
dune buildThe repo includes a dune.lock generated by Dune package management.
The client API adds Cohttp/Lwt, WebSocket framing and SHA-256 dependencies.
The lock is generated with Dune 3.24.2 and uses its upstream relocatable OCaml
5.2.2 compiler packages. Normal builds use this committed lock; no opam files
or global service installation are required.
Interactive and headless launches use a Monty client service in the
same Monty home and a configured account profile. The first launch generates
profiles for the native account directories it finds (~/.codex, ~/.claude,
Mantle profiles) with the registered project repos as roots; see the
service workflow to supply your own
configuration instead. Plain monty starts the service in the background when
needed and reuses it on later launches; no separate service terminal is needed. Use monty service start and monty service stop to manage
it explicitly. The service owns native Pi, Codex and Claude processes, including
terminal sessions and headless supervisors. It also supports read-only mirroring
of explicitly selected native history. See Pi history and RPC
for the Pi terminal/RPC ownership boundary. An unavailable service never falls
back to an independent native launch.
Install the monty CLI without opam:
./install.shThe installer builds with Dune, copies the Monty control room to ~/.local/share/monty, installs the real binary at ~/.local/libexec/monty/monty-real, and writes a wrapper at ~/.local/bin/monty.
Before activation, it runs the staged binary's doctor in an empty temporary home to catch runtime failures without using task state or launching an agent. A failed check leaves the existing installation intact.
Control-room, binary, and wrapper activation is rollback-protected. Compatible reinstallations keep the home and .monty directory in place, so concurrent Monty processes retain access to the same registry while source files are replaced.
The repository and installer currently use Monty state version 2, stored in .monty/version.
Existing unversioned state is adopted as version 2 without deleting it, and
version 1 state is migrated in place because singleton records remain readable
as one-workspace records. Other version mismatches still require interactive
confirmation or the explicit --replace-state option before replacement.
It also writes MONTY_HOME=~/.local/share/monty and MONTY_BRANCH_PREFIX=monty to your shell startup file, such as ~/.zshrc.
If that file already has a non-Monty-managed MONTY_HOME setting, the installer asks before overriding it.
The wrapper pins MONTY_HOME and provides MONTY_BRANCH_PREFIX as an install-time fallback on every invocation, so running monty from any directory uses the installed Monty control room. A persisted branch-prefix setting takes precedence over that fallback.
Use another prefix with:
./install.sh --prefix /path/to/prefixUse another Monty home with:
./install.sh --monty-home /path/to/monty-homeSet your worker branch prefix with:
./install.sh --branch-prefix ctoFor development, keep the control room in the current checkout and only install the CLI wrapper and binary:
./install.sh --dev-install --branch-prefix ctoPreview the commands without changing anything:
./install.sh --dry-runMonty automatically installs its agent skill and session hook for Pi, Codex and
Claude into the account it launches into. The skill defers to monty guide, the
embedded workflow manual, and the hook tells each session whether it is a worker
or the head butler; role instructions remain in AGENTS.md / worker MONTY.md. See
Agents for setup, status and removal, and
Service API for monty api, the self-describing client API.
Use the installed monty command from any directory:
montyWith the default Pi harness, this opens a service-owned native Pi terminal in the Monty control-room directory, named "Monty Head Butler".
Select Codex for one invocation with monty --harness codex, or persist it as
the Monty default with:
monty settings set harness codexInspect settings with monty settings or read just this value with
monty settings get harness.
Head-butler conversations may stop without reaching a conclusion or creating a Monty task. Conversations are registered with Monty's service, which keeps a durable history mirror. Reopen a registered conversation with Monty's picker:
monty continueSkip the picker and reopen the newest registered task-free conversation in the Monty control room:
monty continue --lastOr select an exact registered native session ID. Import a selected older native session before continuing it. An explicit ID may select a task-free conversation from another workspace; worker conversations stay in their worker lifecycle:
monty continue <session>Continuation is explicit: bare monty and monty start still create a fresh
head-butler conversation. Use the same harness that created the conversation,
selecting it explicitly when needed with --harness pi, --harness codex or
--harness claude.
Continuing a conversation does not create a local task, worker, run handoff, or
entry in monty list. The existing monty resume and monty open commands
remain worker-task lifecycle commands.
monty launch \
--repo /path/to/repo \
--title "Fix issue 123" \
--context .monty/runs/run-1/issue-123.mdBy default Monty creates or reuses a repo-scoped worktree for the requested branch.
Monty asks wt, validates that the returned worktree belongs to the requested repo, and automatically answers wt's repo-selection prompt when multiple repos have the same branch name.
The generated worker launch script reruns monty ensure-worktree --repo <repo> --branch <branch> when the terminal starts, so the correct worktree can be recreated if it was deleted after launch.
Durable worker memory lives under Monty home, not in the wt worktree.
The worker receives both Monty instructions and the context file through the selected harness. Pi uses @file arguments; Codex receives a prompt containing the absolute input and durable-memory paths.
Before starting Codex, Monty passes the exact worker worktree as trusted with a
command-local -c override. This answers Codex's directory-trust question for
Monty-launched sessions without changing config.toml, command approval, or
sandbox settings.
monty launch-many --manifest .monty/runs/run-1/jobs.jsonExample manifest:
{
"jobs": [
{
"id": "issue-123",
"title": "Fix issue 123",
"repo": "/Users/cristea/code/example",
"branch": "monty/issue-123",
"context": ".monty/runs/run-1/issue-123.md",
"worker_dir": ".monty/runs/run-1/workers/issue-123",
"task_key": "local:local-001",
"agent_profile": "simplified"
}
]
}One task can own branches in several repositories. Use workspaces instead of
top-level repo and branch fields:
{
"jobs": [
{
"id": "sonnet-5-invoices",
"title": "Upgrade invoice parsing and admin reprocessing to Claude Sonnet 5",
"workspaces": [
{
"repo": "/Users/cristea/code/django-backend",
"branch": "cto/invoice-parser-sonnet-5-django-backend"
},
{
"repo": "/Users/cristea/code/admin",
"branch": "cto/admin-invoice-sonnet-5-admin"
}
],
"context": ".monty/runs/run-1/sonnet-5-invoices.md",
"worker_dir": ".monty/runs/run-1/workers/sonnet-5-invoices",
"task_key": "local:local-005"
}
]
}Workspace repositories must be absolute registered project paths. Their order
is durable. The first workspace is only the initial launch directory; there is
no special primary_project, and all workspaces share one worker, task status,
resume history, and completion operation. Monty materializes and validates each
repo-plus-branch independently. Pi receives every absolute path in the generated
instructions; Codex additionally receives secondary paths with --add-dir.
The manifest can also omit branch.
Monty then derives a safe branch name from the title using the branch prefix.
The default is monty, so Fix issue 123 becomes monty/fix-issue-123 for one launch or monty/01-fix-issue-123 in launch-many.
With monty settings set branch-prefix cto, --branch-prefix cto, or MONTY_BRANCH_PREFIX=cto, the same task becomes cto/fix-issue-123 or cto/01-fix-issue-123.
For a new task spanning multiple repositories, each branch also ends with the
slugged registered project id: for example, cto/my-feature-django-backend and
cto/my-feature-admin. This applies to generated branches and explicit stems;
explicit prefixes and feature stems are preserved, and an already correct suffix
is not appended twice. Single-repository tasks keep their existing naming behavior.
Interactive launch and headless preparation use the same rule, including dry-run.
Persisted worker branches remain unchanged on retry, resume, ensure, reconciliation,
completion, and reopening; Monty does not rename existing Git branches or worktrees.
A manifest entry can include task_key to link a worker to a Monty-owned local task.
When monty done archives that worker, it also marks the linked local task done.
Ordinary launch and reconciliation use only explicit task keys and stable workspace-set-plus-worker identities.
Use monty tasks repair-worker <worker> for an explicit, ambiguity-checked repair of a legacy worker that has no stable link.
Monty validates the complete manifest before creating a task, reserving worker memory, invoking wt, writing a launch script, or requesting a terminal.
Preflight rejects missing repositories or contexts, unknown projects or tasks, unsafe paths, missing dependencies, existing-state conflicts, and duplicate worker IDs, worker directories, task links, or repo-plus-branch identities anywhere in the workspace sets.
Dry-run and real launch use the same preflight.
A valid dry-run remains mutation-free.
Real launch reserves every worker under the Monty state lock before external work begins.
A runtime failure reports every manifest job as launch-requested, launch-failed, or unattempted/prepared and prints exact recovery commands.
Rerunning the printed batch command safely continues prepared and definitely failed jobs.
It skips launch-requested jobs because another automatic request could duplicate a session.
Use the printed monty resume <worker-id> command when you intentionally want another request for such a worker.
Agent profiles keep interactive and headless role instructions together with a deliberately limited execution shape: one implementer, zero or more parallel reviewers, and an optional final writer (simplifier or fixer), or one interactive driver over Monty-owned child chains. Monty ships four profiles under agent-profiles/:
simplifiedis the default for new workers: one implementer followed by a separate editing simplifier in the same workspaces. The simplifier answers "can you radically simplify this?", applies useful simplifications, preserves required behavior and safeguards, reruns affected checks, and produces the final handoff. Interactive Pi/Codex/Claude instructions arrange the same separate editing agent.reviewedpreserves the existing implementer, correctness reviewer, quality reviewer, and fixer behavior.soloruns one implementer with self-validation and no reviewer or fixer phases.swarmruns one interactive driver that spawns, lands and retires Monty-owned committing child workers (solochains by default, six at a time) throughmonty swarm; seemonty guide swarm.
Personal profiles live under .monty/agent-profiles/. Duplicate IDs across bundled and personal profiles are rejected.
A swarm can span repositories: the driver holds each one as a workspace and monty swarm spawn NAME --workspace REPO gives a child the ones its area needs.
Stages are what a worker does once the work is finished, written once as stages/<id>.md (shipped) or .monty/stages/<id>.md (personal, replaces a shipped stage with the same id). Tell the worker "ship" and it reads monty stage show ship and carries it out itself: commit, push, draft pull request. See monty guide stages.
monty agent-profiles list
monty agent-profiles show simplified
monty settings get agent-profile
monty settings set agent-profile soloUse --agent-profile NAME for one launch or headless preparation. A manifest job's optional agent_profile wins over that CLI option, followed by the persisted setting and the built-in simplified default. Dry-run output shows the resolved profile and stage summary for every job.
Monty fully validates and snapshots the expanded profile into durable worker memory before state is installed. Resume always uses that pinned snapshot, so later setting or profile-file changes affect only new workers. Legacy workers and attempts without profile metadata retain reviewed behavior. Creating a tracking record alone does not select or execute a profile; selection happens at launch/preparation.
The existing headless.fix instruction slot is the optional final editing pass; it can run without reviewers. Optional headless.fix_role is fixer (the historical fallback) or simplifier, and is snapshotted along with all role instructions. A simplifier requires a final editing pass.
Headless execution is an explicit alternative to terminal-backed worker sessions.
Ordinary launch, launch-many, and resume commands use Rex by default.
The headless commands resolve the effective harness using the normal precedence: --harness, MONTY_HARNESS, persisted settings, then the Pi default.
Once monty settings set harness codex is configured, no --harness codex flag is needed for preparation, execution, or resume.
Start every new batch with the same complete preflight and worktree preparation:
monty headless prepare-many \
--manifest .monty/runs/run-1/jobs.json \
--dry-run
monty headless prepare-many \
--manifest .monty/runs/run-1/jobs.jsonPreparation reserves every worker and materializes all of its repo-scoped wt worktrees while leaving it prepared.
The output records the effective harness and Codex YOLO setting so the execution mode is visible before a worker is claimed.
Run one prepared worker or the entire prepared manifest with the effective harness:
monty headless run issue-123
monty headless run-many --manifest .monty/runs/run-1/jobs.jsonBoth commands submit independent supervisors to the Monty service. Closing the calling conversation or terminal does not stop them; stopping the service shuts down its owned processes. The command returns after the supervisor has acquired the worker lock, claimed the task, and written the first phase prompt. The monty:headless-start:v1 receipt contains the worker and attempt IDs, artifact directory, and the future canonical handoff path. It confirms supervisor startup, not successful model execution. run-many performs complete batch preflight first and returns a monty:headless-start-many:v1 result for every worker; a failed start does not cancel already started workers.
For a script that needs the final result and exit status, use --wait:
monty headless run issue-123 --wait
monty headless run-many --manifest .monty/runs/run-1/jobs.json --waitEach phase runs in a fresh process with explicit task context, the authoritative workspace map, and only its required predecessor handoffs. The pinned profile determines the sequence:
simplified: implementer, then a separate editing simplifier in the same workspaces.reviewed: implementer, two isolated reviewers in parallel, then a fixer.solo: one implementer with self-validation.swarm: no headless chain of its own;monty headless run,run-manyandresumerefuse a swarm driver, whose children are spawned from its interactive session.
Monty invokes Pi with --print --mode json --no-session. No subagent extension or parent Pi session is required. Writer phases use read,bash,edit,write,grep,find,ls; reviewers use read,grep,find,ls and cannot run shell-based validation. Writer phases retain normal Pi configuration and provider extensions. Reviewers disable extensions, skills and prompt templates as well as mutation-capable tools. Explicit tool allowlists exclude delegation tools. Independent processes and worktrees do not provide a filesystem sandbox. Pi's final event and assistant stop reason are checked as well as its process exit status: a zero exit code with an error or incomplete stream is a failed phase.
Headless profiles always start fresh phases; --fork is supported only for interactive Pi workers.
Codex uses codex exec --ephemeral --json and preserves command-local trust and configured permissions. With Codex YOLO disabled, writers use workspace-write, while reviewers use read-only. The existing codex-yolo setting continues to apply to Codex only.
Claude uses fresh --print --verbose --output-format stream-json --no-session-persistence processes. Print mode never prompts, so writer phases pre-allow Bash,Edit,MultiEdit,Write,NotebookEdit,Read,Glob,Grep with --allowedTools, the Claude counterpart of Pi's writer tool list and Codex's workspace-write sandbox; without it every edit is a permission denial. A phase requires exactly one successful terminal result with a nonempty handoff and valid native UUID; permission denials and incomplete streams fail. Reviewers use restricted/safe modes, read/search tools, empty MCP configuration and disabled hooks. See server-owned agents for native version requirements and remaining validation limits.
Prompts, JSONL events, phase logs, and final messages live in the worker's durable artifacts/headless/<attempt-id>/ directory. Background supervisor diagnostics and its final result go to logs/supervisor.log. Monty captures phase handoffs into worker memory and publishes the canonical monty:run-handoff:v1 record and pending notice. Failures include the last known phase and artifact paths. A successful run leaves the task open and all worktrees intact.
For host workers, another run, resume, or completion fails with a busy diagnostic while the supervisor or an inherited child process is alive. This includes forced completion and survives termination of the supervisor. Other workers and registry commands remain available. Processes interrupted after claiming a worker are never replayed automatically.
When a fresh successor run is intentional:
monty headless resume issue-123
# Add --wait to wait for its final result.Harness selection still follows CLI, environment, and persisted-settings precedence. No PID, backend, Pi run ID, Codex session ID, or runtime status is persisted in job.json. Process attempts use monty:headless-attempt:v2.
A finished run and a done task are deliberately different events.
An interactive or headless run can finish successfully while its linked local task remains open, every worktree remains intact, and job.json keeps its existing open launch status.
Only the explicit monty done lifecycle closes and archives the task.
Every run handoff uses the documented monty:run-handoff:v1 JSON contract.
The complete v1 field and delivery contract is versioned with the repository.
Canonical records and deterministic Markdown renderings live outside the movable worker directory:
.monty/handoffs/<worker-run-id>/<worker-id>/<run-id>.json
.monty/handoffs/<worker-run-id>/<worker-id>/<run-id>.md
The record contains the worker and task identity, run outcome, dense summary, per-workspace Git diff statistics, validation and review reports, risks, every repo/branch/worktree, durable evidence, and supported next actions. Artifact evidence also retains a safe path relative to worker memory, so read-only follow-up can remap it after archive or reopen moves the worker directory.
Interactive workers publish without marking the task done:
monty handoff publish issue-123 \
--summary "Added the shared handoff contract and pending inbox." \
--check "dune runtest --force: passed" \
--fixed "Rejected forged inbox paths before reading evidence" \
--risk "Draft PR still requires explicit approval"The compact handoff is printed directly in that worker's terminal. Because the user owns an interactive terminal run, it is not also queued for the head butler. Its canonical record remains available for later inspection.
Headless completion uses Monty's home-level .monty/inbox/run-handoffs/, whose small monty:run-handoff-notice:v1 records reference canonical handoffs.
Reading is at-least-once: pending never acknowledges implicitly, and acknowledgement is idempotent.
If publication stopped after the canonical record was written, pending repairs its rendering and delivery receipt without turning an interactive result into a head-butler notification. Discovery never launches or resumes a run and never changes task status.
monty handoff pending
monty handoff pending --format plain
monty handoff acknowledge <notice-id>
monty handoff show issue-123 --format jsonThe head butler displays pending cards only at a safe conversation boundary, then acknowledges the notices it actually displayed. If a native runner is no longer addressable, a fresh agent or the head butler can prepare a durable, read-only drill-down without resuming implementation:
monty handoff follow-up issue-123 \
--question "Which review findings were rejected and why?"This emits monty:run-handoff-follow-up:v1 with the current workspace map and verified paths to the canonical handoff, task context, worker memory, and attempt artifacts.
It never modifies code; continuing work still requires an explicit monty resume or monty headless resume.
Each launched worker gets a durable memory directory.
For launch-many, the default is:
.monty/runs/<run-id>/workers/<worker-id>/
Monty writes:
job.json
MONTY.md
memory.md
artifacts/
Interactive workers also get a harness-specific sidecar: pi-session-id,
codex-session-id or claude-session-id. The service records the native session
identity before Monty connects the terminal. The plain-text sidecar is durable
worker memory; the session ID never enters job.json, and headless runs do not
write it.
Workers are instructed to write important discoveries, blockers, and handoff notes back to this folder.
The wt worktrees are treated as ephemeral and can be recreated from the durable workspace array in job.json.
Resume a worker by id, branch leaf, branch, or title slug:
monty resume issue-123resume reads job.json, recreates or reuses every repo-scoped worktree, and reopens the selected harness with the same durable worker memory.
For an interactive Codex worker, Monty resumes the exact recorded sidecar id
without --last or the original task prompt. A missing sidecar opens Monty's
registered conversation picker, restricted to that exact worker and ordered
workspace map. A foreign sidecar cannot select another worker's conversation;
explicitly import selected older native history before resuming it. Use --fresh to
start a new Codex conversation with the normal task prompt; the prior sidecar
is replaced only after the service registers the new thread. open --fresh is the
same operation.
Resume always derives worktree mode from the durable record rather than a current CLI default, so a never worker cannot accidentally create an unmanaged worktree.
Lifecycle commands find workers through their durable job.json files.
The original jobs.json manifest is launch input and a safe batch-retry contract.
Durable job.json remains the lifecycle source of truth.
done archives the worker and closes the linked Monty-owned local task in the same command.
Open launch states have conservative meanings.
preparedmeans the durable identity is reserved and no terminal request has been made.launch-requestedmeans a terminal request was persisted before the external call, so automatic replay must not risk a duplicate.launch-failedmeans launch preparation definitely failed before a terminal request and is safe to retry.
A nonzero terminal command after launch-requested remains ambiguous because Ghostty may have created a surface before a later AppleScript step failed, and a Rex call can time out or return garbled JSON after the tab was created.
Monty preserves launch-requested in that case and requires explicit resume.
With Rex, a successful creation records the exact session, window and block IDs in the worker's rex-terminal.json; monty resume focuses a still-live terminal instead of opening a second one and only requests a new tab when that block has exited or no longer exists.
- Legacy
activerecords remain open and resumable, but the value is not proof of process liveness.
The active path is always .monty/runs/<run-id>/workers/<worker-id>/job.json.
The archive path is always .monty/runs/<run-id>/archive/<worker-id>/job.json.
Physical location determines active versus archived identity.
Persisted path fields cannot override the canonical physical location.
Resume an archived worker and move it back to active memory with:
monty resume --archived issue-123Complete a task and archive its worker with:
monty done issue-123Inside a worker session, monty done uses MONTY_WORKER_DIR and does not need an argument.
done refuses to archive dirty worktrees by default.
Use --force to discard local worktree changes while archiving:
monty done issue-123 --forceCompleting a task first verifies every workspace, then deletes all of its worktrees and branches, closes the linked local task, writes status: done to job.json, and moves durable memory to:
.monty/runs/<run-id>/archive/<worker-id>/
Completion and archived resume are recoverable phase workflows.
Monty persists completing or reopening intent before moving state, updating the linked local task, and finalizing status.
A retry can continue from either canonical physical location.
The original --force decision is persisted for the whole completion retry.
If a failed removal leaves an existing directory without verifiable Git identity, Monty stops before changing permissions or deleting it. Inspect the residual directory and restore its Git metadata, or remove the verified residual directory, before retrying.
monty doctor reports an exact recovery command for every incomplete lifecycle transition.
Monty can keep a small overview of projects and task sources. Project IDs are stable persisted identities derived from repo names, with deterministic disambiguation when needed. External task sources, such as GitHub issues, refresh local external metadata such as title and URL. The local task registry always owns user-facing open or done status, even when a remote issue changes state. Monty-owned local tasks are the task inventory for both external and local work.
Add a project with optional GitHub issues as its task source:
monty projects add \
--repo /path/to/repo \
--github owner/repo \
--query "is:open"List or show project memory:
monty projects list
monty projects show montyProjects can belong to one user-created group; existing projects start ungrouped.
Names are case-sensitive and use letters, digits, ., -, or _ (except . and ..).
monty projects groups add work
monty projects groups add private
monty projects groups list
monty projects set-group monty work
monty projects list --group work
monty projects set-group monty private # Reassign the project
monty projects set-group monty # Clear its assignment
monty projects groups delete workGroups and assignments persist in .monty/projects.json. Project listings are
read-only; projects show also displays the group.
Empty groups are allowed; unknown groups are errors. Deleting a group atomically
clears its assignments and keeps projects and all their associated data intact.
When Mantle is active in the current shell, projects list, list, and
tasks list default to the group with the exact same name. Each list shows the
active profile and selection above the table:
Profile: work (Mantle) | Group: work
mantle work
monty projects list
monty list
monty tasks list --group private # Override the default group
monty list --all-groups # Include every group and ungrouped projects
monty list --all # Open and done tasks within the selected groupAn explicit --project also overrides the default Mantle group. --group and
--all-groups cannot be combined. A missing group is an error; create it or use
--all-groups. Tasks spanning projects appear when any workspace belongs to the
selected group, retaining all their workspace information.
With Mantle inactive, lists show every group by default. Selection follows the
shell invoking each inventory command. Service-owned native processes receive a
minimal environment and do not inherit the terminal client's Mantle selection.
Reading the profile launches no external commands and writes no settings.
Show a cross-project overview:
monty overviewList open tasks, or filter them by project:
monty list
monty tasks list
monty tasks list --project montylist and tasks list read the same local task inventory and show #, ID, PROJECT, STATUS, TITLE, and BRANCH.
Task status comes from the local registry; worker job.json files record launch and lifecycle state, not a separate task inventory.
Visible rows are numbered from 1 after filtering and sorting; every fresh list restarts at 1, including project/run filters and archived/all views where supported.
In a head-butler conversation, complete 1 refers to row 1 of the most recent task list actually shown to you.
After completing it, complete 2 still refers to the original row 2 until a fresh list is displayed; background changes and internal reads do not renumber those references.
Displaying a fresh list replaces the conversation's mapping. Numbers are temporary positions, never stored task IDs or a global last-list registry.
If the list is unavailable, a number is out of range, or a task is ambiguous, the head butler explains and obtains/displays an appropriate list instead of guessing. An already-completed row never targets another task.
The head butler resolves each number to a real task/worker identifier and uses the existing completion command and safeguards. CLI commands still require real identifiers; there is no numeric selector or complete CLI command.
Both list commands automatically reconcile worker jobs into the local task source of truth before rendering.
Worker jobs are linked back to local tasks with exact task_key values and stable workspace-set-plus-worker identities.
Reconciliation is sorted and replay-safe.
It writes tasks before patching job links, so interruption can be retried without creating duplicate tasks.
Corrupt or unknown neighboring workers produce diagnostics while healthy records continue.
Use --no-sync with either inventory command for a read-only view with no reconciliation writes or external metadata fetches.
You can run monty tasks sync explicitly when repairing or inspecting sync behavior.
List done tasks or both open and done tasks within the selected group with:
monty list --archived
monty list --allFilter tasks linked to workers in a run by directory name or path with:
monty list --run run-1Add or complete a local task:
monty task add --project monty --title "Design overview"
monty task done local-001Attach planned repository work to an open task and inspect its absolute paths:
monty task workspace add local-005 \
--repo /absolute/path/to/django-backend \
--branch cto/invoice-parser-sonnet-5
monty task workspace add local-007 \
--repo /absolute/path/to/admin \
--branch cto/admin-invoice-sonnet-5
monty task show local-005After a worker is linked, materialize or rehydrate all of its workspaces—or one selected absolute repo—and persist the returned worktree paths with:
monty task workspace ensure local-005
monty task workspace ensure local-005 --repo /absolute/path/to/adminFor persisted never workers, ensure returns the existing source repositories without invoking wt.
Normal launch and resume do this automatically. Planning-only tasks deliberately
cannot ensure worktrees until their one durable worker record exists.
If local-005 and local-007 were created for the same feature and neither has
launched, combine them explicitly:
monty task merge local-007 --into local-005
monty task show local-005Adding a second planned workspace or merging unlaunched plans applies project
suffixes to every workspace and updates the task's branch alias to its first
workspace. In this example the merged branches become
cto/invoice-parser-sonnet-5-django-backend and cto/admin-invoice-sonnet-5-admin.
Use the displayed branches in the manifest; unsuffixed stems resolve to the same
names. Workspace order is preserved, and membership is immutable once a worker
is reserved.
The merge closes local-007 with durable provenance and gives local-005 the
ordered workspace set. It does not create branches or worktrees; launch or
headless preparation materializes them later.
Monty stores project overview state under:
.monty/projects.json
.monty/projects/<project-id>.md
.monty/tasks.local.json
Rex is a session multiplexer with a server that keeps sessions alive while apps view them. It is Monty's default terminal: every new tab, pane or session is created through the installed rex CLI, never through AppleScript, typed shell input or the private socket.
Setup: install the Rex app (its CLI lives inside the app bundle and rex skill setup or the app's "Install Rex for Agents" action puts rex on PATH; Monty never installs skills, hooks or documentation credentials as a side effect). Keep the app running so its server is reachable, and enable Remote Control in the app if Monty should show new sessions. Check with:
monty doctor --terminal rexIt is selected when nothing else is; choose Ghostty instead per command with --terminal ghostty, per shell with MONTY_TERMINAL=ghostty, or persistently with monty settings set terminal ghostty. Headless workers are unaffected.
Rex terminology differs from Ghostty, so --target maps deliberately:
--target |
Ghostty | Rex |
|---|---|---|
tab (default) |
tab in the front window | a new window (tab) in a Rex session, rex run --json -s SESSION |
split |
right split of the focused terminal | a new block to the right of the caller's own pane, rex split --json -s SESSION -b BLOCK |
window |
new application window | a dedicated Rex session per worker, rex new --json, shown in the app with session.select |
Placement never follows moving UI focus. Rex sets REX_SESSION, REX_BLOCK and REX_SERVER in every terminal it opens; Monty pins the whole batch to those exact IDs before reserving any worker:
- Inside a Rex terminal,
tablands in the caller's session andsplitbeside the caller's pane.REX_SERVERselects the server;REX_CLIENTselects the app when several are connected. - Outside Rex (a plain shell or a service-owned chat),
tabfollows the active Mantle profile: it lands in the session named bymonty settings set rex-session <session>for that profile (an ID or label fromrex ls, pinned to that session's full ID when set so a later rename in Rex changes nothing, and refused in preflight once the session is gone), else in a session labelled after the profile (work, say) that the user already has or that Monty creates and records in.monty/rex-session.<profile>.json; without a profile the label ismontyand the record.monty/rex-session.json.splitis refused in preflight because there is no pane to split;windowalways creates a session. - Showing a new session needs exactly one connected Rex app (or
REX_CLIENT) that offerssession.select; otherwise preflight fails before any reservation and explains what is missing. Creating the session succeeds server-side regardless, so a display failure after creation leaves the workerlaunch-requestedwith the error andmonty resumerecovers it.
Each worker keeps rex-terminal.json beside its job.json with the server endpoint, session, window and block IDs, the app client, the target and the launch attempt. Nothing about Rex is written to job.json. monty resume/monty open asks Rex whether that block's child process is still running: live means focus it (and show its session) without a second writer; exited or vanished means the normal resume flow opens a new tab for the same conversation, account and branches. Closing a tab leaves the worker running in the Monty service; resume then opens a tab attached to that same running program instead of starting another, and monty doctor --terminal rex points at it. An unreachable server stops resume rather than guessing. monty rex status <worker> prints the recorded reference, its liveness and the program-status records; it is read-only.
The service-owned terminal client forwards the caller's REX_* variables with every attachment, the service validates them (known names, printable values, session:/block:/client: prefixes) and applies them to that native process only, so Pi and Claude workers and their tools can run rex against the pane they live in. Codex runs tools in its app-server, so a terminal start passes the launching pane's context to that thread's shell environment only. The IDs are never stored in the durable session context or in job.json; a live native process keeps the IDs it started with until it is reattached.
A terminal opened from a Rex pane is displayed by Rex, which supports the Program Status Protocol (OSC 7501). Because a harness probes for support once at startup and gives up when the reply is late, the owned terminal answers that probe itself, the way a multiplexer would, and keeps it away from Rex; the harness's reports (Claude Code, Pi and Codex all emit them) pass through untouched and drive the tab status. Pi additionally gets PI_PROGRAM_STATUS=1 so it reports without asking. Inside a Rex terminal the worker's client also reports OSC 7501 program status under the monty record, but only for lifecycle facts: done/blocked/error when the worker publishes a run handoff (ready for review, needs attention, failed), and done or error with the exit code when the native process ends. Attaching reports nothing, and the head butler's terminal reports nothing at all: whether the program is working, idle or blocked right now comes from the harness's own root record (Claude Code emits one), which passes through the proxied terminal untouched. A done record, a zero exit or a handoff never completes or archives the task; captured terminal text is untrusted evidence, and Monty's retained output remains the durable record.
Failure recovery: a rex exit or garbled JSON after launch-requested keeps that state with the error and the printed monty resume command; batch retries never re-request such a worker. Missing rex, an unreachable server, a dead REX_SESSION, a missing split anchor or an undisplayable session all fail in preflight with no reservation. Monty never kills Rex sessions or blocks; close a stale retained block in the app or with rex block close.
Use dry-run mode to inspect what Monty would do without creating tasks, worker reservations, launch scripts, worktrees, or Ghostty/Rex requests. Dry-run performs the same complete path, identity, project, task, state-conflict, and dependency validation as real launch.
monty launch-many \
--terminal dry-run \
--manifest .monty/runs/run-1/jobs.jsonThe most important options are available as CLI flags.
--terminal ghostty|rex|dry-run
--target tab|window|split
--worktree always|never
--branch-prefix PREFIX
--agent-profile NAME
--harness pi|codex|claude
--pi-command COMMAND
--codex-command COMMAND
--wt-command COMMAND
--fork SESSION
--home DIREnvironment defaults are also supported. --terminal wins over MONTY_TERMINAL, which wins over the persisted terminal setting; the built-in default is Rex.
MONTY_TERMINAL=ghostty
MONTY_TARGET=tab
MONTY_WORKTREE=always
MONTY_BRANCH_PREFIX=cto
MONTY_HARNESS=codex
MONTY_PI_COMMAND=pi
MONTY_CODEX_COMMAND=codex
MONTY_CODEX_YOLO=false
MONTY_WT_COMMAND=wt
MONTY_HOME=/path/to/montymonty doctorDoctor prints a stable table with PASS, WARN, and FAIL levels plus exact recovery commands.
The configured command for the selected Pi, Codex or Claude harness and Python 3.9+ are required.
The configured wt command is required only when worktree mode is always.
Ghostty and osascript are required only for the Ghostty backend.
The rex CLI and a reachable Rex server (rex-server, the Rex app normally runs it) are required only for the Rex backend; the recovery names the app or REX_SERVER.
Optional integrations such as gh and sdef produce warnings when unavailable.
Doctor also inspects durable worker state for corruption, incomplete lifecycle transitions, and pending launch states.
It exits zero when checks contain only PASS and WARN, and exits nonzero when any FAIL is present.
Monty stores user-controlled defaults in .monty/settings.json under
MONTY_HOME. Show the effective persisted settings with:
monty settingsRead or change the default harness with:
monty settings get harness
monty settings set harness codex
monty settings set harness piSet the prefix for automatically generated worker branches with:
monty settings get branch-prefix
monty settings set branch-prefix ctoChoose the terminal backend for launches that pass no --terminal and no MONTY_TERMINAL (the built-in default is rex) with:
monty settings get terminal
monty settings set terminal ghostty
monty settings set terminal rexTabs requested from outside a Rex terminal (the head butler in another app or a service-owned chat) follow the active Mantle profile: they land in a session labelled after the profile (work, private), or in monty without a profile, unless a session is persisted for that profile; monty doctor --terminal rex reports whether it resolves:
rex ls # session labels and IDs
monty settings set rex-session hyre # the active profile's tabs go to this session, pinned by ID
monty settings set rex-session.private pers # another profile's mapping
monty settings set rex-session '' # back to the session labelled after the profileThe task API's preflight and apply use the same setting and refuse an apply whose terminal changed since preflight.
Enable Codex YOLO mode for Monty-launched Codex sessions with:
monty settings set codex-yolo trueDisable it again with:
monty settings set codex-yolo falseHeadless Codex phases trust their exact worker worktrees with command-local
-c overrides. This only suppresses Codex's initial
directory-trust question; it does not enable YOLO mode or change config.toml.
When enabled, Monty creates managed Codex threads with never approvals and
danger-full-access. The native terminal attaches using that thread's policy;
remote resumes cannot accept CLI permission overrides. Rejoining a running thread preserves its
native policy. Unrelated API starts keep the safe defaults unless their request
explicitly sets codex_yolo: true. Headless Codex still uses its native bypass
flag. YOLO disables both approval prompts and the Codex sandbox, so only
enable it when the surrounding environment provides the isolation you need.
Monty also pins model_reasoning_effort="xhigh" for new managed Codex threads
and headless phases. This takes precedence over a lower effort configured in
the user's global Codex configuration.
Monty likewise sets tui.vim_mode_default=true; managed terminals also persist
it in the selected Codex account's configuration for later sessions. Managed
Codex terminals enter Vim Normal mode automatically. Codex 0.160.0 forces Insert mode
at startup, so Monty's Python PTY guard sends Escape once the native Vim footer
appears. Later mode changes remain under your control. Use /vim inside Codex
to toggle Vim bindings for the current session.
Interactive worker launches, retries, and resumes use the invoking shell's
CODEX_HOME and Mantle state (MANTLE_CONTEXT, _MANTLE_SELECTED_HOME,
_MANTLE_PREV_STATE, and _MANTLE_PREV_HOME), even if Ghostty or its login
startup has a different profile. Unset and empty values stay distinct, so
mantle off and a custom CODEX_HOME also carry through. Each request captures
the current environment; it does not pin an account to the task. Start/continue
and headless execution select the service profile matching the invoking account home;
native processes receive the service's minimal environment and configured credential references.
Managed terminals select the configured service profile matching that Codex home.
Register each Mantle account home in the service configuration once; an explicit
MONTY_API_PROFILE or monty terminal --profile must match the same account.
Harness selection uses this precedence:
--harness pi|codex|claudeMONTY_HARNESS- The persisted
harnesssetting - The Pi compatibility default
For Codex YOLO mode, --codex-yolo overrides MONTY_CODEX_YOLO, which
overrides the persisted codex-yolo setting. It defaults to false.
Branch-prefix selection uses this precedence:
--branch-prefix PREFIX- The persisted
branch-prefixsetting MONTY_BRANCH_PREFIX- The
montydefault
The persisted setting precedes the environment fallback because installed wrappers export their install-time branch prefix on every invocation.
Agent-profile selection uses this precedence:
- The manifest job's
agent_profile --agent-profile NAME- The persisted
agent-profilesetting - The
simplifieddefault
Settings mutations use Monty's state lock and atomic JSON replacement.
Monty stores durable state as plain JSON and Markdown under the configured home.
Every mutation uses one advisory lock at .monty/state.lock.
The lock protects only short local read-plan-write phases and is never held around gh, wt, Ghostty, pi, osascript, git, or other slow external commands.
JSON updates use a same-directory temporary file, file fsync, atomic rename, and parent-directory fsync.
Canonical path validation rejects traversal, unsafe components, symlink escapes, and persisted path metadata that disagrees with physical state.
Unsafe legacy records require explicit repair and are never silently migrated.
Launch-state changes use locked compare-and-update and refuse to overwrite a concurrent completion or reopening transition.
Persisted launch-script paths are accepted only when the complete script bytes prove ownership or an absent destination remains under an explicitly trusted script root.
Scripts are published through same-directory atomic replacement so a destination symlink swap cannot redirect the write.
Interactive Codex session sidecars use the same home lock and atomic file
replacement while remaining separate from lifecycle job.json state.
Agents operate Monty through the monty CLI. Monty supports them the way Rex
supports agents: a skill that sends the agent to the installed binary's guide, a
SessionStart hook that tells the agent which Monty session it is in, and a
service API that describes itself.
monty skill status # skill and hook state per agent and service profile
monty skill setup # only needed for sessions started outside Monty
monty guide # the workflow manual, by topic
monty api list # every service operation
monty api describe command.send # JSON Schemas, examples and validation notes
monty api call inventory '{"scope":"all"}'See Agents and Service API. The docs index for agents and tools is docs/llms.txt.
All test suites, runners and assertions are OCaml and run through Dune. Python remains for the production Claude bridge and ownership guard, and for the fake Claude SDK protocol fixture used to test that bridge.
The checkout-binary E2E suite uses a unique temporary MONTY_HOME for every scenario.
It installs fake wt, gh, pi, Ghostty, osascript, and related tools, and uses real temporary Git repositories when repository identity matters.
The suite covers concurrent mutation, atomic faults, canonical paths, lifecycle recovery, deterministic reconciliation, whole-batch preflight, partial launch recovery, headless claim boundaries, native phase arguments, shared run handoffs, pending delivery and acknowledgement, read-only follow-up construction, clean-context chain construction, parser behavior, and doctor exit contracts.
Run the complete validation with:
dune build @all
dune runtest --force
git diff --checkServer ownership and Claude development status, dependency setup and recovery boundaries are documented in server-owned agents. This implementation is still under validation.