Skip to content

session-hub

When a task spans multiple repositories, handling everything in a single session quickly blurs context and boundaries. With session-hub, a master session opened at the hub root launches parallel child sessions (one per repository).

Each child session receives a written scope, a model, and an effort level. It communicates only with the master and sends any work outside its boundaries back up. You can step into the child session for your own domain and steer it directly, while the master coordinates the rest.

Working across multiple repositories in one chat forces you either to proceed sequentially or to jump between disconnected windows. In session-hub, child sessions are full Claude Code sessions running in parallel, each in its own pane or in the background, with its repository’s instructions, skills, and conventions already loaded.

In practice, you can enter and type in any child session, typically the one for the repository you know best (design, prototype, or code). Meanwhile, the master launches the remaining child sessions, receives their updates without polling, routes requests across projects, and brings you in when a human decision is needed. Scope boundaries hold even when you prompt a child session directly: if you ask it for something that belongs to another repository, the request still goes up to the master instead of crossing over.

Herdr: the master session on the left, two child sessions on the right, each working in its own repository

Herdr: the master on the left, two child sessions on the right, working in parallel.

The Ways of working page walks through four progressive examples of this pattern, from a single person wearing two hats to an AI-mediated product team:

To coordinate child sessions and enforce their boundaries automatically, session-hub combines three skills, two hooks, a script, a mod, and a command:

Name Type What it does
session-hub:dispatch skill Runs in the master. For each repository, decides whether the master reads directly, delegates to a subagent, or starts a child session; handles incoming messages, routes out-of-scope requests, and keeps tasks reserved for the master.
session-hub:spawn skill Launches one child session per repository (desktop app, Herdr, tmux, claude --bg, or manual commands) with scope, model, effort, SESSION_HUB_* role variables, and a handoff file, then records it in the children record.
session-hub:setup skill Creates or updates the ## Child sessions section in the hub’s instructions file, writing it only after you confirm.
session-hub-scope-guard hook PreToolUse hook on Edit, Write, and NotebookEdit. In a child session, blocks any edit whose real path falls outside the write root.
Handoff hook hook SessionStart hook. In a child session, adds the handoff file to the context at startup, after /clear, and after every compaction, so the child does not need to read the file or have access to its directory.
scripts/registry.mjs script Reads and updates the children record atomically and safely.
session-hub mod In a child session, enables the send guard, shell check, message origin marking, and scope line. In the master, adds the child sessions panel. Requires mods to be enabled.
/session-hub command Shows the current session’s role and scope; in the master, also summarizes child sessions and, in the terminal, opens the panel. In the Claude desktop app, replies with a card in the conversation. Registered by the mod.

In day-to-day work, you rarely need to invoke a skill by name. Ask in plain language (for example, “start a child session in product for T-42”, “set up session-hub in this hub”, or “what are the child sessions doing?”) and Claude Code loads the right skill automatically.

Before the master can distribute work sensibly, it needs to know which repositories make up the hub, what role each plays, and how you prefer to launch sessions. Those settings live in the ## Child sessions section of the hub’s instructions file: AGENTS.md in the root folder, or CLAUDE.md if AGENTS.md does not exist.

You do not need to write this section by hand. Ask Claude Code to “set up session-hub for this hub”: the setup skill inspects the folder, drafts a proposal, and writes it only after you confirm.

Every key is optional. Values you state in conversation override keys in the file, which override the defaults.

Key Contents Default
Repositories Relative path, one-line role, and base branch if needed Subfolders containing .git, plus paths in .gitmodules
Task IDs Task ID format and where tasks are located The ID you provide; otherwise a short slug
Propagate Hub rules to include in the handoff of a child session working outside the hub None
Master only Parts of the hub file and tasks reserved for the master None
Model, Effort Defaults per repository or type of work None: uses choose-model, otherwise inherits from the master
Scope For each repository, which paths a child session may read outside its write root None
Registry Path to the children record, outside the hub <config dir>/session-hub/children-<hub id>.json
Guards on or off, for all three guards on
Permissions ask or inherit: what to do when the master skips permission prompts ask
Carry Names of extra environment variables the child session carries over from the master’s launch None
Environment auto, desktop, herdr, tmux, cli, or manual auto
Layout tabs, panes, or ask ask
Worktrees repo, always, or never, for child sessions that modify files repo
Session name Naming pattern for child sessions <task>-<repo>

Here is an example of a configured ## Child sessions section:

## Child sessions
Settings for the session-hub plugin. The invocation says which repositories a piece of work touches.
- Repositories:
- `design/`: specification and API documents, base branch `main`
- `product/`: code monorepo, base branch `develop`
- Task IDs: `T-123`, listed in `backlog/tasks.md`
- Master only: the sections *Backlog* and *Meetings* of this file; writing the story tracker
- Model: design: opus; product: sonnet; read-only: haiku
- Effort: product: medium; read-only: low
- Scope:
- product: `design/docs/api/`
- Environment: auto
- Layout: panes
- Worktrees: repo
- Session name: `<task>-<repo>`

Once the hub configuration is in place, the master still has to decide which operations warrant a dedicated child session. Checking a couple of files does not require a separate session, whereas editing code or interpreting local conventions calls for the repository’s full environment. The dispatch skill makes that call on the master side.

When a task involves the hub’s repositories, dispatch reads the configuration, reconciles the record with the sessions actually running, and identifies the affected repositories. If there is any doubt, it asks you to confirm instead of guessing. For each repository, it applies the first matching rule:

Situation Action
A child session is already running for that repository and task Sends a message to that child session ([master] …); does not start a second one
Any modification in the repository is needed Starts a child session with session-hub:spawn
A read is needed that requires the repository’s skills or rules to interpret Starts a read-only child session
A broad read is needed whose output is a summary or conclusion Delegates to a read-only subagent of the master
Only a few known files need to be read Reads them directly from the master

Once a task goes past roughly five files, or requires searching the repository or using its build tools, it no longer counts as “a few known files.” Before acting, dispatch shows you the plan in a summary table, then launches all needed child sessions in a single call to spawn so each handoff lists the others as sibling sessions immediately.

Once the required child sessions are clear, spawn prepares the environment, sets the scope, and launches them in five ordered steps:

  1. Resolves the repository and its base branch, then reconciles the children record.
  2. Checks whether an active child session already exists for that repository and task; if so, forwards the request there instead of opening a duplicate.
  3. Determines the execution environment, session name, worktree (if any), write root, and read scope.
  4. Picks the model and effort in strict priority order: first what you specified, then the keys configured in the hub, then model-router:choose-model if installed, and otherwise the master’s settings.
  5. Writes the handoff file outside the hub, launches the child session with a single-line initial prompt (the handoff title, a sentence on the goal, and the file path in case the handoff does not reach the context), records it as running alongside the master’s identity, and prints a full summary.

The detected environment determines how the child session opens and whether the scope guard can run:

Environment Detected when Scope guard
Desktop app A session-launch tool such as start_session is available Inactive: scope relies on the handoff alone
Herdr HERDR_ENV is 1 and herdr is in PATH Active
tmux TMUX is set and tmux is in PATH Active
Terminal claude --help lists --bg Active
Manual None of the above Active if you run the command as provided

In Herdr, spawn also records the master on each child’s pane: herdr pane report-metadata <pane> --source session-hub --token parent_pane=$HERDR_PANE_ID, before the child starts. A tool that groups agents, such as herdr-jump, then reads the master–child tree from herdr agent list instead of guessing it. If this step fails, the child starts anyway and the master reports it.

For the master and a child session to exchange messages, they must share the same account and configuration directory; two sessions with different configuration directories cannot communicate. If you launch Claude Code through an alias or wrapper that selects a profile or adds flags, child sessions must start the same way. To preserve that setup, spawn runs scripts/launch.mjs to inspect how the master was started (identity variables such as CLAUDE_CONFIG_DIR, HOME, and the wrapper profile, plus configuration flags). It then launches each child session with those same parameters, adding the child-specific flags (-n, --model, --effort, --permission-mode) and setting the SESSION_HUB_* role variables.

The handoff file stays in the master’s scratchpad, a fresh directory per session. The child does not read it from there: the handoff hook puts its text into the child’s context. Because of this, the launch command omits --add-dir, which used to trigger a trust prompt for that directory on every child.

In tmux, for example, the launch command looks like this:

P=$(cat <<'EOF'
T-42: CSV export endpoint (product). Add GET /export with its tests, and open a PR on develop. <handoff>Follow your handoff, which session-hub adds to your context; if it is not there, read and follow <dir>/t42-product-handoff.md</handoff>
EOF
)
env SESSION_HUB_ROLE=child SESSION_HUB_MASTER=hub SESSION_HUB_MASTER_REF=8f2c1a \
SESSION_HUB_MASTER_SESSION_ID=<master session id> \
SESSION_HUB_SCOPE_ROOT=/work/hub/product SESSION_HUB_HANDOFF=<dir>/t42-product-handoff.md \
SESSION_HUB_REGISTRY=<config dir>/session-hub/children-<hub id>.json SESSION_HUB_GUARDS=on \
claude -n t42-product --model sonnet --effort medium --permission-mode default -- "$P"

The initial prompt shows anyone looking at the child session’s window what it is working on. It always travels in the launch command, even in Herdr, so if the child pauses at the repository trust prompt it starts on its task as soon as you respond. It stays on a single line because Herdr rejects prompts containing line breaks.

At launch, spawn also handles permission mode, account identity, and worktrees:

  • Permission mode: the child session inherits the master’s mode, because messages between sessions with mismatched permission-bypass settings would sit blocked waiting for manual confirmation. If the master skips permission prompts, spawn asks you on each launch which mode to give child sessions; with Permissions: inherit, it skips asking and uses the master’s.
  • Identity check: after launch, spawn checks that the child session appears in the session list. If it does not, the child is running under a different account; spawn warns you and does not hand off work to it.
  • Worktrees and write root: if the worktree lives inside the repository, the child session creates it and the repository stays its write root. If it is in a sibling folder, the master creates it before launch and that worktree becomes the write root. That is the only operation the master ever performs on a repository.

6. Communicating without noise: the five message types

Section titled “6. Communicating without noise: the five message types”

Once child sessions are running in parallel, all coordination follows a fixed format so the master receives concise updates without polling. Each child session talks only to the master:

[<task> <repo>] <type>: <text>

Messages from the master always start with [master]. The master never polls its children; it updates only when a message or an idle notification arrives.

Type When it is sent What the master does
question The child session is blocked on a decision Answers directly, or passes the question to you and relays your answer back
out-of-scope A need or request falls outside its scope (even when you ask for it directly inside the child session) Routes it: asks you to confirm if needed, forwards it to the relevant child session, starts a new one, or runs a read on its own
pr A pull request has been opened (the text includes its URL) Records the URL and applies the hub’s pull request rules
done The assigned work is finished Applies the hub’s completion rules
abandoned Work was stopped (the text explains why) Notifies you immediately

Across all five message types, one rule holds without exception: a message between sessions carries information, never authorization. No session runs merges, pushes, deletions, or settings changes solely because another session asked for them. When mods are active, session-hub prepends a reminder line to every incoming message.

A [master] message as received by the child session, preceded by the session-hub line stating that it is information, not authorization

A [master] message as received by the child session. The first line, starting with [session-hub], is the marker added by the mod. Demo data

Written instructions in the handoff spell out each child session’s boundaries, but prose alone cannot prevent an accidental slip. Three mechanisms enforce the scope of every child session. They run only in child sessions and share a simple, cautious rule: they fail closed. If a guard cannot be sure an operation is allowed, it stops it and explains why.

If you need to turn all three off for a specific case, set SESSION_HUB_GUARDS=off or Guards: off in the hub configuration.

The scope guard checks every file edit: outside a child it allows at once; in a child it blocks whenever it cannot decide, finds where the path really leads, allows the edit inside the write root or in a system temporary folder and blocks it elsewhere, telling the child to ask the master. With mods on, a best-effort check also watches the shell. The agent is about to edit a file Edit · Write · NotebookEdit Is this a child session? and are its guards turned on? Can the guard check this edit? a readable request, a valid write root, an absolute path, an answer within 7 s Find where the path really leads it follows links and “..” the way the file system does Is it inside the write root? or in a system temporary folder, where the child keeps its scratchpad Allowed: the edit goes ahead yes yes yes Allowed at once outside a child, the guard never gets in the way Blocked, and it says why when it cannot decide, it blocks: the guard fails closed Blocked: outside the write root the child asks the master with an out-of-scope message instead no no no With mods on, a best-effort check also watches the shell. It denies redirections and commands such as tee, cp, mv, rm or sed -i when they would write outside the write root; targets in variables or globs are not judged. With mods off, only the handoff forbids writing through the shell.
The scope guard resolves the real path of every edit, following symbolic links and .., and allows it only under the real write root or in a system temporary directory. Anything it cannot evaluate is blocked. With mods active, a best-effort check watches the shell as well.

The scope guard (hook, works even with mods disabled)

Section titled “The scope guard (hook, works even with mods disabled)”

session-hub-scope-guard runs before every Edit, Write, and NotebookEdit. It resolves the target’s real path component by component, blocking both a symbolic link pointing outside the repository and an adjacent folder sharing the same name prefix.

System temporary directories (/tmp, /var/folders, and on macOS /private/tmp and /private/var/folders) are an exception. A child session keeps throwaway files there, such as the session scratchpad or a pull request body, and writes them with Write and Edit, just as it already could from the shell. Even in these directories, paths are followed to their real target, and the rule on hard links still applies.

It also stops any ambiguous or misconfigured case:

  • a relative target path;
  • a write root set to / or the home folder;
  • a file with more than one hard link, since another name for it could live outside the write root and editing it would change that file too;
  • the repository’s Claude Code settings, .claude/settings.json and .claude/settings.local.json, because their env and hook settings would disable the child session’s guards on its next start (changes must be requested from the master, and the shell check blocks these files too);
  • an unknown role value or unreadable input;
  • node missing from PATH.

If the check takes too long, an internal watchdog blocks the operation after 7 seconds, ahead of the hook’s 10-second timeout.

A blocked write in a child session: the message starts with [session-hub] Write blocked, shows the path and write root, and tells the model to send an out-of-scope message

A write through a link pointing to another repository, blocked. The model is told not to retry with another tool, and to send an out-of-scope message to the master instead. Demo data

Before a child session runs a Bash or Monitor command, the mod parses it the way bash and zsh would (on macOS, the Bash tool uses zsh). It inspects redirections (including <> and zsh forms such as >!), the targets of tee, touch, mkdir, rm, rmdir, truncate, unlink, cp, mv, ln, install, and sed -i, and find operations (-delete, -fprint, and commands invoked via -exec or -execdir). It also inspects commands inside substitutions ($(…), backticks, and <(…), including inside double quotes and here-documents with an unquoted delimiter) along with the literal line passed to eval or sh -c. By tracking literal cd and pushd calls, it blocks any write outside the write root while allowing /dev and system temporary directories. It also blocks hard links to files outside the root and writes through a symbolic link created by the same command.

When it cannot parse a command (for example, a here-document whose delimiter never arrives), it blocks the command and explains why. The write root follows the same rules as the scope guard: it must be an existing directory and cannot be / or the home folder.

[session-hub] Shell command blocked: it writes /work/hub/design/notes.md, outside the write root /work/hub/product. Do not retry this write through another command or tool. Send an `out-of-scope` message to the master, saying what you need written and why, and tell the user that you passed the request to the master.

This check is best-effort because it inspects only the literal command line: it cannot evaluate targets hidden inside variables, command substitution output, or globs, nor what an invoked program (a script, git, or a build tool) writes internally.

To prevent sideways coordination between child sessions, a child may send messages only to its master (by name) or to its own subagents. Any other recipient, such as a sibling session or a socket address, is blocked with a notice pointing back to the master:

[session-hub] This session is a child and may message only its master, "hub". Send what you need to "hub" with your message prefix, even if the master was renamed: the guard delivers it to the master. A request for another session or repository is an `out-of-scope` message, and the master routes it.

A session’s name can change while it is running through /rename, a hook that sets the title after a reply, or Remote Control. Even then, the child session keeps writing to the name it received: the guard still recognizes the master by its ref or its new name and delivers the message using the master’s session ID. In the master, the mod warns you once when it is renamed while child sessions are running, and tells you whether they can still reach it.

If the message still cannot get through (for example, the master was closed or reopened under a different name), it is not lost: the child session’s mod saves it to the outbox next to the record and lets the child session know. The master reads it with dispatch.

In long sessions, initial instructions can get compacted or cleared. With mods active, session-hub keeps the role and scope (in a child session) or the record (in the master) visible in the system prompt at all times, and resends the same text as context on the first turn after startup, after compaction, and after /clear.

8. Checking status: /session-hub, the panel, and the card

Section titled “8. Checking status: /session-hub, the panel, and the card”

To inspect child sessions without interrupting the agent’s work, run /session-hub, registered by the mod. Its output is visible only to you and is never sent to the model.

In the terminal:

  • In the master, /session-hub prints the record path and a summary table of child sessions, and opens the panel beside the chat. Each row shows the recorded state, the live status from the session list, model, effort, and last message; the panel refreshes every 30 seconds and whenever you run /session-hub. It uses the same colors as model-router: the model in bold in its tier color, effort as a four-cell bar (▰▰▰▱ high) in its level color, and status in green when working, yellow when waiting, abandoned, or missing from the list, and red when lost. The command’s table includes the bar without colors.
  • In a child session, it summarizes the role, write root, handoff file, record, and guard status.

Below the rows, the panel links to the children record (the session-hub log): press l to open it. /session-hub log does the same, opening the record in the system’s default app and printing its path. If no record exists, it says so and opens nothing; in a child session, it opens the master’s record.

In the Claude desktop app, no panel opens beside the chat. Instead, /session-hub replies with a card in the conversation, styled like the app’s /context card. The header shows the role and, in the master, how many child sessions exist and how many are active. Clicking the title collapses the card down to its header and a bar breaking child sessions down by state. A menu on the left switches between two views that read the same record to answer different questions:

  • Children (/session-hub): the current state. In the master, it shows the role, hub, repositories, and record, followed by child sessions grouped by state (running, waiting for you, done, abandoned, lost); clicking a group name expands it. Each child row shows its model and effort in words (Sonnet · medium), what the active session list reports, and its last message. In a child session, the card shows its master, write root, handoff, and guard status instead.
  • Record (/session-hub log): the history of what happened and when. It shows counts of child sessions, events, and requests, when the first one started, and a newest-first timeline of the latest seven events (launches, latest messages, and requests with their outcomes). A menu on the right filters the timeline to a single child.

The bottom line of the card links to the record file. The most recent card refreshes every 30 seconds; older ones keep their header and bar.

The child sessions panel next to the master chat, with one row per running child session

The child sessions panel next to the master chat in an active hub.

The child sessions panel: for each child, its state, live status, model, effort, and last message

The panel rows: state in the record, live status from the session list, model and effort, last message. Demo data

When the master launches child sessions through a Bash command, a line appears under the command for each child, showing its model, effort, and name in the same colors (for example, ⎿ 🔀 opus ▰▰▰▱ high -> t123-product). The mod reads these values from the launch command written by spawn; a command specifying neither model nor effort gets no line. In the desktop app, the line is plain text: Started t123-product on Opus · high. A child launched with the desktop app’s start_session tool gets no line at all because the app’s own session card already names it, and nothing added by a mod renders beneath that card.

Here is an example of /session-hub output inside a child session:

Role: child of "hub"
Write root: /w/repo
Handoff: /h/t42.md
Children record: not set
Guards: on (scope guard, shell check, send guard)

/session-hub in a child session: role, write root, handoff, record, and guards

/session-hub in child session t123-product. Demo data

Output of /session-hub help

Output of /session-hub help.

Everything shown by /session-hub, the panel, and the desktop card comes from a single JSON file per hub. The master stores it outside the hub folder so temporary state never clutters a git repository:

<config dir>/session-hub/children-<hub id>.json

Here <config dir> is CLAUDE_CONFIG_DIR or ~/.claude, and <hub id> is the first 16 hex digits of the SHA-256 hash of the hub’s real path.

  • What each entry stores: name, repository, task, scope, model, effort, state, start time, last message, and requests.
  • Possible states: running, waiting-user, done, abandoned, and lost (recorded as active, but no longer present in the session list).
  • Master identity: the name, ref, and session ID the child sessions were started with; used to detect a rename.
  • Outbox: the children-<hub id>.outbox/ folder next to the record, with one file for each message a child session could not deliver. The panel counts them; dispatch reads them, handles them like newly arrived messages, and deletes them.

Skills update the file exclusively through scripts/registry.mjs, atomically and under a lock, to prevent corruption on concurrent writes. If the file does not contain valid JSON, the issue is reported without overwriting it. Likewise, a record error never blocks new sessions from starting: spawn warns you and moves on.

You can also inspect the record directly from the terminal:

node "<plugin folder>/scripts/registry.mjs" read --hub /work/hub

The current implementation has six practical limitations:

  • Best-effort, mod-dependent shell check. It works only when mods are enabled; when they are off, shell writes are constrained by the handoff alone.
  • No active guards in the desktop app. Its session-launch tool does not accept environment variables, so a child session opened there receives no role variables and relies solely on the handoff.
  • The send guard requires active mods. With mods disabled, a child session can message a sibling session: the rule to talk only to the master falls back to written instructions.
  • Resuming a child session requires its variables. If you run claude --resume without prepending the same SESSION_HUB_* variables, the session loses its child role.
  • An externally killed hook lets the write through. The 7-second internal watchdog protects against a slow check, not against a hook forcefully terminated from outside.
  • Trust is per repository. Running claude --bg in a repository nested inside an already trusted hub fails with Workspace not trusted until you open that repository at least once to confirm trust.

To see how these components fit together and trace the guards’ decision flow step by step, continue to the Architecture page.