mBm TUI (mbm2)
Menu

Parallel Work

mbm2 can work the way a lead engineer with a team does: split a job into independent parts, hand each part to someone who works on their own copy of the code, keep going meanwhile, hear when each part is done, check it, merge it, run the checks. In mbm2 the "someone" is a background subagent task, and its own copy is a git worktree.

Step Who How
1. Split The agent, or you Independent parts only: two features, a refactor and its docs, a long test run. A lookup or a small edit is not worth a task
2. Brief The agent's task call, or your /delegate text Everything the subagent needs, since it has not seen your conversation: the goal, the files, what is ruled out, how to verify, how long the report should be
3. Run The runtime Each task runs in the background in .mbm/worktrees/<job> on branch mbm2/<job>, from your last commit; your working tree is not touched
4. Keep working You and the agent Ask other things, start other tasks; nobody polls. The status row says 2 jobs
5. Hear back The runtime When a task ends, a notification with its report, commits and changed files arrives in the session and wakes the agent
6. Verify and merge The agent proposes, you approve The report is a claim: the agent reads the branch's diff and runs the checks, then calls task_merge. You see the commits and approve or reject. Nothing is pushed
7. Check The agent It runs the project's checks on your branch after each merge

The build agent's instructions describe this method, so build (and safe) follow it when you ask for parallel work. plan does not delegate edits.

Three Ways To Run Work In Parallel

Way You type Good for Where it runs
Ask the agent split this into independent parts and do them in parallel, each in its own worktree Work the agent should plan, brief and merge itself Background tasks of the session (Background jobs)
/delegate <task> /delegate add a --dry-run flag to mbm2 export, with a test A task you already know, started now, without asking the agent first A background task of the session, in its own worktree
A team lead /team lead planner, then a goal in its tab Several long-lived workers in tabs, each with its own session you can open Worker tabs (Teamwork)

The first two are the same mechanism: a background task of the open session, listed by /jobs and /delegate, reported by a notification, merged by task_merge with your approval. The third gives each worker a tab of its own.

Example: Two Worktree Tasks While You Ask Something Else

  1. In a git repository, on build, ask:

    Two independent changes, each in its own worktree, in parallel:
    1. add input validation to the API handlers in api/, with tests;
    2. document the config package in docs/config.md.
    Brief each task fully and have it commit its work. Then wait for the reports.
    
  2. The agent calls task twice in one step, each with isolation: "worktree". Both answer at once:

    Started background task job_01c3… (@general, session ses_…).
    Worktree: /path/to/repo/.mbm/worktrees/job-01c3… on branch mbm2/job-01c3… from 4f2a9c1d0b7e.
    

    The agent ends its turn. The status row reads 2 jobs.

  3. Ask something else meanwhile: what does the retry helper in internal/net do?. The agent answers you at once; the tasks keep running in their worktrees.

  4. When the first task ends, a line appears in the transcript and the agent wakes:

    ▸ ✓ job_01c3… completed · Add API validation
    

    Click it to read the notification: the branch, its commits, the changed files and the report.

  5. The agent checks the work before it merges: it reads git -C <worktree> diff <base> HEAD, runs the tests in the worktree when the report does not show them passing, and then calls task_merge.

  6. mbm2 asks you, every time:

    △ Permission required
      ⑂ Merge task Add API validation
    Branch: mbm2/job-01c3…
    9b1e2f3 validate request bodies
    api/validate.go | 42 +++++
    1 file changed, 42 insertions(+)
    Commit message: Add API validation
     Allow once   Reject
    

    Allow once applies the commits to your current branch, commits exactly the task's files, and removes the worktree and the branch. Reject leaves everything as it was. The same branch, commits and files are on the question when you answer it from your phone (/rc) or «mbm code».

    The call stays in the transcript with what it merged:

    ┃  # Merged task Add API validation
    ┃
    ┃  Branch: mbm2/job-01c3…
    ┃
    ┃  9b1e2f3 validate request bodies
    ┃
    ┃  api/validate.go | 42 +++++
    ┃  1 file changed, 42 insertions(+)
    ┃
    ┃  Committed 4d7a0c1 on the current branch. Nothing was pushed.
    

    The agent reads the same in the call's answer: the commit, the branch, its commits and the diff stat.

  7. The agent runs the project's checks on your branch and tells you what was merged. The second task is merged the same way when it ends — one at a time.

Example: /delegate A Task Yourself

/delegate starts a background task without asking the agent: the text is the subagent's brief, and it runs with the model you have selected.

  1. In a session, type (shift+return or ctrl+j starts a new line):

    /delegate Add a --dry-run flag to mbm2 export
    It prints what the export would write and writes nothing.
    Files: cmd/mbm-tui/cli_export.go and its test. Do not change the export format.
    Verify with: go test ./cmd/mbm-tui/ -run Export. Commit the change. Report in five lines.
    

    The first line names the task (up to 50 characters). The toast says Delegated in the background: Add a --dry-run flag to mbm2 export · /delegate lists it. You stay in your session and can go on with anything.

  2. When the task ends, the toast says Delegated task completed: … · /delegate to read and merge it, and its notification arrives in the session as for any background task. The agent reads it, so you can also just say review and merge the delegated task.

  3. Type /delegate (or choose Delegated tasks in the palette, ctrl+p):

    Delegated tasks                                  esc
    Running
      Add API validation @general           running 1m 35s
    Finished
      Document the config package @general   to merge · 3m
      Rename the store helpers @general     merged 9b1e2f3
    report enter  merge m  stop s
    
    Key What it does
    enter Opens the task's report (the subagent's last message), with its branch in the header; esc goes back
    m On a finished worktree task: closes the list and asks the merge question in the session, the same one task_merge asks
    s On a running task: asks to stop it; its subagent's turn is aborted and its worktree kept
    r On a Stale worktrees row: asks (Cancel first), then removes that worktree and its branch

    A task that ends with no commit (and no change to a tracked file) has nothing to merge: its worktree and branch are removed when it ends, and its row reads nothing to merge. A task cut short when mbm2 closed is cleaned the same way at the next start. Worktrees under .mbm/worktrees/ that no task runs in or waits to merge from — left by an older mbm2, a stopped task, a deleted session — are listed under the tasks as Stale worktrees, with the commits or uncommitted changes they hold:

    Stale worktrees
      mbm2/job-01b7… stale worktree                     2 commits
    report enter  merge m  stop s  remove r
    
  4. Approve the merge. The toast says Merged Document the config package as 4c2d9e1. Run the project's checks now. Rejected, it says Not merged: …: the merge was rejected; nothing changed.

Outside a git repository there is no worktree to make: /delegate still starts the task, in the project directory itself, and the toast warns … is not in a git repository: the task works in the project directory itself, beside you and any other task. Such a task has nothing to merge.

Example: A Long Test Run In The Background

  1. Ask: run the whole test suite — the agent starts go test ./... in the foreground.
  2. Two minutes in it is still running, so it moves to the background on its own and the agent goes on. Do not want to wait two minutes? While it runs the status row reads esc interrupt ctrl+b background: press ctrl+b and it moves at once.
  3. Keep working: meanwhile, explain the cache eviction in internal/state.
  4. When the tests finish, the notification carries the exit code and the last 20 lines, and the agent reads the failures. /jobs (ctrl+alt+j) lists every job with its output.

Asking up front works too: run go test ./... in the background and tell me when it fails.

Example: Queue Prompts While The Agent Works

You do not have to wait for a turn to end to say the next thing.

  1. While the agent works, type also update the changelog and return. The message waits with a QUEUED badge, and the status row counts 1 queued.
  2. Changed your mind? With an empty prompt, ctrl+alt+q brings the newest queued message back to edit, and ctrl+alt+x removes it (Prompts).
  3. When the running turn ends, the queued messages are answered in order.

A message you type while the agent waits in monitor ends that wait at once: the agent answers you and then waits again (Background jobs).

Write A Good Brief

A subagent starts with nothing but its brief. Whether you write it (/delegate) or the agent does, it should say:

Part Example
The goal, in one sentence Add a --dry-run flag to mbm2 export that prints what it would write.
Where to start cmd/mbm-tui/cli_export.go, cmd/mbm-tui/cli_export_test.go
What is ruled out Do not change the export format. The flag parser is not the problem.
How to verify go test ./cmd/mbm-tui/ -run Export
What to hand back Commit the change. Report in five lines: what changed, the commit, the test result.

Keep each task independent: two tasks that edit the same lines will conflict at merge time. Ask for research (find every caller of …) as its own task when it is long; a quick lookup is faster done directly.

Limits And Safety

Rule What it means
Every merge asks you task_merge and /delegate's m ask even when your permission rules allow everything; an allow rule never skips it, a deny rule for task_merge refuses every merge
Nothing is pushed A merge commits on your current branch only
Your edits are safe A merge that conflicts, or touches a file you have changed and not committed, is refused and leaves the tree as it was
A task starts from your last commit Changes you have not committed are not in its worktree
A report is a claim Read the diff and the checks before you approve; the merge question shows the commits and files
The checks run after the merge Ask the agent to run them, or run them yourself; a merge does not run them
A worktree task must commit A task with uncommitted changes to tracked files is refused: resume it (the agent can, with its task_id) to commit, then merge
Only commits merge Untracked and ignored files in a task's worktree (__pycache__, node_modules, build output) never block a merge and never reach your branch; they go with the worktree. Nothing needs deleting first
Tasks keep your denies A delegated task keeps the deny rules of your current agent and session; /delegate refuses when they deny the task permission
Runtime Background tasks and /delegate need mbm2's own runtime (features.delegate); on Windows the runtime does not run them yet

Troubleshooting

Symptom Cause and fix
/delegate needs mbm2's own runtime; this server does not run background tasks mbm2 is attached to a server that is not mbm2's runtime, or an older one. Start mbm2 without --attach, or upgrade the runtime
Open a session to delegate a task to it You are on the home screen; open or start a session first
The toast warns … is not in a git repository The project is not a git repository, so the task shares the directory. Run git init and commit to get worktrees
/delegate failed: … isolation "worktree" needs a git repository Only an explicit worktree request is refused outside git; plain /delegate falls back to the shared directory
Merge …: task job_… is still running: wait for its notification The task has not ended; m waits for the to merge state
Merge …: task job_… has uncommitted changes to tracked files in its worktree The subagent changed tracked files and did not commit them. Ask the agent to resume the task with its task_id and commit, then merge. Untracked files such as a test cache never cause this
Merge …: task job_…: the task branch has no commits since its base The task committed nothing; read its report (enter) to see why
Merge …: task job_… has nothing to merge: its worktree and branch are removed The task ended with no commit, so mbm2 removed its empty worktree; read its report to see why
Not merged: …: … local changes in files the task touches; the tree is as it was You have uncommitted edits in a file the task changed; commit or stash them, then m again
Not merged: …: … the task's commits conflict with the current branch Your branch moved on in the same lines; ask the agent to resume the task and rebase its work, or merge by hand
The agent re-checks a task in a loop or does the task itself Tell it wait for the notification; the notification wakes it, and its instructions say not to poll or redo a delegated part
A task runs far too long /delegate or /jobs, s on its row, Confirm. A stopped task with no commit loses its empty worktree; one with commits keeps it to merge, and anything else left is listed under Stale worktrees in /delegate, where r removes it
mbm2 closed while tasks ran They are lost; the next start offers them in Work to continue. A task resumed after the restart works in its own worktree again, and its permission questions still reach the window of the project that started it

Published from revision f88fc66f 2026-11-30