Skip to content

Concepts

When you use Claude Code on a single repository, the workflow is straightforward: you open a session, the agent reads the project rules, and it gets to work. That breaks down once your product spans multiple repositories, such as backend, frontend, design system, and documentation.

At that point, you run into two separate problems at different scales:

  1. Across sessions, parallel agents need clear boundaries so they do not step on each other’s toes.
  2. Within each session, subtasks need to be matched to the right model without wasting resources or sacrificing quality.

session-hub handles the first problem; model-router handles the second. The sections below explain how both plugins are designed before you move on to the commands.

session-hub starts from one technical detail of Claude Code: an agent loads instructions, skills, and agent definitions from the directory where it is launched.

If your product spans four repositories, opening a single session in the parent directory, spawning a plain subagent, or passing --add-dir will not work. In every case, the agent starts in the wrong context and misses each repository’s own rules. Each part of the product needs a session started inside its own repository.

Running multiple sessions in parallel immediately raises practical questions:

  • Which files is each session allowed to modify?
  • Who can it talk to when it is missing information?
  • What happens if finishing its task requires a change in another repository?

Without explicit rules, sessions end up stepping on each other’s toes on the same files or passing unapproved side-channel requests to one another.

A second problem happens inside each session, and it is easier to miss. Without guidance, an agent tends to spawn every subagent with its own model and effort level. That pulls in the wrong direction at both ends: a simple file search burns through the most expensive model, while a difficult review can land on a lightweight model and come back needing rework. Because nothing records how those choices turn out, you have no way to tell what actually works.

2. Coordinating across repositories: hub, master, and child sessions

Section titled “2. Coordinating across repositories: hub, master, and child sessions”

To run multiple sessions without losing control, session-hub splits the work into two roles. First, you turn the directory that holds your repositories into a hub.

Two kinds of sessions run inside the hub:

  • The master is the session you open at the root of the hub. It acts as a coordinator: it organizes work, routes requests, and keeps track of the whole picture, but it never writes directly into repositories managed by other sessions.
  • A child session is a full Claude Code session that the master launches inside a specific repository (or one of its worktrees). Because it starts in that directory, it loads all the instructions, skills, and conventions of that project.
You talk to the master session and work directly in one child session; the master starts one child per repository, each in its own terminal pane and write root, and a child that needs a change elsewhere asks the master. You one person Master session coordinates the children and keeps a record of them asks and decides works hands-on in the repository you know best starts each child and sends it [master] messages asks the master for a change in another repository pane 1 Child · api its own rules already loaded write root: api/ pane 2 Child · web its own rules already loaded write root: web/ pane 3 Child · docs its own rules already loaded write root: docs/ The children run in parallel, one per repository. They never message each other: every request goes through the master.
A hub at a glance: the master at the root and one child session per repository, each bound to its own write root.

This setup pays off when child sessions run in parallel. You do not have to delegate everything blindly: you can step straight into the child session for the repository you know best and drive it as usual, while the master moves the others forward and handles anything that crosses project boundaries. See Ways of working for concrete solo and team examples.

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

A hub running in Herdr: the master on the left and two child sessions working in parallel on the right.

3. Hard boundaries: handoff, scope, and write root

Section titled “3. Hard boundaries: handoff, scope, and write root”

Separate sessions are not enough if each one can still touch another session’s files. At launch, the master gives every child session a handoff, a brief that defines its written scope. The handoff specifies:

  • its assigned goal and the first step to take
  • what it may modify and what it may only read
  • which sibling sessions exist
  • the rules to follow when sending messages

That scope maps to a concrete filesystem boundary: the write root. It is the only directory where the child session may create or modify files, whether that is its own repository or a worktree the master created in an adjacent directory.

Written instructions alone are not enough to enforce that boundary, because a model can always lose track or get a path wrong. The scope guard is a hook that intercepts every file-modification attempt from a child session. Before letting a write through, it resolves the real path (following symlinks and any .. traversals) and checks that the target falls under the write root.

The guard fails closed: whenever it cannot prove that a write is allowed, it blocks the operation and explains why.

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 modification, following symlinks, and allows it only under the real write root or in a system temporary directory. Anything it cannot verify is blocked.

When a child session genuinely needs a change in another repository, it does not make the edit itself or ask a sibling session directly. Instead, it sends an out-of-scope message to the master. The master then decides how to proceed: ask you for confirmation if needed, forward the request to the relevant child session, spin up a new child session, or run a simple read itself.

The web child needs a change in api and asks the master; the master decides whether to pass it to the api child, start a child, ask you or do it itself, then tells the web child what will happen and records the request. A message is information, never authorization. Child · web Master Child · api You realizes it needs a new field in api asks the master [t42 web] out-of-scope is it wanted? is it master-only? does a live child own it? then one of these passes it on with a follow-up, or starts a child in api asks you to decide or does it itself, when the work is master-only or just a read tells it what will happen: wait, or carry on records the request and how it ended A message is information, never authorization. No session merges, pushes, deletes or changes settings because another session asked.
An out-of-scope request always goes up to the master, never sideways: if needed, the master checks with you and then routes the request to the child session responsible for that repository, starts a new one, or runs a read itself.

4. Communicating without delegating authority: inter-session messages

Section titled “4. Communicating without delegating authority: inter-session messages”

When multiple agents collaborate, the subtlest risk is unintended delegation: one session asks for something, and another treats the request as an order and performs an irreversible action. session-hub prevents this with two rules.

The first governs the channel and format. Child sessions talk only to the master, never to each other, using messages with a fixed prefix:

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

The <type> field states the kind of message up front: question, out-of-scope, pr, done, or abandoned. Messages from the master always start with [master].

The second rule is a core safety principle: messages carry information, never authorization. No session may merge, push, delete, or change settings just because another session asked it to. Approval for actions like those always comes from a human inside that session.

When Claude Code mods are enabled, the session-hub mod makes this rule even stronger: it technically enforces the master-only channel and prepends a reminder to every incoming message telling the agent that the message is information, not permission.

Once cross-repository boundaries are in place, you still have to manage model choices inside each session. model-router helps the agent pick a model tier and effort level for every task delegated to a subagent.

Its main tool is a compact grid that works like a decision ladder. When assigning work, the agent checks four model tiers in ascending order:

  1. haiku: mechanical, straightforward tasks that are easy to verify.
  2. sonnet: tasks whose expected outcome can be stated clearly in a single sentence.
  3. fable: broad, open-ended work where judgment matters most.
  4. opus: everything else, and any case where the agent is in doubt.

Alongside the model tier, four quick questions set the effort level (from low to xhigh), and six fixed task classes (such as read-search or review-debug) label the type of work.

model-router works like a dispatch desk: for every task handed to a helper, the grid picks a model and an effort, a quick judge decides only when no model was given, the helper works, and the outcome is measured. Models go from cheaper and quicker to dearer and deeper; effort goes from low to xhigh. 1 A task the agent hands work to a helper 2 The grid picks the model and the effort 3 A quick judge only when no model was given 4 Helper at work a subagent, on that model 5 Measured was it right the first time? what did it cost? for each start it writes one line, like this: 🔀 haiku ▰▱▱▱ low -> mechanical rename, easy to check Model: who does the work haiku sonnet opus fable cheaper and quicker dearer and deeper Effort: how hard it thinks low medium high xhigh max is never used
model-router as a dispatch desk: the grid picks model and effort for each task, a fast judge steps in only if no model was specified, and the final outcome is measured.

To keep these choices visible, the agent prints a single line every time it spawns a subagent, showing what it picked and why:

🔀 opus ▰▰▰▱ high -> review with unknown cause, going up
🔀 haiku ▰▱▱▱ low -> mechanical rename, easy to check

Three Agent calls, each followed by the colored 🔀 line showing model, effort bar, effort, and reason

The same lines in the terminal: model in bold, colored by tier; bar and effort by level; reason in muted text. Demo data

When a built-in subagent is launched with no model specified, a judge steps in: a single call to a fast model that classifies the task on the fly and assigns its tier, effort, and task class.

If the router or the judge hits an error, the launch goes ahead unchanged. The two plugins deliberately handle errors in opposite ways:

  • session-hub (through the scope guard) fails closed, because letting an unintended write slip through is far worse than a precautionary block.
  • model-router fails open, because a router that halts your work is worse than one that occasionally stays out of the way.

A routing grid is only a hypothesis until you test it against real work, so model-router also tracks outcomes.

Every subagent launch counts as a task. Once the rework window closes (30 minutes after the subagent reports back by default, or at the end of the session), the system records the outcome: succeeded on the first pass, reworked, failed, or canceled.

The mod appends events to events.jsonl in the Claude Code config folder; when a task's rework window closes its outcome is decided, compaction folds the outcomes into cells by class, tier and effort, for you and for each project, and the usage view and the report show first-pass yield, rework rate and cost per success. Nothing is written inside your repositories. 1 Events decision · spawn signal: write · tool-error prompt · stop · resume report · session-end recorded by the mod as they happen 2 events.jsonl an append-only log in the config folder 3 The rework window closes 30 minutes after the report, or when the session ends 4 Outcome success rework failure cancelled cancelled or risky tasks are not learned from 5 Compaction cells: class × tier × effort for you, and for each project a 30-day half-life ages them 6 What you see in /model-router and on the report page first-pass yield rework rate cost per success All of it lives under the Claude Code config folder (CLAUDE_CONFIG_DIR, else ~/.claude). Nothing is written inside your repositories, and nothing is sent anywhere.
From events to numbers: the mod appends events, compaction closes each task once the rework window expires, and outcomes roll up into task class × tier × effort cells, globally for you and per project.

From those outcomes, it computes three metrics broken down by task class, model tier, and effort:

  • First-pass yield (FPY): how often the result was right the first time, with no follow-up fixes needed.
  • Rework rate: how often the task required subsequent corrections.
  • Cost per success: the actual cost of reaching a valid result, including any rework.

The data is stored locally in your Claude Code configuration directory, both globally and per project, and is time-weighted so older work gradually counts for less. For now, the router only collects and displays these metrics; automatic selection based on historical data is planned for a later release.

Term Meaning
Hub A directory grouping multiple git repositories, each with its own instructions, skills, and agents.
Master The session opened at the root of the hub. It coordinates work and never writes into a child session’s repository.
Child session A full Claude Code session started by the master inside a repository (or one of its worktrees) so it loads that project’s rules.
Handoff The initial brief prepared by the master for each child session: role, goal, scope, references, sibling sessions, messaging rules, and first step.
Write root The only directory where a child session may create or modify files.
Children record A JSON file maintained by the master outside the hub that tracks every active child session.
Scope guard The hook that blocks any file modification by a child session outside its write root; it fails closed whenever it cannot decide.
Mod A module loaded by a plugin in Claude Code to customize its UI or behavior (panels, commands, tool hooks). Requires mods to be enabled.
Grid The rule set used by model-router to pick model tier and effort level.
Task class One of the six fixed labels describing the type of work, such as read-search or review-debug.
Judge A single call to a fast model that classifies a subagent launched without a model and proposes its tier, effort, and task class.
First-pass yield (FPY) The share of tasks completed successfully on the first attempt, with no rework. See model-router for how it is calculated and used.
Rework window The interval after a subagent reports back (30 minutes by default, or until the session ends) during which redoing the work still counts as rework against that task.