claude-teams-behavior
Skill11 starsChanged 50 days agoApache-2.0View on GitHub
Claude Code Agent Teams patterns for the orchestrator. Loaded only in Claude Code sessions via claudeCli.skills. Provides hub-and-spoke contract, decision rules for SendMessage, background agent spawning, and agent name resolution.
In this repository83 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- about-konductorSkill
- adr-generatorSkill
- adversarial-code-review-pass-integritySkill
- adversarial-code-review-pass-schemaSkill
- adversarial-code-review-pass-securitySkill
- adversarial-code-reviewSkill
- adversarial-design-reviewSkill
- agents-md-authoringSkill
- app-discoverySkill
- architecture-advisorSkill
- architecture-diagram-generationSkill
- argumentation-referenceSkill
- asana-sprint-planningSkill
- asdlc-aspect-reviewSkill
- asdlc-code-simplifierSkill
- aws-service-validatorSkill
- backend-developmentSkill
- backend-reviewSkill
- cmux-dispatchSkill
- code-reviewSkill
- constraintsSkill
- cost-estimationSkill
- cypress-test-implementationSkill
- decision-researchSkill
- decision-writingSkill
- delegation-protocolSkill
- deliberation-panelSkill
- design-doc-guidelinesSkill
- design-evaluationSkill
- design-impact-reviewSkill
- design-quality-checkSkill
- doc-accuracy-analyzerSkill
- document-formatsSkill
- dom-inspectionSkill
- dynamodb-designSkill
- dynamodb-validationSkill
- e2e-test-strategySkill
- external-researchSkill
- find-aws-skillsSkill
- frontend-developmentSkill
- frontend-reviewSkill
- git-mergeSkill
- git-workflowSkill
- historical-issues-registrySkill
- humanize-writingSkill
- iam-policy-designSkill
- infra-validationSkill
- kiro-design-generationSkill
- kiro-requirements-generationSkill
- kiro-task-generationSkill
- legacy-to-agentic-estimateSkill
- mux-dispatchSkill
- non-functional-requirementsSkill
- persistent-memorySkill
- plan-reviewSkill
- playwright-test-implementationSkill
- policy-validationSkill
- pre-planning-analysisSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Specialists never message each other: All coordination flows through you.
- Distinctive: line 18
You are the single point of coordination: Do not instruct specialists to spawn further specialists or to relay messages to peers.
- Very specific: line 75
Write agent's first action, before touching any file: if a worktree was named, independently re-run git worktree list (the orchestrator's …
- Very specific: line 109
When spawning subagents via Agent(), use the full installed agent name — short names do not resolve.
- Very specific: line 127
When SendMessage is in your tool list, prefer run_in_background: true for parallel work — it unlocks mid-run communication that …
- Very specific: line 131
Check your tool list for SendMessage:
- Very specific: line 138
Use background agents (run_in_background: true) when:
- Distinctive: line 145
Do NOT use background agents when:
- Very specific: line 169
Same-task follow-up →
SendMessage: When a subagent returns and needs follow-up on that same task, use SendMessage (retains session …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Claude Code Agent Teams
This skill is loaded only in Claude Code. It provides the orchestrator with the hub-and-spoke contract and decision rules for Agent Teams features (background agents, SendMessage).
Hub-and-Spoke Contract
You (the orchestrator) are the sole hub. The rules below are MANDATORY:
- SendMessage targets ONLY agents you spawned via
Agent(). You never message agents you did not spawn. - Specialists never message each other. All coordination flows through you. A specialist that completes its work reports back to you; you decide what happens next.
- You are the single point of coordination. Do not instruct specialists to spawn further specialists or to relay messages to peers.
This constraint keeps multi-agent behavior portable across runtimes. This skill and Claude's SendMessage/Agent() tools are scoped to Claude Code only (via claudeCli.skills / claudeCli.tools); the same specialists also run as Kiro CLI subagents, which are one-shot with no peer-messaging channel — the orchestrator spawns a specialist, it runs to completion in isolation, and returns its result. Peer-to-peer coordination therefore cannot be relied on cross-runtime, so all coordination flows through the orchestrator. This also matches the documented orchestrator-only dispatch design: native dispatch belongs solely to the orchestrator, and nested subagent spawning is unsupported in both runtimes.
Tool Usage: Direct Reads and Read-only Bash
What you do yourself is defined once, in the Orchestrator Direct Work table of k-orchestrator-routing-rules.md. On Claude Code that means Read, Glob, and Grep for files and search, and Bash only for the read-only commands that table lists. Before dispatching a write agent, read .wt-ledger.json and run git worktree list this way (see Worktree Scoping below). git worktree add, git worktree remove, and every other state-changing command stay delegated to the write agent.
Worktree Scoping
Agent() has no cwd parameter — a spawned Claude Code subagent starts in
the orchestrator's own working directory. Working-tree isolation is
established by prompt, not by parameter.
The rule: every write-agent dispatch prompt must explicitly name the exact target — never let the agent infer or default. A silent default is the actual collision mechanism: two agents (from the same task or from different tasks) can each independently default into the same location and step on each other, even when neither dispatch looked "concurrent" from the orchestrator's own point of view. The named target is one of three legitimate forms:
- A new dedicated worktree —
wt-<id>on branchwt-<id>(worktree and branch share one flat name), for the agent to create. - An existing worktree to reuse —
wt-<id>at<path>on branchwt-<id>. - The shared primary tree, on a named feature branch
<branch>— a deliberate, explicit choice, only for a single sequential write agent with no concurrent writer sharing that tree.
Read-only agents (research, investigation, review) need no worktree decision at all — they share the primary working tree by default, and the dispatch prompt does not need to name a target.
Before dispatch (orchestrator, read-only): using the direct reads
above, check current worktree state (.wt-ledger.json and git worktree
list — treat git worktree list as ground truth over the ledger, which can
go stale) and decide which of the three forms applies for this task. This is
a read plus a naming decision, not a mutation, so the zero-mutation rule
still holds.
State the decision in the dispatch prompt:
Agent(
subagent_type: "<prefix>k-developer",
prompt: "Worktree wt-<id> already exists at <path> — cd in, do not create
a new one.
[OR: No worktree exists for this task — create wt-<id> before
touching any file.]
[OR: Work directly on branch <branch> in the shared working tree
at <path> — no worktree for this task.]
TASK: <task description>
..."
)Write agent's first action, before touching any file: if a worktree was
named, independently re-run git worktree list (the orchestrator's read
could be stale by dispatch time), then either cd into the existing
worktree or provision it — running $WORKTREE_PROVISION_CMD wt-<id> if that
variable is set in its environment, otherwise git worktree add (see
mux-dispatch/cmux-dispatch's Provisioning command section for the same
hook). If the shared tree was named, check out the named branch there. The
write agent was always going to mutate — this is an explicit first step, not
new authority.
This is a best-effort guardrail, not a hard boundary — the subagent could in principle ignore the instruction. Two things provide harder enforcement after the fact:
- The pre-commit hook (husky/lint-staged, or the equivalent for this project) runs inside the tree the agent actually committed from — edits made outside the named target simply will not surface in that commit.
- The CR diff at review time shows exactly which files changed; a human reviewer catches any file that should not have been touched before merge.
Sequential handoff is the reuse case above, not a special case — a second write agent continuing the same task gets the same named target (worktree or shared-tree branch) in its prompt and resumes there.
Concurrent collaboration on one target is not supported, by design —
that is the exact collision this mechanism exists to prevent, whether the
target is a worktree or the shared tree. A maker/checker pair never shares a
target; a checker gets its own separate read-only checkout (e.g.
CrCheckout), never the maker's tree. Only sequential reuse of a named
target is legitimate; two write agents on the same target at the same time
is always wrong.
Agent Name Resolution
When spawning subagents via Agent(), use the full installed agent name — short names do not resolve. Derive the correct prefix from your own agent name:
- Your agent name contains the install prefix, if any (e.g.,
konductor:konductorfor a Claude Code plugin install,konductorfor a.claude/agents/install) - Replace your role suffix with the target specialist's role to get the full name
- Example: if you are
konductor:konductor, spawnkonductor:k-developer - Example: if you are
konductor, spawnk-developer
The prefix varies by install type (plugin vs .claude/agents/). Always match your own prefix.
SendMessage / Background Agents
How to Achieve Parallel Execution
Both fire-and-wait (multiple Agent() calls in one message) and run_in_background: true achieve true parallelism — agents run concurrently in both cases. The difference is:
- Fire-and-wait: orchestrator blocks until all complete, receives all results in one response turn. Best for short, independent lookups where you need all results before proceeding.
- Background agents (
run_in_background: true): orchestrator continues working while agents run, receives notifications individually as each completes, and can inject context mid-run viaSendMessage. Best for long-running work, maker-checker patterns, and tasks where findings from one agent should feed another.
When SendMessage is in your tool list, prefer run_in_background: true for parallel work — it unlocks mid-run communication that fire-and-wait cannot provide. See the Decision Rule below for when each is appropriate.
Detection
Check your tool list for SendMessage:
- Present → use the Teams patterns below
- Absent → use standard
Agent()fire-and-wait calls
Decision Rule
Use background agents (run_in_background: true) when:
- You have 2+ independent subtasks that can run concurrently
- Tasks do NOT depend on each other's output
- You want to inject findings from one agent into another mid-run
- Tasks are long-running and you want to continue working while waiting
Do NOT use background agents when:
- Task B depends on Task A's output (use sequential
Agent()calls) - There is only one subtask
- The task is simple enough for a single agent (short lookups — fire-and-wait is fine)
Full Pattern
# Step 1 — spawn independent agents simultaneously
researcher_id = Agent(subagent_type: "konductor:k-researcher", run_in_background: true, prompt: "Research X")
developer_id = Agent(subagent_type: "konductor:k-developer", run_in_background: true, prompt: "Implement Y")
# Step 2 — inject follow-up context mid-run if needed (hub only — never specialist-to-specialist)
SendMessage(to: researcher_id, message: "Also check Z")
SendMessage(to: developer_id, message: "Use the pattern from file W")
# Step 3 — wait for completion notifications (runtime notifies you — do NOT poll)
# Step 4 — aggregate results and report to userResume Over Re-spawn
Same-task follow-up → SendMessage. When a subagent returns and needs follow-up on that same task, use SendMessage (retains session context) instead of a new Agent() (starts from zero).
Independent work → new Agent(). Spawn fresh for genuinely new tasks, even while another session is active. Don't serialize unrelated work behind one session — that defeats concurrency.
Primitives
| Primitive | What it does |
Agent(run_in_background: true, ...) | Spawns a background agent, returns agentId |
SendMessage(to: <agentId>, message: "...") | Resumes an existing agent's session — does NOT spawn new agents |
Agent() (no run_in_background) | Fire-and-wait — use when Teams is unavailable or task is sequential |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

