Skip to content
Back to skills

Dispatch

ASecurity

Hand new work bound for its own pull request to a fresh Claude session in a new worktree, opened in a Rex tab or a herdr workspace with its permissions written ahead of time. Use when a task should run beside this session rather than inside it, including a change this session found that belongs in another branch or repository. Not for re-rooting this session (`worktrunk:wt-switch-create`) or in-session subagents (`Agent`).

  • 18 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 10, 2026
ai-agentsrustgobashgit

Works with

  • terminal

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 28, 2026

npx -y skills add bendrucker/claude --skill dispatch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dispatch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dispatch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bendrucker-dispatch/badge)](https://www.skillsdirectory.com/skills/bendrucker-dispatch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: dispatch
description: >-
  Hand new work bound for its own pull request to a fresh Claude session in a new worktree, opened in a Rex tab or a herdr workspace with its permissions written ahead of time. Use when a task should run beside this session rather than inside it, including a change this session found that belongs in another branch or repository. Not for re-rooting this session (`worktrunk:wt-switch-create`) or in-session subagents (`Agent`).
argument-hint: "--branch <branch | pr:<n> | mr:<n>> --prompt <file>"
effort: low
allowed-tools:
  - Bash(claude-dispatch:*)
  - 'Bash(sh "${CLAUDE_PLUGIN_ROOT}/scripts/bin-path-check.sh":*)'
  - 'Bash(bun "${CLAUDE_SKILL_DIR}/scripts/dispatch.ts" --help)'
  - 'Bash(bun "${CLAUDE_SKILL_DIR}/scripts/dispatch.ts" sessions:*)'
---

# Dispatch

Start a separate Claude session that takes a task through to its own PR while this session keeps working, or follows up on a branch or PR that already exists. The script checks the branch out in a worktree with `wt`, writes the session's `.claude/settings.local.json`, and launches `claude --name <name> <prompt>` in the multiplexer hosting this session.

## Write the Prompt

Write the prompt to a file under `tmp/` from what this conversation already knows. The dispatched session starts with no context from this one, so state the goal, what is already ruled out, and the completion criterion, and name any files this conversation has already found. It reads the repository itself, so go straight from the request to the prompt without exploring the code first. Keep it under 128KB. For larger material, point the session at a file. The script appends this session's name, its Rex block or herdr pane, and the address another machine uses for this one. The dispatched session sends its replies with `SendMessage` to that name.

PR-bound work ends by opening its PR through `pull-request:create`. When the user wants to review the work before the PR opens, tell the session in the prompt to run `pull-request:create --review human`, which holds the PR until the user approves its body and diff. That flag is the session's stopping point.

## Flags

`--help`, run for this session:

!`bun "${CLAUDE_SKILL_DIR}/scripts/dispatch.ts" --help`

Pass `--title` with two to four Title Case words naming the task. The script ends a pane or tab session's prompt with an instruction to run `dispatch:close` once its PR is open. Pass `--keep-open` to leave that instruction out when the user wants to keep the session open.

## Grant Permissions

Pass the permissions the task needs with `--allow`, `--sandbox-write`, and `--settings-json` so the session runs without prompting for them. The script merges them into the worktree's `.claude/settings.local.json`, keeping existing keys and skipping array entries already present. It refuses to write when that file is not git-ignored.

## Pick the Place

A tab is a workstream with this session as its lead, and a pane is one task within it. Take the first place that fits:

- `bg`, a `claude --bg` session with no terminal: a small, self-contained change with a clear completion criterion, few questions, and little for the user to read before the PR. Pass `--mux bg`.
- A pane in this tab: a side issue inside this tab's current workstream that the user will want to watch or steer. Under Rex, pass `--split`. Under herdr, open a tab.
- A new tab (`rex` or `herdr`): an unrelated theme, or exploratory work that needs decisions, reading, or review as it goes.

### Session

Under Rex, open a tab in the session for its area of work. The user keeps one Rex session per area, plus the inbox `I/O` for scratch work and light follow-ups. The candidates, with each session's tabs, working directories, and description. Listing them also moves the sessions that `~/.config/rex/sessions.toml` gives an `order` to the top of Rex's session list:

!`bun "${CLAUDE_SKILL_DIR}/scripts/dispatch.ts" sessions --apply-order`

Take the first rule that fits:

- A light follow-up to existing work, such as a small CI fix: stay in this session, or pass `--session I/O`.
- One area session clearly matches the repo, a working directory, a tab label, or the description: pass `--session <label>`.
- Several sessions match, or none does: pass `--session I/O`, and name the closest areas in the hand-off. Once the user picks one, move the tab there with `rex window move <title> -s I/O --to <session>`.
- The user named another host: list that host's sessions with `claude-dispatch sessions --host <label>`, then dispatch with `--host <label> --session <label> --repo <path or slug>`.

`--help` above names the tab multiplexer `--mux` defaults to. When the task calls for a pane or tab and `--help` says to pass `--mux` instead, ask the user with `AskUserQuestion` whether to use `rex` or `herdr`.

The user finds a background session in `claude agents` and picks it up with `claude attach <target>`. This session follows it with `SendMessage` to `name`, and reads its output with `claude logs <target>`. The ledger, `dispatches.jsonl` in the plugin data dir, records every dispatch.

## Run It

!`sh "${CLAUDE_PLUGIN_ROOT}/scripts/bin-path-check.sh" claude-dispatch`

```bash
claude-dispatch --branch "$BRANCH" --prompt "$PROMPT_FILE" [--allow <rule>]... [--sandbox-write <path>]...
```

- Make `claude-dispatch` the entire Bash command, with no `cd`, env prefix, pipe, `&&`, or loop, because only that form matches its sandbox exclusion. For several dispatches, write one prompt file each and issue the Bash calls in parallel in one message.
- `--repo` defaults to this session's repository, shown in `--help` above. Pass it only to dispatch into another repository. See Other Repositories below.
- A branch that exists locally or on a remote is reused, and a branch that already has a worktree opens there. `wt` resolves a PR or MR to its head branch. `--base` applies only to a branch being created, and is fetched first.
- Under Rex the session opens in a new tab, or a pane with `--split`, labeled with the title. From outside Rex, pass `--session <id or label>` from `rex ls`.

## Other Repositories

`--repo` takes a path, an `owner/name` slug, or a GitHub URL. A slug or URL resolves to `~/src/<owner>/<name>`, where `<owner>` is the upstream owner. A fork's slug resolves to its parent's directory, so `bendrucker/plannotator` lands in `~/src/backnotprop/plannotator`. A missing path of the form `~/src/<owner>/<name>` resolves the same way.

When that directory is missing, the script clones it with `gh` on the machine that runs the session:

- With push access upstream, `origin` is upstream.
- Without it, the script forks with `gh repo fork --clone`. `origin` is the fork, `upstream` is the parent and gh's default repository. The dispatched session pushes to `origin`, and `gh pr create` opens the PR against upstream. Worktrees go under the fork owner, since `wt` names them from `origin`.

In a checkout with an `upstream` remote, `--base` defaults to upstream's default branch instead of `origin/main`, because the fork's own branch lags.

## Other Machines

To run the session on another machine, pass `--host <label> --session <remote session> --repo <remote path or slug>`. The label must appear in `rex hosts list`, and that machine must have the dispatch plugin deployed at `~/.claude-repo`. The worktree, settings, and fetch happen there. The session starts with `--remote-control`, which puts it in `ListAgents` here. `path` stays `null`, and `branch` stays a PR or MR reference, until the remote screen shows them.

## Read the Result

On success the script prints one JSON line:

- `name`: the session name to address it by.
- `title`: the tab or pane label.
- `place`: `pane`, `tab`, or `bg`.
- `path`, `branch`: the worktree. For a PR or MR, `branch` is its head branch.
- `checkout`: `new-branch`, `existing-branch`, or `existing-worktree`. Absent for `--host`.
- `mux`, `target`: the Rex block, herdr pane, or `claude --bg` id running the session.
- `settings`: the settings keys written.
- `status`:
  - `working`: the session took the prompt.
  - `blocked`: a dialog is showing, such as folder trust or a permission prompt. Under Rex and `bg`, `blockedKind` (`permission`, `question`, or `auth`) and `blockedMessage` say what it asks when the session reported them. Otherwise read the screen (`rex capture -b <target> --trim`, `herdr agent read <name>`, or `claude logs <target>`). Tell the user what it asks. The user answers it.
  - `failed`: under Rex, the session reported an error, or the remote launcher printed `dispatch failed:` and stopped. Under `bg`, `claude agents` reports the session failed or stopped. Read the screen (add `-S <host>` for a remote one) and report the error.
  - `unknown`: the session showed neither before the timeout. Read the screen before reporting the hand-off. Under `bg`, a sandboxed `claude agents --json` lists nothing, so the status comes from `claude logs` alone.
- `submoduleError`, when present: submodules failed to initialize. The session can repair them.

A failure exits 1 and prints the error. Once the worktree exists, it also prints the partial record. Unless `checkout` is `existing-worktree`, report `path` to the user as an orphaned checkout to clean up. A failure after `wt` created the branch leaves the branch, and a rerun with the same `--branch` reuses it (`existing-branch`).

## Follow Up

1. Confirm `name` appears in `ListAgents`.
2. Talk to the session with `SendMessage` to `name`. Its replies arrive in this conversation.

The hand-off is done when `ListAgents` lists the session and the user has its `name`, `branch`, and `status`.

Files in this skill

  • SKILL.md5.9 KB
  • scripts/__snapshots__/dispatch.test.ts.snap1.1 KB
  • scripts/dispatch.test.ts65.3 KB
  • scripts/dispatch.ts52 KB
  • scripts/ledger.ts1.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.