Get the FREE Ultimate OpenClaw Setup Guide →

team-management

npx machina-cli add skill zircote/claude-team-orchestration/team-management --openclaw
Files (1)
SKILL.md
8.4 KB

Team Management

Create, manage, and shut down agent teams. This skill covers team lifecycle from creation through cleanup.

Experimental: Agent teams are disabled by default. Enable with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS in your settings.json or environment.

Related skills:


Core Architecture

A team consists of:

  • Leader (you) - Creates team, spawns workers, coordinates work
  • Teammates (spawned agents) - Execute tasks, report back
  • Task List - Shared work queue with dependencies
  • Inboxes - JSON files for inter-agent messaging

File Structure

~/.claude/teams/{team-name}/
├── config.json              # Team metadata and member list
└── inboxes/
    ├── team-lead.json       # Leader's inbox
    ├── worker-1.json        # Worker 1's inbox
    └── worker-2.json        # Worker 2's inbox

~/.claude/tasks/{team-name}/
├── 1.json                   # Task #1
├── 2.json                   # Task #2
└── 3.json                   # Task #3

Team Config Structure

{
  "name": "my-project",
  "description": "Working on feature X",
  "leadAgentId": "team-lead@my-project",
  "createdAt": 1706000000000,
  "members": [
    {
      "agentId": "team-lead@my-project",
      "name": "team-lead",
      "agentType": "team-lead",
      "color": "#4A90D9",
      "joinedAt": 1706000000000,
      "backendType": "in-process"
    },
    {
      "agentId": "worker-1@my-project",
      "name": "worker-1",
      "agentType": "Explore",
      "model": "haiku",
      "prompt": "Analyze the codebase structure...",
      "color": "#D94A4A",
      "planModeRequired": false,
      "joinedAt": 1706000001000,
      "tmuxPaneId": "in-process",
      "cwd": "/Users/me/project",
      "backendType": "in-process"
    }
  ]
}

Two Ways to Spawn Agents

Method 1: Task Tool (Subagents)

Use Task for short-lived, focused work that returns a result:

Task({
  subagent_type: "Explore",
  description: "Find auth files",
  prompt: "Find all authentication-related files in this codebase",
  model: "haiku"  // Optional: haiku, sonnet, opus
})

Characteristics:

  • Runs synchronously (blocks until complete) or async with run_in_background: true
  • Returns result directly to you
  • No team membership required
  • Best for: searches, analysis, focused research

Method 2: Task Tool + team_name + name (Teammates)

Use Task with team_name and name to spawn persistent teammates:

// First create a team
TeamCreate({ team_name: "my-project", description: "Working on feature X" })

// Then spawn a teammate into that team
Task({
  team_name: "my-project",        // Required: which team to join
  name: "security-reviewer",      // Required: teammate's name
  subagent_type: "general-purpose",
  prompt: "Review all authentication code for vulnerabilities. Send findings to team-lead.",
  run_in_background: true         // Teammates usually run in background
})

Characteristics:

  • Joins team, appears in config.json
  • Communicates via inbox messages
  • Can claim tasks from shared task list
  • Persists until shutdown
  • Best for: parallel work, ongoing collaboration, pipeline stages

Key Difference

AspectTask (subagent)Task + team_name + name (teammate)
LifespanUntil task completeUntil shutdown requested
CommunicationReturn valueInbox messages
Task accessNoneShared task list
Team membershipNoYes
CoordinationOne-offOngoing

Creating a Team

TeamCreate

TeamCreate({
  team_name: "feature-auth",
  description: "Implementing OAuth2 authentication"
})

Creates:

  • ~/.claude/teams/feature-auth/config.json
  • ~/.claude/tasks/feature-auth/ directory
  • You become the team leader

Constraint: One team per session. Clean up the current team before starting a new one.


Delegate Mode

By default, the lead may start implementing tasks itself instead of waiting for teammates. Delegate mode restricts the lead to coordination-only tools: spawning, messaging, shutting down teammates, and managing tasks.

When to use: When you want the lead to focus entirely on orchestration (breaking down work, assigning tasks, synthesizing results) without touching code directly.

How to enable: Start a team first, then press Shift+Tab to cycle into delegate mode.


Permissions Model

  • Teammates start with the lead's permission settings
  • If the lead runs with --dangerously-skip-permissions, all teammates do too
  • You can change individual teammate modes after spawning
  • You cannot set per-teammate modes at spawn time

Environment Variables

Spawned teammates automatically receive these:

CLAUDE_CODE_TEAM_NAME="my-project"
CLAUDE_CODE_AGENT_ID="worker-1@my-project"
CLAUDE_CODE_AGENT_NAME="worker-1"
CLAUDE_CODE_AGENT_TYPE="Explore"
CLAUDE_CODE_AGENT_COLOR="#4A90D9"
CLAUDE_CODE_PLAN_MODE_REQUIRED="false"
CLAUDE_CODE_PARENT_SESSION_ID="session-xyz"

Using in prompts:

Task({
  team_name: "my-project",
  name: "worker",
  subagent_type: "general-purpose",
  prompt: "Your name is $CLAUDE_CODE_AGENT_NAME. Use it when sending messages."
})

Plan Approval

For complex or risky tasks, require teammates to plan before implementing:

Task({
  team_name: "careful-work",
  name: "architect",
  subagent_type: "Plan",
  prompt: "Design an implementation plan for adding OAuth2 authentication",
  mode: "plan",  // Requires plan approval
  run_in_background: true
})

When the teammate finishes planning, they send a plan_approval_request to the lead. The lead reviews and either approves or rejects with feedback. If rejected, the teammate stays in plan mode, revises based on feedback, and resubmits.

See Messaging for plan approval tool syntax.


Graceful Shutdown

Always follow this sequence:

// 1. Request shutdown for all teammates
SendMessage({ type: "shutdown_request", recipient: "worker-1", content: "All tasks complete" })
SendMessage({ type: "shutdown_request", recipient: "worker-2", content: "All tasks complete" })

// 2. Wait for shutdown approvals
// Teammates respond with: SendMessage({ type: "shutdown_response", request_id: "...", approve: true })

// 3. Only then cleanup
TeamDelete()

Shutdown behavior: Teammates finish their current request or tool call before shutting down, which can take time.

Crashed teammates: Teammates have a 5-minute heartbeat timeout. If a teammate crashes:

  1. They are automatically marked as inactive after timeout
  2. Their tasks remain in the task list
  3. Another teammate can claim their tasks
  4. Cleanup will work after timeout expires

Cleanup

TeamDelete

TeamDelete()

Removes:

  • ~/.claude/teams/{team-name}/ directory
  • ~/.claude/tasks/{team-name}/ directory

IMPORTANT:

  • Will fail if teammates are still active. Use shutdown first.
  • Always use the lead to clean up. Teammates should not run cleanup because their team context may not resolve correctly.

Discovering Team Members

Teammates can read the team config file to discover other team members:

cat ~/.claude/teams/{team-name}/config.json

The config contains a members array with each teammate's:

  • name - Human-readable name (always use this for messaging and task assignment)
  • agentId - Unique identifier (for reference only)
  • agentType - Role/type of the agent

IMPORTANT: Always refer to teammates by their name (e.g., "team-lead", "researcher", "tester").

Source

git clone https://github.com/zircote/claude-team-orchestration/blob/main/skills/team-management/SKILL.mdView on GitHub

Overview

Team management covers the lifecycle of agent teams, from creation through cleanup. It coordinates a Leader (you) and Teammates, maintains a shared Task List and Inboxes, and supports spawning workers, delegate mode, and permissions. Note: agent teams are experimental and disabled by default; enable with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS.

How This Skill Works

A team contains a Leader, Teammates, a shared Task List, and Inboxes, with data stored under ~/.claude/teams/{team-name}/ and ~/.claude/tasks/{team-name}/. You spawn workers either as subagents via the Task Tool for short-lived work or as persistent Teammates by first creating the team with TeamCreate and then spawning with team_name and name to join the team, where they communicate via inbox messages and can claim tasks from the shared list.

When to Use It

  • Setting up a new team and metadata for a project
  • Spawning workers to handle parallel tasks within a project
  • Configuring team modes, permissions, or delegate options
  • Coordinating ongoing collaboration with persistent teammates
  • Shutting down a completed team and performing cleanup

Quick Start

  1. Step 1: Enable experimental agent teams in settings.json or environment.
  2. Step 2: Create the team with TeamCreate({ team_name, description }).
  3. Step 3: Spawn teammates using Task({ team_name, name, subagent_type, prompt, run_in_background }). Manage lifecycle and shut down when done.

Best Practices

  • Enable the experimental agent teams flag (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS) before use.
  • Document team metadata in config.json and keep member details accurate.
  • Choose the spawn method appropriately: Task for short-lived subagents vs TeamCreate + team Task for persistent teammates.
  • Monitor inboxes and shared task lists to ensure clear communication and task ownership.
  • Shut down teams intentionally to trigger resource cleanup and avoid leaks.

Example Use Cases

  • Create a new project team and spawn workers to handle initial analysis tasks.
  • Spawn a persistent teammate to perform ongoing security reviews with tasks pulled from the shared list.
  • Use a Task (subagent) to quickly locate authentication-related files in the codebase.
  • Enable delegate mode to allow a teammate to operate with delegated authority on behalf of the lead.
  • Shutdown and clean up a completed team when the project ends.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers