# https://github.com/HKUDS/ClawTeam 项目说明书

生成时间：2026-05-17 05:40:48 UTC

## 目录

- [Introduction to ClawTeam](#page-introduction)
- [Quick Start Guide](#page-quickstart)
- [System Architecture](#page-architecture)
- [Event System](#page-event-system)
- [Agent Spawning System](#page-agent-spawning)
- [Task Management System](#page-task-management)
- [Team Management](#page-team-management)
- [Transport Layer](#page-transport)
- [Messaging & Inbox System](#page-messaging)
- [Board & Monitoring Dashboard](#page-board-dashboard)

<a id='page-introduction'></a>

## Introduction to ClawTeam

### 相关页面

相关主题：[System Architecture](#page-architecture), [Quick Start Guide](#page-quickstart)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [website/src/App.jsx](https://github.com/HKUDS/ClawTeam/blob/main/website/src/App.jsx)
- [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)
- [skills/clawteam/SKILL.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/SKILL.md)
- [clawteam/spawn/wsh_backend.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/wsh_backend.py)
- [clawteam/team/tasks.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)
- [clawteam/harness/context_recovery.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/context_recovery.py)
- [clawteam/spawn/session_locators/claude.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/session_locators/claude.py)
</details>

# Introduction to ClawTeam

ClawTeam is an agent swarm orchestration CLI designed to coordinate multiple coding agents—including Claude Code, Codex, OpenClaw, nanobot, and other terminal-native clients—from a single command-line interface. It serves as the coordination layer that enables agents to plan, delegate, and ship code together as a unified team.

## Purpose and Scope

ClawTeam addresses a fundamental limitation in modern AI-assisted development: isolated agent sessions working independently without coordination. The platform provides:

- **Team Management**: Create and manage teams of agents with designated leaders
- **Task Coordination**: Shared task boards with dependency tracking and priority levels
- **Inter-Agent Communication**: File-based inbox system for point-to-point and broadcast messaging
- **Session Management**: Spawn, monitor, and lifecycle control of agent processes
- **Context Injection**: Git-aware context tools for worktree isolation and overlap detection

资料来源：[skills/clawteam/SKILL.md]()

## Architecture Overview

ClawTeam follows a leader-worker architecture where one agent serves as the coordinator while others perform specialized tasks.

```mermaid
graph TD
    A[Leader Agent] --> B[Worker Agent 1]
    A --> C[Worker Agent 2]
    A --> D[Worker Agent N]
    B --> E[Task Store]
    C --> E
    D --> E
    A --> F[Message Inboxes]
    B --> F
    C --> F
    D --> F
    G[CLI Interface] --> A
    G --> H[Board Dashboard]
```

### Core Components

| Component | Description |
|-----------|-------------|
| **CLI Interface** | Command-line entry point for all operations |
| **Team Manager** | Handles team creation, membership, and discovery |
| **Task Store** | File-based task board with dependency chains |
| **Message Inbox** | Per-agent file-based message queue |
| **Spawn Backends** | tmux, subprocess, wsh for launching agents |
| **Session Locators** | Detects and captures existing agent sessions |

资料来源：[clawteam/team/tasks.py:1-12]()

## Data Storage Model

All data is persisted in `~/.clawteam/` with a structured directory layout:

```
~/.clawteam/
├── teams/{team}/
│   ├── config.json          # TeamConfig (name, members, leader)
│   └── inboxes/{agent}/     # msg-{timestamp}-{uuid}.json files
├── tasks/{team}/
│   └── task-{id}.json       # Individual task files
└── plans/
    └── {agent}-{id}.md      # Plan documents
```

资料来源：[skills/clawteam/references/cli-reference.md]()

## Task Management System

Tasks form the backbone of team coordination, supporting four distinct statuses:

| Status | Description |
|--------|-------------|
| `pending` | Not yet started |
| `in_progress` | Currently being worked on |
| `completed` | Done (auto-unblocks dependents) |
| `blocked` | Waiting on other tasks |

### Task Dependencies

Tasks support dependency chains through two parameters:

- `--blocks`: Task IDs this task blocks upon completion
- `--blocked-by`: Task IDs blocking this task from starting

When a task is marked `completed`, any tasks blocked by it are automatically unblocked (moved from `blocked` to `pending` if no other blockers remain).

资料来源：[skills/clawteam/references/cli-reference.md]()

```mermaid
graph LR
    T1[Task 1: Design] --> T2[Task 2: Implement]
    T2 --> T3[Task 3: Test]
    T3 --> T4[Task 4: Deploy]
    T1 -->|blocks| T2
    T2 -->|blocks| T3
    T3 -->|blocks| T4
```

## Message Types

The inbox system supports various message types for inter-agent communication:

| Type | Description |
|------|-------------|
| `message` | General point-to-point message |
| `broadcast` | Broadcast to all members |
| `join_request` | Request to join team |
| `join_approved` / `join_rejected` | Join response |
| `plan_approval_request` | Plan submitted for review |
| `plan_approved` / `plan_rejected` | Plan response |
| `shutdown_request` | Shutdown request |
| `shutdown_approved` / `shutdown_rejected` | Shutdown response |
| `idle` | Agent idle notification |

资料来源：[skills/clawteam/references/cli-reference.md]()

## Spawn Backends

ClawTeam supports multiple spawn backends for launching agents:

| Backend | Description |
|---------|-------------|
| `tmux` | Default backend, sessions in tmux panes |
| `subprocess` | Direct subprocess spawning |
| `wsh` | WebSocket handler for IDE integration |

The spawn command configures team environment variables for spawned agents:

```bash
clawteam spawn <backend> <command...> [options]
```

| Option | Description | Default |
|--------|-------------|---------|
| `--team, -t` | Team name | `"default"` |
| `--agent-name, -n` | Agent name | auto-generated |
| `--agent-type` | Agent type | `"general-purpose"` |

资料来源：[clawteam/spawn/wsh_backend.py:1-30]()

## Session Management

For Claude Code specifically, ClawTeam integrates with existing sessions:

```python
# Session capture flow from clawteam/spawn/session_locators/claude.py
session_id = str(uuid.uuid4())
return PreparedSession(
    command=[*command, "--session-id", session_id],
    client=self.client,
    session_id=session_id,
    source="generated",
    confidence="exact",
    cwd=context.cwd,
)
```

The system can detect existing sessions via:
- Environment variables (`CLAUDE_CODE_SESSION`, `CLAUDE_SESSION_ID`)
- Project directory session files (`.jsonl` format)

资料来源：[clawteam/spawn/session_locators/claude.py:1-60]()

## Lifecycle Management

Agents support a complete lifecycle for graceful shutdown:

```mermaid
graph TD
    A[Agent Running] --> B{Shutdown Request}
    B -->|approve| C[Agent Shuts Down]
    B -->|reject| D[Agent Continues]
    A --> E[Idle Notification]
    E --> F[Leader Reassigns Tasks]
```

### Lifecycle Commands

| Command | Purpose |
|---------|---------|
| `lifecycle request-shutdown` | Request an agent to shut down |
| `lifecycle approve-shutdown` | Agent agrees to shut down |
| `lifecycle reject-shutdown` | Agent rejects shutdown request |
| `lifecycle idle` | Send idle notification to leader |

资料来源：[skills/clawteam/references/cli-reference.md]()

## Quick Start

### Installation

```bash
clawteam --version  # Check if installed
pip install clawteam  # Requires Python 3.10+
```

### Create and Manage a Team

```bash
# Set agent identity
export CLAWTEAM_AGENT_ID="leader-001"
export CLAWTEAM_AGENT_NAME="leader"
export CLAWTEAM_AGENT_TYPE="leader"

# Spawn a team with leader
clawteam team spawn-team my-team -d "Project team" -n leader

# Create tasks
clawteam task create my-team "Design system" -o leader
clawteam task create my-team "Implement feature" -o worker1
clawteam task create my-team "Write tests" -o worker2

# View team board
clawteam board show my-team
```

### Spawn Worker Agents

```bash
clawteam spawn tmux claude-code --team my-team --agent-name builder
clawteam spawn tmux claude-code --team my-team --agent-name reviewer
```

资料来源：[skills/clawteam/SKILL.md]()

## Board Dashboard

The board command provides team visibility through multiple views:

| Command | Description |
|---------|-------------|
| `board show` | Detailed kanban board with message history |
| `board overview` | Summary of all teams in table format |
| `board live` | Live-refreshing kanban board with auto-refresh |

```bash
# JSON output for integration
clawteam --json board show my-team

# Live monitoring
clawteam board live my-team --interval 2.0
```

资料来源：[skills/clawteam/references/cli-reference.md]()

## Identity System

Each agent requires environment variables for identification within the team:

```bash
eval $(clawteam identity set --agent-name alice --team dev-team)
```

The identity system exposes:
- `CLAWTEAM_AGENT_ID`: Unique identifier
- `CLAWTEAM_AGENT_NAME`: Human-readable name
- `CLAWTEAM_AGENT_TYPE`: Role classification (leader, general-purpose, etc.)

资料来源：[clawteam/harness/context_recovery.py:1-40]()

## Context Recovery

The harness system provides role-based context recovery for agents:

```python
# Layer 5: One-liner teammate summaries from context_recovery.py
def _teammate_summary(self, agent_name: str, team_name: str, role: str) -> str:
    from clawteam.team.tasks import TaskStore
    store = TaskStore(team_name)
    tasks = store.list_tasks()
    # Group by owner, exclude self
    owner_status: dict[str, tuple[int, int]] = {}
```

This enables leaders to understand team workload distribution and assign tasks appropriately.

资料来源：[clawteam/harness/context_recovery.py:40-70]()

## See Also

- [CLI Reference](skills/clawteam/references/cli-reference.md) - Complete command documentation
- [SKILL.md](skills/clawteam/SKILL.md) - Comprehensive usage guide

---

<a id='page-quickstart'></a>

## Quick Start Guide

### 相关页面

相关主题：[Introduction to ClawTeam](#page-introduction), [Agent Spawning System](#page-agent-spawning)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/HKUDS/ClawTeam/blob/main/README.md)
- [pyproject.toml](https://github.com/HKUDS/ClawTeam/blob/main/pyproject.toml)
- [skills/clawteam/SKILL.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/SKILL.md)
- [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)
- [clawteam/spawn/session_locators/claude.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/session_locators/claude.py)
- [clawteam/team/tasks.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)
</details>

# Quick Start Guide

ClawTeam is an agent swarm orchestration CLI that enables coordination of multiple coding agents (Claude Code, Codex, OpenClaw, nanobot, and any terminal-native client) from a single command-line interface. This guide walks you through installation, team creation, agent spawning, and basic coordination workflows.

## Prerequisites

Before getting started with ClawTeam, ensure your environment meets the following requirements:

| Requirement | Version/Details | Notes |
|-------------|-----------------|-------|
| Python | 3.10+ | Required runtime |
| tmux | Latest | Default spawn backend |
| Git | Any recent version | For worktree isolation and context features |
| Coding Agent CLI | Claude, Codex, Gemini, etc. | At least one agent client installed |

资料来源：[skills/clawteam/SKILL.md:20-30]()

## Installation

### Standard Installation

Install ClawTeam via pip:

```bash
pip install clawteam
```

### Installation with P2P Transport Support

For peer-to-peer transport capabilities:

```bash
pip install "clawteam[p2p]"
```

### Verify Installation

Confirm ClawTeam is installed correctly:

```bash
clawteam --version
```

资料来源：[skills/clawteam/SKILL.md:12-18]()

## Core Concepts

Understanding these fundamental concepts is essential before creating your first agent team.

### Teams

Teams are named groups of agents with one designated leader and zero or more worker agents. The leader coordinates task distribution and monitors team progress. 资料来源：[skills/clawteam/SKILL.md:32]()

### Tasks

Shared task board with status tracking:
- `pending` — Not yet started
- `in_progress` — Currently being worked on
- `completed` — Done; auto-unblocks dependent tasks
- `blocked` — Waiting on other tasks to complete

Tasks support dependency chains and priority levels (low, medium, high, urgent). 资料来源：[skills/clawteam/references/cli-reference.md:80-88]()

### Inbox

File-based message queue per agent. Messages can be destructive (`receive`) or non-destructive (`peek`). 资料来源：[skills/clawteam/SKILL.md:34]()

### Spawn Backends

ClawTeam supports multiple agent spawning backends:

| Backend | Description | Use Case |
|---------|-------------|----------|
| `subprocess` | Spawns agent as subprocess | Simple local execution |
| `tmux` | Spawns agent in tmux session | Persistent sessions with terminal access |
| `wsh` | Windows Subsystem for Host | Windows environment support |

资料来源：[clawteam/spawn/wsh_backend.py:1-50]()

## Step 1: Create a Team

### Spawn a New Team

Create a team with a leader agent:

```bash
clawteam team spawn-team <team-name> [options]
```

| Option | Description | Default |
|--------|-------------|---------|
| `--description, -d` | Team description | `""` |
| `--agent-name, -n` | Leader agent name | `"leader"` |
| `--agent-type` | Leader agent type | `"leader"` |

**Example:**

```bash
clawteam team spawn-team dev-sprint -d "Backend development team" -n alice
```

The team leader will automatically be registered in the system. 资料来源：[skills/clawteam/references/cli-reference.md:100-115]()

### Verify Team Creation

Check team status and members:

```bash
clawteam team status <team-name>
```

### List Existing Teams

Discover all teams in the network:

```bash
clawteam team discover
```

Or get JSON output for scripting:

```bash
clawteam --json team discover
```

Returns: name, description, leadAgentId, memberCount for each team. 资料来源：[skills/clawteam/references/cli-reference.md:116-120]()

## Step 2: Spawn Agents

### Spawn an Agent into a Team

Add a worker agent to your team:

```bash
clawteam spawn <backend> <command...> [options]
```

| Option | Description | Default |
|--------|-------------|---------|
| `--team, -t` | Team name | `"default"` |
| `--agent-name, -n` | Agent name | auto-generated |
| `--agent-type` | Agent type | `"general-purpose"` |

**Example:**

```bash
clawteam spawn tmux claude --team dev-sprint --agent-name builder --agent-type researcher
```

This spawns Claude Code in a tmux session named `builder` and registers it with the `dev-sprint` team. 资料来源：[skills/clawteam/references/cli-reference.md:35-45]()

### Agent Identity Setup

For spawned agents to operate within the team context, set identity environment variables:

```bash
eval $(clawteam identity set --agent-name alice --team dev-team)
```

View current agent identity:

```bash
clawteam identity show
```

资料来源：[skills/clawteam/references/cli-reference.md:46-55]()

## Step 3: Manage Tasks

### Create a Task

```bash
clawteam task create <team> <subject> [options]
```

| Option | Description | Default |
|--------|-------------|---------|
| `--owner, -o` | Task owner | None |
| `--description, -d` | Task description | None |
| `--priority, -p` | Priority: low, medium, high, urgent | medium |
| `--blocks` | Comma-separated task IDs this blocks | None |
| `--blocked-by` | Comma-separated task IDs blocking this | None |

**Example:**

```bash
clawteam task create dev-team "Implement auth" -o alice -d "Add JWT authentication"
```

### Update Task Status

```bash
clawteam task update <team> <task-id> [options]
```

| Option | Description |
|--------|-------------|
| `--status, -s` | New status: pending, in_progress, completed, blocked |
| `--owner, -o` | New owner |
| `--add-blocks` | Task IDs to add to blocks |
| `--add-blocked-by` | Task IDs to add to blocked-by |

When a task is marked `completed`, any tasks blocked by it are automatically unblocked (moved from `blocked` to `pending` if no other blockers remain). 资料来源：[skills/clawteam/references/cli-reference.md:60-80]()

### List Team Tasks

```bash
clawteam task list <team> [--status STATUS] [--owner NAME] [--priority LEVEL] [--sort-priority]
```

## Team Workflow Example

```mermaid
graph TD
    A[Install ClawTeam] --> B[Spawn Team with Leader]
    B --> C[Leader Creates Initial Tasks]
    C --> D[Spawn Worker Agents]
    D --> E[Workers Pick Tasks]
    E --> F[Complete Task]
    F --> G{Tasks Blocked?}
    G -->|Yes| H[Wait for Blockers]
    G -->|No| I[Mark Complete]
    H --> I
    I --> J{More Tasks?}
    J -->|Yes| E
    J -->|No| K[Idle Notification]
```

### Terminal Workflow Demo

The following demonstrates the typical CLI workflow:

```bash
$ clawteam team spawn-team docs-sprint
✓ Team "docs-sprint" created

$ clawteam spawn tmux claude-code --agent-name builder
✓ Agent "builder" spawned in tmux

$ clawteam team status docs-sprint
docs-sprint  3 agents active
● T-001 Build landing page  done
● T-002 Write API docs  active
○ T-003 Review & merge  blocked
```

资料来源：[website/src/App.jsx:1-60]()

## Lifecycle Management

### Request Agent Shutdown

```bash
clawteam lifecycle request-shutdown <team> <from-agent> <to-agent> [--reason TEXT]
```

### Approve/Reject Shutdown

```bash
clawteam lifecycle approve-shutdown <team> <request-id> <agent>
clawteam lifecycle reject-shutdown <team> <request-id> <agent> [--reason TEXT]
```

### Send Idle Notification

When an agent has no more work:

```bash
clawteam lifecycle idle <team> [--last-task ID] [--task-status STATUS]
```

This notifies the team leader that the agent is available for new tasks. 资料来源：[skills/clawteam/references/cli-reference.md:130-150]()

## Communication Between Agents

### Message Types

| Type | Description |
|------|-------------|
| `message` | General point-to-point message |
| `broadcast` | Broadcast to all team members |
| `join_request` | Request to join team |
| `join_approved` / `join_rejected` | Join response |

### Send a Message

```bash
clawteam message send <team> <to-agent> <content>
```

### Join a Team

Request to join an existing team:

```bash
clawteam team request-join <team> <proposed-name> [options]
```

| Option | Description | Default |
|--------|-------------|---------|
| `--capabilities, -c` | Agent capabilities description | `""` |
| `--timeout, -t` | Timeout in seconds | 60 |

The leader can approve or reject the request:

```bash
clawteam team approve-join <team> <request-id> [--assigned-name NAME]
clawteam team reject-join <team> <request-id>
```

资料来源：[skills/clawteam/references/cli-reference.md:25-30]()

## Plan Submission and Approval

### Submit a Plan

```bash
clawteam plan submit <team> <agent> <plan-content-or-file> [--summary TEXT]
```

### Approve/Reject a Plan

```bash
clawteam plan approve <team> <plan-id> <agent> [--feedback TEXT]
clawteam plan reject <team> <plan-id> <agent> [--feedback TEXT]
```

资料来源：[skills/clawteam/references/cli-reference.md:95-108]()

## Session Persistence

ClawTeam handles session persistence for agents like Claude Code. When spawning an agent:

1. If `--continue` or `-c` flag is used, the agent continues from its last session
2. Otherwise, a new session ID is generated automatically
3. Session state is captured and stored for future restoration

```python
# Session capture flow
if prepared.session_id:
    return CapturedSession(
        session_id=prepared.session_id,
        client=self.client,
        source=prepared.source or "prepared",
        confidence=prepared.confidence or "exact",
        cwd=context.cwd,
    )
return self.current_session(context)
```

资料来源：[clawteam/spawn/session_locators/claude.py:30-45]()

## Data Storage

All team data is stored in `~/.clawteam/` by default:

| Data Type | Storage Location |
|-----------|------------------|
| Teams | `~/.clawteam/teams/` |
| Tasks | `~/.clawteam/teams/<team>/tasks/` |
| Messages | `~/.clawteam/teams/<team>/inbox/<agent>/` |
| Sessions | `~/.clawteam/sessions/` |

Task operations are backed by `FileTaskStore`:

```python
from clawteam.store.base import BaseTaskStore, TaskLockError
from clawteam.store.file import FileTaskStore

TaskStore = FileTaskStore
```

资料来源：[clawteam/team/tasks.py:1-20]()

## Next Steps

- Review the [CLI Reference](skills/clawteam/references/cli-reference.md) for complete command documentation
- Explore [Git-aware execution](skills/clawteam/SKILL.md) features for repository integration
- Configure [runtime profiles](skills/clawteam/SKILL.md) for different agent environments

---

<a id='page-architecture'></a>

## System Architecture

### 相关页面

相关主题：[Introduction to ClawTeam](#page-introduction), [Transport Layer](#page-transport), [Event System](#page-event-system)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [clawteam/team/tasks.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)
- [clawteam/spawn/wsh_backend.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/wsh_backend.py)
- [clawteam/harness/context_recovery.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/context_recovery.py)
- [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)
- [skills/clawteam/SKILL.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/SKILL.md)
- [website/src/App.jsx](https://github.com/HKUDS/ClawTeam/blob/main/website/src/App.jsx)
</details>

# System Architecture

## Overview

ClawTeam is an agent swarm orchestration CLI that coordinates multiple coding agents (Claude Code, Codex, OpenClaw, nanobot, and any terminal-native client) from a single command-line interface. The system provides shared task graphs, persistent coordination, and git-aware execution across distributed agent workers.

The architecture follows a modular design with clear separation between spawning backends, team management, task storage, event handling, and transport layers. All data persists in `~/.clawteam/` by default, with support for P2P transport when agents operate on different machines.

资料来源：[skills/clawteam/SKILL.md:1-15]()

## High-Level Component Architecture

```mermaid
graph TD
    subgraph "CLI Layer"
        CLI[clawteam CLI]
    end
    
    subgraph "Core Services"
        TM[Team Manager]
        TS[Task Store]
        EB[Event Bus]
        TR[Transport Layer]
    end
    
    subgraph "Spawn Backends"
        TMUX[Tmux Backend]
        WSH[Wsh Backend]
        SUB[Subprocess Backend]
    end
    
    subgraph "Agent Runtime"
        AG1[Agent 1]
        AG2[Agent 2]
        AGn[Agent N]
    end
    
    subgraph "Data Storage"
        ST[Store - FileSystem]
        IN[Inbox - per-agent]
        TK[Tasks JSON]
        PL[Plan Files]
    end
    
    CLI --> TM
    CLI --> TS
    CLI --> EB
    CLI --> TR
    TM --> TS
    TM --> EB
    EB --> TR
    TR --> AG1
    TR --> AG2
    AG1 --> ST
    AG2 --> ST
    ST --> IN
    ST --> TK
    ST --> PL
```

## Core Modules

### Task Store Layer

The task storage system provides a persistent, file-based task management interface. The `TaskStore` class serves as the primary abstraction, with implementations supporting different storage backends.

```mermaid
classDiagram
    class BaseTaskStore {
        <<abstract>>
        +create_task(task) Task
        +get_task(task_id) Task
        +update_task(task_id, updates) Task
        +list_tasks() List~Task~
        +delete_task(task_id)
        +acquire_lock(task_id) ContextManager
        +release_lock(task_id)
    }
    
    class FileTaskStore {
        +_base_path: Path
        +create_task(task) Task
        +get_task(task_id) Task
        +update_task(task_id, updates) Task
        +list_tasks() List~Task~
    }
    
    class TaskLockError {
        +Exception
    }
    
    BaseTaskStore <|-- FileTaskStore
    BaseTaskStore -- TaskLockError
```

**Task Data Model**

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique task identifier |
| `subject` | string | Task title/summary |
| `description` | string | Detailed task description |
| `status` | enum | `pending`, `in_progress`, `completed`, `blocked` |
| `owner` | string | Agent responsible for task |
| `priority` | enum | `low`, `medium`, `high`, `urgent` |
| `blocks` | list[string] | Task IDs this blocks |
| `blocked_by` | list[string] | Task IDs blocking this |

资料来源：[clawteam/team/tasks.py:1-15]()

**Task Status Transitions**

| Current Status | Valid Transitions | Auto-Behavior |
|----------------|-------------------|---------------|
| `pending` | `in_progress`, `blocked` | - |
| `in_progress` | `completed`, `blocked` | - |
| `completed` | - | Unblocks all dependent tasks |
| `blocked` | `pending`, `in_progress` | Auto-unblock when blockers complete |

资料来源：[skills/clawteam/references/cli-reference.md:85-100]()

### Event Bus

The event system enables inter-agent communication through a pub-sub pattern. Events flow through the transport layer to reach individual agent inboxes.

```mermaid
graph LR
    A[Agent A] -->|publish| EB[Event Bus]
    EB -->|deliver| IN1[Inbox A]
    EB -->|deliver| IN2[Inbox B]
    EB -->|deliver| INn[Inbox N]
    
    subgraph "Message Types"
        MSG[message]
        BC[broadcast]
        JR[join_request]
        PA[plan_approval_request]
        SR[shutdown_request]
        IDL[idle]
    end
    
    EB -.->|routes| MSG
    EB -.->|routes| BC
    EB -.->|routes| JR
    EB -.->|routes| PA
    EB -.->|routes| SR
    EB -.->|routes| IDL
```

**Supported Message Types**

| Type | Direction | Purpose |
|------|-----------|---------|
| `message` | point-to-point | General communication between agents |
| `broadcast` | one-to-all | Announcements to entire team |
| `join_request` | worker→leader | Request to join team |
| `join_approved` / `join_rejected` | leader→worker | Join response |
| `plan_approval_request` | worker→leader | Submit plan for review |
| `plan_approved` / `plan_rejected` | leader→worker | Plan response |
| `shutdown_request` | any→any | Request agent shutdown |
| `shutdown_approved` / `shutdown_rejected` | any→any | Shutdown response |
| `idle` | worker→leader | Agent has no more work |

资料来源：[skills/clawteam/references/cli-reference.md:110-125]()

### Spawn Backend System

The spawn system launches agent processes using configurable backends. Each backend implements a common interface for process management and runtime injection.

**Backend Architecture**

```mermaid
graph TD
    subgraph "Spawn Factory"
        SF[Backend Factory]
    end
    
    SF --> TMUX[Tmux Backend]
    SF --> WSH[Wsh Backend]
    SF --> SUB[Subprocess Backend]
    
    subgraph "Agent Lifecycle"
        LAUNCH[Launch]
        MONITOR[Monitor]
        INJECT[Inject Runtime]
        TERMINATE[Terminate]
    end
    
    TMUX --> LAUNCH
    WSH --> LAUNCH
    SUB --> LAUNCH
    TMUX --> MONITOR
    WSH --> MONITOR
    SUB --> MONITOR
    WSH --> INJECT
    TMUX --> INJECT
    SUB --> INJECT
```

**Spawn Command Parameters**

| Option | Description | Default |
|--------|-------------|---------|
| `--team, -t` | Team name | `"default"` |
| `--agent-name, -n` | Agent name | auto-generated |
| `--agent-type` | Agent type | `"general-purpose"` |

**Example Usage**

```bash
clawteam spawn tmux claude --team dev-team --agent-name builder --agent-type researcher
```

资料来源：[skills/clawteam/references/cli-reference.md:25-45]()

### Wsh Backend Implementation

The WebSocket-based spawn backend (`wsh_backend.py`) provides runtime message injection into running agent sessions.

```python
def inject_runtime_message(self, team: str, agent_name: str, envelope) -> tuple[bool, str]:
    """Best-effort runtime injection into a running wsh block."""
    from clawteam.spawn.registry import get_registry

    info = get_registry(team).get(agent_name, {})
    block_id = info.get("block_id", "") or self._blocks.get(agent_name, "")
    if not block_id:
        return False, f"wsh block for '{team}/{agent_name}' not found"
    if not _is_block_alive(block_id):
        return False, f"wsh block '{block_id}' is not alive"
    # ... RPC client payload delivery
```

**Agent Registration Flow**

1. Agent spawns with `team_name`, `agent_name`, `backend` type
2. Backend calls `register_agent()` with metadata
3. Spawn data persisted via `persist_spawned_session()`
4. Agent entry stored in registry for runtime lookups

资料来源：[clawteam/spawn/wsh_backend.py:1-55]()

## Data Storage Layout

All persistent data resides under `~/.clawteam/` with a structured directory hierarchy:

```
~/.clawteam/
├── teams/{team}/
│   ├── config.json          # TeamConfig (name, members, leader)
│   └── inboxes/{agent}/     # msg-{timestamp}-{uuid}.json files
├── tasks/{team}/
│   └── task-{id}.json       # Individual task files
└── plans/
    └── {agent}-{id}.md      # Plan documents
```

**Inbox Operations**

| Operation | Behavior |
|-----------|----------|
| `receive` | Destructive read - message removed after retrieval |
| `peek` | Non-destructive read - message remains in inbox |

## Team Structure

```mermaid
graph TD
    subgraph "Team: dev-team"
        L[Leader Agent]
        W1[Worker: alice]
        W2[Worker: bob]
        W3[Worker: charlie]
        
        L -->|manages| W1
        L -->|manages| W2
        L -->|manages| W3
        
        subgraph "Shared Resources"
            TB[Task Board]
            CH[Inbox Channel]
            CT[Context]
        end
        
        W1 --> TB
        W2 --> TB
        W3 --> TB
        W1 --> CH
        W2 --> CH
        W3 --> CH
    end
```

**Team Commands**

| Command | Description |
|---------|-------------|
| `clawteam team spawn-team` | Create team and register leader |
| `clawteam team discover` | List all existing teams |
| `clawteam team status` | Show team configuration and members |
| `clawteam team request-join` | Request to join a team |
| `clawteam team approve-join` | Approve join request (leader only) |

资料来源：[skills/clawteam/references/cli-reference.md:130-160]()

## Context and Recovery System

The context recovery module provides role-specific context injection for agents operating within the harness system.

**Role-Based Context Layers**

| Role | Context Provided |
|------|------------------|
| `worker` | Sprint contract artifacts assigned to agent |
| `evaluator` | Specification + all contract criteria |
| `planner` | Spec draft for planning |

```python
def _teammate_summary(self, agent_name: str, team_name: str, role: str) -> str:
    """Layer 5: One-liner teammate summaries."""
    try:
        from clawteam.team.tasks import TaskStore
        store = TaskStore(team_name)
        tasks = store.list_tasks()

        # Group by owner, exclude self
        owner_status: dict[str, tuple[int, int]] = {}
        for t in tasks:
            if t.owner and t.owner != agent_name:
                done, total = owner_status.get(t.owner, (0, 0))
                total += 1
                if t.status == TaskStatus.COMPLETED:
                    done += 1
                owner_status[t.owner] = (done, total)
    except Exception:
        pass
```

资料来源：[clawteam/harness/context_recovery.py:1-75]()

## Frontend Architecture

The website provides a browser-based dashboard for visualizing team state.

```mermaid
graph LR
    subgraph "React Components"
        App[App.jsx]
        TM[TerminalMockup]
        HG[HalfGlobe]
    end
    
    subgraph "UI Sections"
        H[Hero]
        F[Features]
        W[Workflow]
        D[Docs]
    end
    
    subgraph "Data Display"
        TL[Terminal Output]
        KB[Kanban Board]
        ST[Status Grid]
    end
    
    App --> TM
    App --> HG
    TM --> TL
    H --> KB
    F --> ST
    W --> D
```

**Terminal Mockup Features**

- Real-time team status display
- Agent spawn simulation
- Task progress visualization with status badges
- Animated cursor for active states

资料来源：[website/src/App.jsx:1-100]()

## Communication Flow

```mermaid
sequenceDiagram
    participant L as Leader
    participant W1 as Worker Alice
    participant W2 as Worker Bob
    participant T as TaskStore
    participant I as Inbox
    
    W1->>L: request-join(team, "alice")
    L->>T: create_task()
    L->>W1: join_approved
    W1->>T: update_task(status=in_progress)
    W1->>L: plan_approval_request
    L->>W1: plan_approved
    W1->>T: update_task(status=completed)
    T->>W2: unblock(task_id)
    W2->>L: idle(last_task=T-001)
```

## Key Dependencies

| Component | Dependencies | Purpose |
|-----------|-------------|---------|
| Task Store | `clawteam/store/base.py` | Abstract store interface |
| Spawn Backends | `tmux`, `wsh` | Process management |
| Event Bus | File system / P2P | Inter-agent messaging |
| CLI | Click/Typer | Command parsing |
| Context | Git worktrees | Repository awareness |

资料来源：[skills/clawteam/SKILL.md:1-40]()

## Summary

ClawTeam's architecture centers on three pillars:

1. **Team Coordination** - Leader-based hierarchy with worker registration and task distribution
2. **Persistent Storage** - File-based task boards, inboxes, and plans under `~/.clawteam/`
3. **Flexible Spawning** - Pluggable backends (tmux, subprocess, wsh) for agent lifecycle management

The system is designed for git-aware, multi-agent development workflows where agents share task context, communicate via typed messages, and maintain independent worktree isolation.

---

<a id='page-event-system'></a>

## Event System

### 相关页面

相关主题：[System Architecture](#page-architecture), [Team Management](#page-team-management)

<details>
<summary>Relevant Source Files</summary>

The following source files are listed as relevant for generating this page, but **were not present in the retrieved repository context**:

- [clawteam/events/__init__.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/events/__init__.py)
- [clawteam/events/bus.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/events/bus.py)
- [clawteam/events/global_bus.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/events/global_bus.py)
- [clawteam/events/types.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/events/types.py)
- [clawteam/events/hooks.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/events/hooks.py)

The following files from the provided context were used to derive event-related information:

- [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)
- [clawteam/spawn/wsh_backend.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/wsh_backend.py)
- [clawteam/harness/context_recovery.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/context_recovery.py)

</details>

# Event System

> ⚠️ **Documentation Notice**: This page documents the Event System based on available repository context. The core event system source files (`clawteam/events/*.py`) were not available in the retrieved context. This page derives event system behavior from CLI reference documentation and related modules.

## Overview

The Event System in ClawTeam provides the inter-agent communication backbone that enables coordination between multiple autonomous agents in a team. Rather than exposing a standalone event bus API, ClawTeam integrates event-driven communication through its messaging infrastructure, task lifecycle hooks, and board system.

资料来源：[skills/clawteam/references/cli-reference.md]()

## Message Types

The system defines several message/event types that flow between team members. These types represent the different categories of communication that agents use to coordinate.

| Message Type | Description |
|--------------|-------------|
| `message` | General point-to-point message between agents |
| `broadcast` | Broadcast message to all team members |
| `join_request` | Request sent by an agent wanting to join the team |
| `join_approved` / `join_rejected` | Response from team leader regarding join request |
| `plan_approval_request` | Plan submitted by agent for leader review |
| `plan_approved` / `plan_rejected` | Leader's decision on a submitted plan |
| `shutdown_request` | Request to terminate an agent |
| `shutdown_approved` / `shutdown_rejected` | Response to shutdown request |
| `idle` | Notification sent when an agent has no more work |

资料来源：[skills/clawteam/references/cli-reference.md]()

## Task Status Events

Task state transitions trigger automatic event behavior. When a task status changes, the system automatically propagates effects to dependent tasks.

| Status | Description |
|--------|-------------|
| `pending` | Task not yet started |
| `in_progress` | Task currently being worked on |
| `completed` | Task done — auto-unblocks dependent tasks |
| `blocked` | Task waiting on other tasks to complete |

When a task is marked `completed`, any tasks blocked by it are automatically unblocked (moved from `blocked` to `pending` if no other blockers remain).

资料来源：[skills/clawteam/references/cli-reference.md]()

## Inter-Agent Communication Flow

```mermaid
graph TD
    A[Agent] -->|message| B[Team Inbox]
    A -->|broadcast| C[All Members]
    A -->|join_request| D[Leader]
    D -->|join_approved| A
    A -->|plan_approval_request| D
    D -->|plan_approved<br>plan_rejected| A
    A -->|shutdown_request| E[Target Agent]
    E -->|shutdown_approved<br>shutdown_rejected| A
    A -->|idle| D
```

## Board and Inbox Architecture

The board system serves as the persistent event store, maintaining message history and team state.

```
~/.clawteam/
├── teams/{team}/
│   ├── config.json          # TeamConfig (name, members, leader)
│   └── inboxes/{agent}/     # msg-{timestamp}-{uuid}.json files
├── tasks/{team}/
│   └── task-{id}.json       # Individual task files
└── plans/
    └── {agent}-{id}.md      # Plan documents
```

资料来源：[skills/clawteam/references/cli-reference.md]()

### Board Show Command

The `board show` command displays team board data with member-aware message aliases:

```bash
clawteam board show <team>
clawteam --json board show <team>
```

Recent board payloads include:
- `memberKey` — identifies team member
- `inboxName` — target inbox identifier
- `fromLabel` / `toLabel` — message source and destination

These fields are used by the browser board to filter inbox history.

资料来源：[skills/clawteam/references/cli-reference.md]()

## Lifecycle Event Commands

The CLI provides commands for managing agent lifecycle events:

### Idle Notification

Send when an agent has no more work:

```bash
clawteam lifecycle idle <team> [--last-task ID] [--task-status STATUS]
```

### Shutdown Sequence

```bash
# Request shutdown
clawteam lifecycle request-shutdown <team> <from-agent> <to-agent> [--reason TEXT]

# Accept shutdown
clawteam lifecycle approve-shutdown <team> <request-id> <agent>

# Reject shutdown
clawteam lifecycle reject-shutdown <team> <request-id> <agent> [--reason TEXT]
```

资料来源：[skills/clawteam/references/cli-reference.md]()

## Plan Submission Events

Agents submit plans for leader approval, creating an approval workflow:

```mermaid
sequenceDiagram
    Agent->>Leader: plan submit <team> <agent> <plan-content>
    Note over Leader: Reviews plan
    Leader->>Agent: plan approve <team> <plan-id> <agent>
    Note over Agent: Plan approved, proceed with work
```

### Plan Commands

```bash
# Submit a plan
clawteam plan submit <team> <agent> <plan-content-or-file> [--summary TEXT]

# Approve a plan
clawteam plan approve <team> <plan-id> <agent> [--feedback TEXT]

# Reject a plan
clawteam plan reject <team> <plan-id> <agent> [--feedback TEXT]
```

资料来源：[skills/clawteam/references/cli-reference.md]()

## Context Recovery Hooks

The harness system integrates with the event system through context recovery hooks that provide role-aware information to agents:

```python
def _teammate_summary(self, agent_name: str, team_name: str, role: str) -> str:
    """Layer 5: One-liner teammate summaries."""
    from clawteam.team.models import TaskStatus
    from clawteam.team.tasks import TaskStore
    store = TaskStore(team_name)
    tasks = store.list_tasks()
```

资料来源：[clawteam/harness/context_recovery.py:53-59]()

Different roles receive different context:

| Role | Context Provided |
|------|------------------|
| `executor` | Sprint contract artifact containing their assignment |
| `evaluator` | Full spec.md content and all contract criteria |
| `planner` | Spec draft content for planning purposes |

资料来源：[clawteam/harness/context_recovery.py:31-47]()

## Spawn Backend Event Integration

The wsh backend demonstrates how spawned agents integrate with the event system for runtime message injection:

```python
def inject_runtime_message(self, team: str, agent_name: str, envelope) -> tuple[bool, str]:
    """Best-effort runtime injection into a running wsh block."""
    from clawteam.spawn.registry import get_registry

    info = get_registry(team).get(agent_name, {})
    block_id = info.get("block_id", "") or self._blocks.get(agent_name, "")
    if not block_id:
        return False, f"wsh block for '{team}/{agent_name}' not found"
```

The spawn registry tracks agent metadata (`team_name`, `agent_name`, `backend`, `block_id`, `pid`, `command`) enabling the event system to route messages to correct agent processes.

资料来源：[clawteam/spawn/wsh_backend.py:52-61]()

## See Also

- [CLI Reference](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md) — Complete command documentation
- [Task System](../team/tasks) — Task management and dependencies
- [Spawn System](../spawn/index) — Agent spawning and backend management

---

<a id='page-agent-spawning'></a>

## Agent Spawning System

### 相关页面

相关主题：[Quick Start Guide](#page-quickstart), [Team Management](#page-team-management)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [clawteam/spawn/__init__.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/__init__.py)
- [clawteam/spawn/base.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/base.py)
- [clawteam/spawn/adapters.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/adapters.py)
- [clawteam/spawn/tmux_backend.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/tmux_backend.py)
- [clawteam/spawn/subprocess_backend.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/subprocess_backend.py)
- [clawteam/spawn/profiles.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/profiles.py)
- [clawteam/spawn/presets.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/presets.py)
- [clawteam/spawn/prompt.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/prompt.py)
- [clawteam/spawn/sessions.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/sessions.py)
- [clawteam/spawn/session_locators/base.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/session_locators/base.py)
</details>

# Agent Spawning System

The Agent Spawning System is the core infrastructure in ClawTeam responsible for launching, managing, and coordinating multiple AI agent processes. It provides a unified interface to spawn various CLI-based agents (such as Claude Code, Codex, Gemini, nanobot, and OpenClaw) within a team context, handling environment setup, session persistence, and lifecycle management.

## Architecture Overview

The spawning system follows a pluggable backend architecture that abstracts the underlying execution environment. This design allows ClawTeam to support multiple execution backends while presenting a consistent API to the rest of the system.

```mermaid
graph TD
    A[CLI Command: clawteam spawn] --> B[SpawnCommand Handler]
    B --> C[Backend Factory]
    C --> D[subprocess Backend]
    C --> E[tmux Backend]
    C --> F[wsh Backend]
    D --> G[Agent Process]
    E --> H[tmux Session]
    F --> I[wsh Block]
    G --> J[Session Store]
    H --> J
    I --> J
    J --> K[Registry]
    K --> L[Team Coordination]
```

## Core Components

### Spawn Backends

The system supports three execution backends, each providing different isolation and management capabilities:

| Backend | Description | Use Case |
|---------|-------------|----------|
| `subprocess` | Direct child process management | Simple single-agent scenarios |
| `tmux` | Terminal multiplexer sessions | Persistent sessions with attach capability |
| `wsh` | weish block isolation | Isolated workspace blocks |

#### Base Backend Interface

All backends implement a common interface defined in `base.py`:

```python
class SpawnBackend(ABC):
    @abstractmethod
    def spawn(
        self,
        command: list[str],
        team_name: str,
        agent_name: str,
        agent_type: str,
        cwd: str | None = None,
        env: dict[str, str] | None = None,
        **kwargs
    ) -> str:
        """Spawn an agent process and return result message."""
        pass
    
    @abstractmethod
    def list_running(self) -> list[dict[str, str]]:
        """List currently running agents."""
        pass
    
    @abstractmethod
    def inject_runtime_message(self, team: str, agent_name: str, envelope) -> tuple[bool, str]:
        """Inject a runtime notification into a running agent."""
        pass
```

资料来源：[clawteam/spawn/base.py:1-50]()

### Agent Registry

When an agent is spawned, it is registered in a centralized registry that tracks all active agents per team:

```python
from clawteam.spawn.registry import register_agent

register_agent(
    team_name=team_name,
    agent_name=agent_name,
    backend="tmux",
    block_id=session_name,
    pid=process.pid,
    command=list(final_command),
)
```

资料来源：[clawteam/spawn/tmux_backend.py](), [clawteam/spawn/wsh_backend.py:1-50]()

The registry maintains the following information per agent:
- `team_name`: The team the agent belongs to
- `agent_name`: Unique identifier within the team
- `backend`: Backend type (subprocess/tmux/wsh)
- `block_id` / `session_name`: Backend-specific identifier
- `pid`: Process ID (for subprocess backend)
- `command`: Original spawn command

## Spawn Command Interface

### CLI Syntax

```bash
clawteam spawn <backend> <command...> [options]
```

### Command Options

| Option | Description | Default |
|--------|-------------|---------|
| `--team, -t` | Team name | `"default"` |
| `--agent-name, -n` | Agent name | auto-generated |
| `--agent-type` | Agent type | `"general-purpose"` |

### Example Usage

```bash
# Spawn Claude Code agent in tmux
clawteam spawn tmux claude --team dev-team --agent-name builder --agent-type researcher

# Spawn in subprocess backend
clawteam spawn subprocess claude-code --team analysis --agent-name analyzer
```

资料来源：[skills/clawteam/references/cli-reference.md](), [clawteam/cli/commands.py]()

## Agent Identity System

When spawning an agent, the system automatically configures environment variables that establish the agent's identity within the team:

```bash
export CLAWTEAM_AGENT_ID="<auto-generated-uuid>"
export CLAWTEAM_AGENT_NAME="<agent-name>"
export CLAWTEAM_AGENT_TYPE="<agent-type>"
export CLAWTEAM_TEAM_NAME="<team-name>"
```

Agents can verify their identity using:

```bash
clawteam identity show
```

资料来源：[clawteam/cli/commands.py](), [skills/clawteam/references/cli-reference.md]()

## Session Management

### Session Persistence

The system tracks agent sessions to enable resume functionality:

```python
from clawteam.spawn.sessions import SessionStore

session_store = SessionStore(team_name)
session = session_store.load(agent_name)

if session and session.session_id:
    resumed_command = build_cli_resume_command(command, session.session_id, client=client)
```

资料来源：[clawteam/spawn/sessions.py](), [clawteam/spawn/session_capture.py]()

### Session Lifecycle

```mermaid
graph LR
    A[Spawn] --> B[Create Session]
    B --> C[Store in SessionStore]
    C --> D[Execute Agent]
    D --> E[Agent Completes]
    E --> F[Session Archived]
    F --> G[Resume Available]
    G --> H[Resume Command]
    H --> D
```

### Session Locators

Session locators find existing sessions across different backends:

```python
from clawteam.spawn.session_locators.base import SessionLocator

class SessionLocator(ABC):
    @abstractmethod
    def find_session(self, team: str, agent: str) -> SessionInfo | None:
        """Locate an existing session for the given team/agent."""
        pass
```

资料来源：[clawteam/spawn/session_locators/base.py]()

## Profile and Preset System

### Profiles

Profiles are reusable configurations that define how agents should be spawned:

```bash
# List available profiles
clawteam profile list

# Test a profile
clawteam profile test claude-kimi

# Generate profile from preset
clawteam preset generate-profile moonshot-cn claude --name claude-kimi
```

资料来源：[clawteam/spawn/profiles.py](), [skills/clawteam/SKILL.md]()

### Presets

Presets are provider templates used to generate profiles:

| Preset | Provider |
|--------|----------|
| `moonshot-cn` | Moonshot CN |
| `claude` | Anthropic Claude |
| `openai` | OpenAI |
| Custom | User-defined |

```bash
# List presets
clawteam preset list

# Show preset details
clawteam preset show moonshot-cn
```

资料来源：[clawteam/spawn/presets.py](), [skills/clawteam/references/workflows.md]()

## Prompt Generation

When spawning an agent, ClawTeam generates a comprehensive system prompt that includes identity information, task details, and coordination instructions:

```python
from clawteam.spawn.prompt import build_agent_prompt

prompt = build_agent_prompt(
    agent_name=agent_name,
    agent_id=agent_id,
    agent_type=agent_type,
    team_name=team_name,
    leader_name=leader_name,
    task=task,
    user=user_name,
    workspace_dir=cwd,
    workspace_branch=ws_branch,
    isolated_workspace=bool(workspace and cwd),
    repo_path=repo,
)
```

资料来源：[clawteam/spawn/prompt.py](), [clawteam/cli/commands.py]()

### Prompt Components

The generated prompt includes:
1. **Identity block**: Agent name, ID, type, and team
2. **Task description**: Assigned work from the team leader
3. **Coordination guide**: How to use ClawTeam CLI for task updates
4. **Workspace context**: Directory, branch, git state

## Skill Loading

Agents can be spawned with predefined skills loaded from `~/.claude/skills/`:

```python
def _load_skill_content(name: str) -> str | None:
    """Load skill content from ~/.claude/skills."""
    skills_root = Path.home() / ".claude" / "skills"
    skill_dir = skills_root / name
    
    # Support both directory and single-file formats
    if skill_dir.is_dir():
        skill_file = skill_dir / "SKILL.md"
        # Fallback to first .md file
    else:
        single_file = skills_root / f"{name}.md"
```

资料来源：[clawteam/cli/commands.py]()

### Supported Skill Formats

- Directory format: `skills/<name>/SKILL.md`
- Single file format: `skills/<name>.md`

## Runtime Message Injection

The system supports injecting runtime notifications into running agents:

```python
def inject_runtime_message(self, team: str, agent_name: str, envelope) -> tuple[bool, str]:
    """Best-effort runtime injection into a running agent."""
    from clawteam.spawn.registry import get_registry
    
    info = get_registry(team).get(agent_name, {})
    block_id = info.get("block_id", "")
    
    if not block_id:
        return False, f"Agent '{team}/{agent_name}' not found"
    
    # Render and send notification
    payload = render_runtime_notification(envelope)
```

资料来源：[clawteam/spawn/wsh_backend.py](), [clawteam/spawn/base.py]()

## Team Template Launch

For complex multi-agent scenarios, ClawTeam supports launching entire teams from templates:

```bash
clawteam launch <template> <backend> [options]
```

### Launch Options

| Option | Description | Default |
|--------|-------------|---------|
| `--team, -t` | Team name | From template |
| `--user, -u` | User name | Current user |
| `--workspace` | Workspace directory | Current directory |
| `--repo` | Repository path | None |
| `--isolated` | Isolated workspaces | False |

### Template Structure

```python
team_template = {
    "name": "dev-team",
    "leader": {"name": "leader", "type": "leader"},
    "members": [
        {"name": "researcher", "type": "researcher"},
        {"name": "coder", "type": "general-purpose"},
    ]
}
```

资料来源：[clawteam/cli/commands.py](), [skills/clawteam/SKILL.md]()

## Backend-Specific Details

### TMUX Backend

The tmux backend creates named sessions for each agent:

```bash
tmux new-session -d -s clawteam-{team}-{agent} "{command}"
tmux attach -t clawteam-{team}-{agent}
```

Sessions are named using pattern: `clawteam-{team_name}-{agent_name}`

资料来源：[clawteam/spawn/tmux_backend.py]()

### Subprocess Backend

The subprocess backend provides direct process management:

```python
process = subprocess.Popen(
    command,
    env=full_env,
    cwd=cwd,
    stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT,
)
```

资料来源：[clawteam/spawn/subprocess_backend.py]()

### WSH Backend

The weish backend provides block-based isolation:

```python
pane_id = spawn_wsh_block(
    target=target,
    command=final_command,
    title=agent_name,
)
```

资料来源：[clawteam/spawn/wsh_backend.py]()

## Configuration Files

### Profile Configuration

Profiles are stored in JSON format:

```json
{
  "name": "claude-kimi",
  "provider": "moonshot-cn",
  "api_key_env": "MOONSHOT_API_KEY",
  "model": "claude-3-5-sonnet",
  "spawn_options": {
    "backend": "tmux",
    "agent_type": "general-purpose"
  }
}
```

### Preset Configuration

Presets define provider templates:

```json
{
  "name": "moonshot-cn",
  "provider": "openai-compatible",
  "base_url": "https://api.moonshot.cn/v1",
  "models": ["claude-3-5-sonnet", "claude-3-sonnet"]
}
```

资料来源：[clawteam/spawn/profiles.py](), [clawteam/spawn/presets.py]()

## Error Handling

### Common Errors and Solutions

| Error | Cause | Solution |
|-------|-------|----------|
| `Backend not found` | Invalid backend name | Use `tmux`, `subprocess`, or `wsh` |
| `Team not found` | Team doesn't exist | Create team with `clawteam team spawn-team` |
| `Agent name conflict` | Agent already exists | Use unique name or `--force` flag |
| `Permission denied` | tmux/socket access | Check user permissions |

### Spawn Hint System

The CLI provides contextual hints when arguments are misordered:

```python
def _spawn_hint(backend: str | None, team: str | None) -> str:
    """Provide helpful hint when spawn positional args are misordered."""
    if not backend or team:
        return ""
    return (
        " Hint: the first positional argument to `clawteam spawn` is the backend "
        "(`tmux` or `subprocess`), not the team name. Use `--team <name>` to set "
        "the team explicitly."
    )
```

资料来源：[clawteam/cli/commands.py]()

## Workflow Diagram

```mermaid
sequenceDiagram
    participant User
    participant CLI
    participant Backend
    participant Registry
    participant Agent

    User->>CLI: clawteam spawn tmux claude --team dev --name worker1
    CLI->>Backend: spawn(command, team, agent)
    Backend->>Backend: Setup environment
    Backend->>Backend: Create tmux session
    Backend->>Agent: Launch agent process
    Backend->>Registry: register_agent(...)
    Registry-->>CLI: Agent registered
    CLI-->>User: "Agent 'worker1' spawned in tmux"
    Agent->>Agent: Read identity env vars
    Agent->>Agent: Execute assigned task
```

## Best Practices

1. **Use descriptive agent names**: Makes tracking and debugging easier
2. **Set appropriate agent types**: Enables role-based task assignment
3. **Use tmux backend for persistence**: Allows attaching to view progress
4. **Leverage profiles**: Reuse configurations across multiple spawns
5. **Use session resume**: Maintain continuity across agent restarts

## See Also

- [CLI Reference](skills/clawteam/references/cli-reference.md) - Full command documentation
- [Workflows](skills/clawteam/references/workflows.md) - Common usage patterns
- [Team Management](skills/clawteam/references/cli-reference.md#team-commands) - Team operations

---

<a id='page-task-management'></a>

## Task Management System

### 相关页面

相关主题：[Agent Spawning System](#page-agent-spawning), [Messaging & Inbox System](#page-messaging), [Board & Monitoring Dashboard](#page-board-dashboard)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [clawteam/team/tasks.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)
- [clawteam/team/models.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/models.py)
- [clawteam/store/base.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/store/base.py)
- [clawteam/store/file.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/store/file.py)
- [clawteam/mcp/tools/task.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/task.py)
- [clawteam/cli/commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py)
</details>

# Task Management System

## Overview

The Task Management System is the core orchestration layer within ClawTeam that enables multi-agent teams to create, track, assign, and coordinate work items across collaborative agent swarms. It provides a task store abstraction with file-based persistence, supporting task dependencies, priority levels, status tracking, and automatic unblocking when dependent tasks complete.

**资料来源：** [clawteam/team/tasks.py:1-17](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)

---

## Architecture

### High-Level Component Diagram

```mermaid
graph TD
    subgraph "CLI Layer"
        CLI[clawteam CLI Commands]
    end
    
    subgraph "Task Management"
        TaskStore[TaskStore<br/>Compatibility Shim]
        BaseTaskStore[BaseTaskStore<br/>Abstract Interface]
        FileTaskStore[FileTaskStore<br/>File-based Implementation]
    end
    
    subgraph "MCP Integration"
        MCPTools[clawteam/mcp/tools/task.py]
    end
    
    subgraph "Storage"
        FS[~/.clawteam/tasks/{team}/<br/>task-{id}.json]
    end
    
    CLI --> TaskStore
    MCPTools --> TaskStore
    TaskStore --> BaseTaskStore
    FileTaskStore -->|inherits| BaseTaskStore
    FileTaskStore --> FS
```

### Task Store Abstraction

The system uses a compatibility shim pattern where `clawteam/team/tasks.py` preserves the historic import path while delegating to the modern store implementation:

```python
from clawteam.store.base import BaseTaskStore, TaskLockError
from clawteam.store.file import FileTaskStore

TaskStore = FileTaskStore
```

**资料来源：** [clawteam/team/tasks.py:9-16](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)

---

## Data Models

### Task Model Fields

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Unique task identifier (auto-generated) |
| `subject` | string | Task title/summary |
| `description` | string | Detailed task description |
| `status` | TaskStatus | Current state (pending/in_progress/completed/blocked) |
| `owner` | string | Agent name assigned to the task |
| `priority` | string | Priority level (low/medium/high/urgent) |
| `blocks` | list[string] | Task IDs that this task blocks when completed |
| `blocked_by` | list[string] | Task IDs that must complete before this can start |
| `created_at` | timestamp | Creation timestamp |
| `updated_at` | timestamp | Last modification timestamp |

**资料来源：** [clawteam/team/models.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/models.py)

### Task Statuses

| Status | Value | Description |
|--------|-------|-------------|
| `pending` | `pending` | Not yet started |
| `in_progress` | `in_progress` | Currently being worked on |
| `completed` | `completed` | Done (auto-unblocks dependents) |
| `blocked` | `blocked` | Waiting on other tasks |

**资料来源：** [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

### Task Priority Levels

| Priority | Description |
|----------|-------------|
| `low` | Non-critical work |
| `medium` | Standard priority |
| `high` | Important work |
| `urgent` | Immediate attention required |

---

## Storage Layer

### File Storage Layout

```
~/.clawteam/
├── teams/{team}/
│   ├── config.json          # TeamConfig (name, members, leader)
│   └── inboxes/{agent}/     # msg-{timestamp}-{uuid}.json files
├── tasks/{team}/
│   └── task-{id}.json       # Individual task files
└── plans/
    └── {agent}-{id}.md      # Plan documents
```

**资料来源：** [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

### TaskStore Implementation

The `FileTaskStore` provides concrete implementation extending `BaseTaskStore`:

- **Persistence**: Tasks stored as individual JSON files named `task-{id}.json`
- **Team Isolation**: Each team has its own subdirectory under `~/.clawteam/tasks/`
- **Task Locking**: Uses `TaskLockError` for concurrent access control

**资料来源：** [clawteam/store/file.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/store/file.py)

---

## Task Dependencies

### Dependency Model

```mermaid
graph LR
    A[Task A<br/>Design API] -->|blocks| B[Task B<br/>Implement Backend]
    A -->|blocks| C[Task C<br/>Build Frontend]
    B -->|blocks| D[Task D<br/>Integration Testing]
    C -->|blocks| D
    
    style A fill:#90EE90
    style B fill:#FFD700
    style C fill:#FFD700
    style D fill:#FFA500
```

### Automatic Unblocking

When a task is marked `completed`, the system automatically unblocks any tasks that were waiting on it:

```
Task A marked completed → Tasks B and C auto-transition from blocked → pending
```

**资料来源：** [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

---

## CLI Commands

### Task Create

```bash
clawteam task create <team> <subject> [options]
```

| Option | Description | Default |
|--------|-------------|---------|
| `--owner, -o` | Agent assigned to this task | `None` |
| `--description, -d` | Detailed description | `""` |
| `--priority, -p` | Priority level | `"medium"` |
| `--blocks` | Comma-separated task IDs this blocks | `None` |
| `--blocked-by` | Comma-separated task IDs blocking this | `None` |

**Example:**
```bash
clawteam task create dev-team "Implement auth" -o alice -d "Add JWT authentication"
```

**资料来源：** [clawteam/cli/commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py)

### Task Get

Retrieve a single task by ID:

```bash
clawteam task get <team> <task-id>
```

### Task Update

Update task properties:

```bash
clawteam task update <team> <task-id> [options]
```

| Option | Description |
|--------|-------------|
| `--status, -s` | New status: `pending`, `in_progress`, `completed`, `blocked` |
| `--owner, -o` | New owner |
| `--subject` | New subject |
| `--description, -d` | New description |
| `--priority, -p` | New priority: `low`, `medium`, `high`, `urgent` |
| `--add-blocks` | Comma-separated task IDs to add to blocks |
| `--add-blocked-by` | Comma-separated task IDs to add to blocked-by |
| `--force, -f` | Force override task lock |

### Task List

List all tasks for a team with optional filters:

```bash
clawteam task list <team> [--status STATUS] [--owner NAME] [--priority LEVEL] [--sort-priority]
```

**资料来源：** [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

---

## MCP Tool Integration

The MCP (Model Context Protocol) layer exposes task operations to AI agents:

```python
# Pseudo-structure from clawteam/mcp/tools/task.py
- task_create_tool()   # Create tasks via MCP
- task_get_tool()      # Retrieve task details
- task_update_tool()   # Modify task state
- task_list_tool()    # Query tasks with filters
```

**资料来源：** [clawteam/mcp/tools/task.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/task.py)

---

## Workflow Examples

### Sequential Dependency Chain

```bash
# 1. Create design task
clawteam task create my-team "Design API schema" -o leader
# => Task ID: aaa11111

# 2. Create backend task (blocked by design)
clawteam task create my-team "Implement backend" -o backend-dev --blocked-by aaa11111
# => Task ID: bbb22222 (auto-set to blocked status)

# 3. Create integration task (blocked by backend)
clawteam task create my-team "Integration testing" --blocked-by bbb22222
# => Task ID: ccc33333

# 4. Complete tasks in order
clawteam task update my-team aaa11111 --status completed
# bbb22222 auto-unblocks from blocked → pending

clawteam task update my-team bbb22222 --status completed
# ccc33333 auto-unblocks from blocked → pending
```

**资料来源：** [skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)

### Parallel Task Assignment

```bash
# Design task (owned by leader)
clawteam task create my-team "Design system" -o leader

# Backend and frontend (both blocked by design)
clawteam task create my-team "Implement backend" -o backend-dev --blocked-by <design-id>
clawteam task create my-team "Build frontend" -o frontend-dev --blocked-by <design-id>

# Integration (blocked by both backend and frontend)
clawteam task create my-team "Integration testing" --blocked-by <backend-id>,<frontend-id>
```

---

## Error Handling

### TaskLockError

Concurrent access to task files is controlled via `TaskLockError`:

```python
from clawteam.store.base import BaseTaskStore, TaskLockError
```

When a task is locked by another process, operations that modify the task will raise `TaskLockError`.

**资料来源：** [clawteam/team/tasks.py:9](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)

---

## API Summary

| Operation | Method | File Reference |
|-----------|--------|----------------|
| Create Task | `task create <team> <subject>` | [commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py) |
| Get Task | `task get <team> <task-id>` | [commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py) |
| Update Task | `task update <team> <task-id>` | [commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py) |
| List Tasks | `task list <team>` | [commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py) |
| Store Base | Abstract interface | [store/base.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/store/base.py) |
| Store File | File implementation | [store/file.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/store/file.py) |
| MCP Tools | Tool definitions | [mcp/tools/task.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/task.py) |

---

<a id='page-team-management'></a>

## Team Management

### 相关页面

相关主题：[Agent Spawning System](#page-agent-spawning), [Task Management System](#page-task-management), [Event System](#page-event-system)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [clawteam/team/manager.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/manager.py)
- [clawteam/team/lifecycle.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/lifecycle.py)
- [clawteam/team/router.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/router.py)
- [clawteam/team/routing_policy.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/routing_policy.py)
- [clawteam/team/snapshot.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/snapshot.py)
- [clawteam/harness/orchestrator.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/orchestrator.py)
- [clawteam/harness/roles.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/roles.py)
</details>

# Team Management

Team Management is the core orchestration layer in ClawTeam that enables multiple AI agents to collaborate within a structured hierarchy. It provides facilities for creating teams, managing agent lifecycles, routing messages, coordinating tasks with dependency chains, and facilitating graceful shutdowns.

## Overview

ClawTeam's Team Management system treats a multi-agent workflow as a first-class organizational unit called a **Team**. Each team has:

- A designated **Leader** agent responsible for coordination
- Member agents with distinct roles and capabilities
- A shared **Board** for task visualization and status tracking
- An **Inbox** system for point-to-point and broadcast messaging
- Task management with dependency tracking

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Team Architecture

```mermaid
graph TD
    A[Leader Agent] --> B[Board - Kanban Tasks]
    A --> C[Inbox - Message Routing]
    A --> D[Task Store]
    B --> E[Task Status: pending, in_progress, completed, blocked]
    C --> F[Message Types: broadcast, plan, shutdown, idle]
    D --> G[Dependency Chains]
```

The architecture follows a hub-and-spoke model where the leader agent serves as the central coordinator. The Board provides a kanban-style visualization, while the Inbox handles all inter-agent communication.

资料来源：[clawteam/team/manager.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/manager.py)

## Team Lifecycle

### Lifecycle States

Agents in a team progress through well-defined lifecycle states:

| State | Description |
|-------|-------------|
| `active` | Agent is running and processing tasks |
| `idle` | Agent has completed current work and awaits new assignments |
| `shutdown_requested` | Leader has requested agent termination |
| `terminated` | Agent has gracefully shut down |

资料来源：[clawteam/team/lifecycle.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/lifecycle.py)

### Lifecycle Commands

```bash
# Leader requests agent shutdown
clawteam lifecycle request-shutdown <team> <from-agent> <to-agent> [--reason TEXT]

# Agent approves shutdown
clawteam lifecycle approve-shutdown <team> <request-id> <agent>

# Agent rejects shutdown
clawteam lifecycle reject-shutdown <team> <request-id> <agent> [--reason TEXT]

# Agent signals idle state to leader
clawteam lifecycle idle <team> [--last-task ID] [--task-status STATUS]
```

资料来源：[skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)

## Message Routing

The routing system determines how messages flow between agents within a team.

```mermaid
graph LR
    A[Agent A] -->|message| B[Router]
    A -->|broadcast| B
    A -->|plan_approval_request| B
    B -->|route| C[Agent B]
    B -->|route| D[All Members]
    B -->|route| E[Leader]
```

### Routing Policies

| Policy | Behavior |
|--------|----------|
| `direct` | Point-to-point message to specific agent |
| `broadcast` | Message delivered to all team members |
| `leader_only` | Message routed exclusively to team leader |

资料来源：[clawteam/team/router.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/router.py)
资料来源：[clawteam/team/routing_policy.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/routing_policy.py)

### Message Types

| Type | Direction | Purpose |
|------|-----------|---------|
| `message` | point-to-point | General communication |
| `broadcast` | team-wide | Announcements to all members |
| `join_request` | candidate → leader | Request to join team |
| `join_approved` / `join_rejected` | leader → candidate | Join response |
| `plan_approval_request` | agent → leader | Submit plan for review |
| `plan_approved` / `plan_rejected` | leader → agent | Plan response |
| `shutdown_request` | leader → agent | Termination request |
| `shutdown_approved` / `shutdown_rejected` | agent → leader | Shutdown response |
| `idle` | agent → leader | No more work notification |

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Task Management

Tasks are the fundamental work units within a team. They support dependency chains, priorities, and automatic status transitions.

### Task Statuses

| Status | Description |
|--------|-------------|
| `pending` | Not yet started |
| `in_progress` | Currently being worked on |
| `completed` | Done (auto-unblocks dependents) |
| `blocked` | Waiting on other tasks |

When a task is marked `completed`, any tasks blocked by it are automatically unblocked (moved from `blocked` to `pending` if no other blockers remain).

资料来源：[clawteam/team/tasks.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/tasks.py)

### Task Commands

```bash
# Create a task
clawteam task create <team> <subject> [options]
    -o, --owner NAME          Task owner
    -d, --description TEXT    Task description
    -p, --priority LEVEL      low, medium, high, urgent
    --blocks ID               Task IDs this blocks
    --blocked-by ID           Comma-separated task IDs blocking this

# Update task
clawteam task update <team> <task-id> [options]
    -s, --status STATUS       New status
    -o, --owner NAME          New owner
    --add-blocks ID           Add tasks this blocks
    --add-blocked-by ID       Add tasks blocking this
    -f, --force               Force override task lock

# List tasks
clawteam task list <team> [--status STATUS] [--owner NAME] [--priority LEVEL] [--sort-priority]

# Get single task
clawteam task get <team> <task-id>
```

### Task Dependency Example

```bash
# Task 1: Design system (no dependencies)
clawteam task create my-project "Design system" -o leader
# => Task ID: aaa11111

# Task 2: Implement backend (blocked by Task 1)
clawteam task create my-project "Implement backend" -o backend-dev --blocked-by aaa11111
# => Task ID: bbb22222 (auto-set to blocked status)

# Task 3: Integration testing (blocked by Tasks 1 and 2)
clawteam task create my-project "Integration testing" --blocked-by bbb22222,ccc33333
# => Task ID: ddd44444

# When Task 1 completes, Task 2 unblocks
clawteam task update my-project aaa11111 --status completed
```

资料来源：[skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)

## Agent Roles

ClawTeam supports role-based agent assignments through the harness system.

### Available Roles

| Role | Purpose |
|------|---------|
| `leader` | Team coordinator, approves plans, assigns tasks |
| `planner` | Drafts specifications and implementation plans |
| `coder` | Executes implementation tasks |
| `evaluator` | Reviews and validates work against specifications |
| `researcher` | Gathers information and best practices |

资料来源：[clawteam/harness/roles.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/roles.py)

### Role-Specific Context Recovery

Each role has context recovery layers that inject relevant information:

| Role | Context Provided |
|------|------------------|
| `leader` | Sprint contract, team task summary by owner |
| `planner` | Spec draft for planning |
| `evaluator` | Full specification + contract criteria |
| `researcher` | Sprint contract with agent name highlighted |

资料来源：[clawteam/harness/context_recovery.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/harness/context_recovery.py)

## Orchestration

The orchestrator coordinates multiple agents within a team template, spawning agents with proper identity and environment setup.

### Orchestration Flow

```mermaid
sequenceDiagram
    participant L as Leader
    participant O as Orchestrator
    participant A as Agent
    participant S as Spawn Backend

    L->>O: Launch team from template
    O->>O: Parse template and roles
    loop For each agent
        O->>S: Spawn agent with identity env vars
        S->>A: Start agent process
        A->>A: Set CLAWTEAM_AGENT_* vars
    end
    O->>L: Return launch summary
```

### Spawn Command

```bash
clawteam spawn <backend> <command...> [options]
    -t, --team NAME         Team name (default: "default")
    -n, --agent-name NAME   Agent name (auto-generated)
    --agent-type TYPE       Agent type (default: "general-purpose")
```

Backends: `subprocess`, `tmux`

Example:
```bash
clawteam spawn subprocess claude --team dev-team --agent-name bob --agent-type researcher
```

资料来源：[clawteam/cli/commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py)

## Board and Monitoring

The Board provides real-time visualization of team state.

### Board Commands

```bash
# Show detailed team board (kanban view)
clawteam board show <team>
clawteam --json board show <team>

# Overview of all teams
clawteam board overview
clawteam --json board overview

# Live-refreshing kanban board
clawteam board live <team> [--interval 2.0]
```

### Board Data Structure

The board includes:
- Kanban task visualization with status badges
- Member inbox counts
- Message history from event log
- Member-aware message aliases (`memberKey`, `inboxName`, `fromLabel`, `toLabel`)

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Team Snapshots

Snapshots capture the complete state of a team at a point in time for debugging, auditing, or resumption.

```mermaid
graph TD
    A[Snapshot Request] --> B[Snapshot Generator]
    B --> C[Team Config]
    B --> D[Task States]
    B --> E[Agent Status]
    B --> F[Message History]
    B --> G[File Storage: ~/.clawteam/teams/{team}/]
```

资料来源：[clawteam/team/snapshot.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/snapshot.py)

## File Storage Layout

Team data persists to disk under `~/.clawteam/`:

```
~/.clawteam/
├── teams/{team}/
│   ├── config.json          # TeamConfig (name, members, leader)
│   └── inboxes/{agent}/     # msg-{timestamp}-{uuid}.json files
├── tasks/{team}/
│   └── task-{id}.json       # Individual task files
└── plans/
    └── {agent}-{id}.md      # Plan documents
```

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Workflow: Complete Team Lifecycle

```mermaid
graph TD
    A[Create Team] --> B[Spawn Agents]
    B --> C[Assign Tasks]
    C --> D[Agent Work]
    D --> E{Status}
    E -->|in_progress| D
    E -->|completed| F[Unblock Dependents]
    E -->|idle| G[Report to Leader]
    F --> H{Tasks Remaining?}
    H -->|Yes| D
    H -->|No| I[Request Shutdown]
    I --> J[Approve Shutdown]
    J --> K[Cleanup Team]
```

### Step-by-Step Workflow

1. **Create team with leader**
   ```bash
   clawteam team spawn-team my-team -d "Project team" -n leader
   ```

2. **Spawn worker agents**
   ```bash
   clawteam spawn tmux claude --team my-team --agent-name researcher
   clawteam spawn tmux claude --team my-team --agent-name coder
   ```

3. **Create and assign tasks**
   ```bash
   clawteam task create my-team "Research phase" -o researcher
   clawteam task create my-team "Implementation" -o coder --blocked-by <research-task-id>
   ```

4. **Monitor progress**
   ```bash
   clawteam board live my-team
   ```

5. **Graceful shutdown**
   ```bash
   clawteam lifecycle request-shutdown my-team leader coder
   clawteam lifecycle approve-shutdown my-team <request-id> coder
   clawteam team cleanup my-team --force
   ```

资料来源：[skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)

## Quick Reference: Team Commands

| Command | Description |
|---------|-------------|
| `clawteam team spawn-team <name>` | Create new team with leader |
| `clawteam team discover` | List all existing teams |
| `clawteam team status <team>` | Show team configuration and members |
| `clawteam team request-join <team> <name>` | Request to join a team |
| `clawteam team approve-join <team> <request-id>` | Approve join request (leader) |
| `clawteam team reject-join <team> <request-id>` | Reject join request (leader) |
| `clawteam identity show` | Show current agent identity |
| `clawteam inbox send <team> <to> <message>` | Send message to agent |
| `clawteam inbox receive <team> --agent <name>` | Check agent inbox |

资料来源：[clawteam/cli/commands.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/cli/commands.py)

---

<a id='page-transport'></a>

## Transport Layer

### 相关页面

相关主题：[System Architecture](#page-architecture), [Messaging & Inbox System](#page-messaging)

```markdown
<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [clawteam/transport/__init__.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/transport/__init__.py)
- [clawteam/transport/base.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/transport/base.py)
- [clawteam/transport/file.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/transport/file.py)
- [clawteam/transport/p2p.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/transport/p2p.py)
- [clawteam/transport/claimed.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/transport/claimed.py)
</details>

# Transport Layer

## Overview

The Transport Layer in ClawTeam is a modular communication subsystem that enables inter-agent messaging within a team. It provides abstract interfaces and concrete implementations for different transport mechanisms, allowing agents to send, receive, and route messages regardless of the underlying delivery mechanism.

The transport layer is designed with a pluggable architecture, supporting multiple backends including file-based transport and peer-to-peer (P2P) transport for direct agent-to-agent communication.

## Architecture

```mermaid
graph TB
    subgraph "Transport Layer"
        API[Transport API]
        BASE[BaseTransport]
        FILE[FileTransport]
        P2P[P2PTransport]
        CLM[ClaimedTransport]
    end
    
    subgraph "Message Flow"
        SND[Sender Agent]
        RCV[Receiver Agent]
        INBOX[Inbox Store]
    end
    
    API --> BASE
    BASE --> FILE
    BASE --> P2P
    BASE --> CLM
    
    SND -->|send_message| API
    API --> INBOX
    INBOX --> RCV
```

## Core Components

### Base Transport (`clawteam/transport/base.py`)

The `BaseTransport` abstract class defines the interface that all transport implementations must follow.

| Method | Purpose |
|--------|---------|
| `send(envelope)` | Send a message envelope to destination |
| `receive(agent_name)` | Retrieve messages from agent's inbox |
| `peek(agent_name)` | View messages without consumption |
| `list_pending(agent_name)` | List pending message IDs |

资料来源：[clawteam/transport/base.py]()

### File Transport (`clawteam/transport/file.py`)

File-based transport provides reliable message delivery using filesystem-based inboxes. Messages are stored as JSON files in the team's inbox directory structure.

```
~/.clawteam/
├── teams/{team}/
│   └── inboxes/{agent}/
│       └── msg-{timestamp}-{uuid}.json
```

资料来源：[clawteam/transport/file.py]()

**Key Features:**
- Persistent message storage
- Non-destructive `peek` operations
- Destructive `receive` operations
- Atomic file operations for consistency

### P2P Transport (`clawteam/transport/p2p.py`)

Peer-to-peer transport enables direct agent-to-agent communication without centralized message storage. This is an optional backend that requires the `p2p` extra: `pip install "clawteam[p2p]"`

资料来源：[clawteam/transport/p2p.py]()

**Use Cases:**
- Low-latency communication
- Decentralized team topologies
- Environments without shared filesystem

### Claimed Transport (`clawteam/transport/claimed.py`)

The `ClaimedTransport` wraps another transport backend and adds message claiming semantics. This prevents duplicate message processing in concurrent scenarios.

资料来源：[clawteam/transport/claimed.py]()

## Message Envelope

Messages are encapsulated in an envelope structure containing routing and payload information.

```python
@dataclass
class Envelope:
    to: str              # Destination agent name
    from_: str           # Source agent name
    msg_type: str        # Message type identifier
    payload: dict        # Message content
    timestamp: float     # Unix timestamp
    id: str              # Unique message ID
```

## Message Types

| Type | Description | Used By |
|------|-------------|---------|
| `message` | General point-to-point message | Core |
| `broadcast` | Broadcast to all team members | Core |
| `join_request` | Request to join a team | Team module |
| `join_approved` / `join_rejected` | Join response | Team module |
| `plan_approval_request` | Plan submitted for review | Plan module |
| `plan_approved` / `plan_rejected` | Plan response | Plan module |
| `shutdown_request` | Agent shutdown request | Lifecycle module |
| `shutdown_approved` / `shutdown_rejected` | Shutdown response | Lifecycle module |
| `idle` | Agent idle notification | Lifecycle module |

资料来源：[clawteam/transport/__init__.py]()

## Transport Selection

```mermaid
graph LR
    A[Agent Spawns] --> B{Configured Backend}
    B -->|default| F[FileTransport]
    B -->|p2p| P[P2PTransport]
    B -->|claimed| C[ClaimedTransport]
```

The transport backend is typically specified in the agent's runtime profile or configured via environment variables.

## Configuration

Transport backends can be configured through:

1. **Runtime Profiles** - Stored in `~/.clawteam/profiles/`
2. **Environment Variables** - `CLAWTEAM_TRANSPORT_BACKEND`
3. **Profile Wizard** - Interactive TUI: `clawteam profile wizard`

资料来源：[skills/clawteam/SKILL.md]()
</details>

---

<a id='page-messaging'></a>

## Messaging & Inbox System

### 相关页面

相关主题：[Transport Layer](#page-transport), [Agent Spawning System](#page-agent-spawning)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [clawteam/team/mailbox.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/mailbox.py)
- [clawteam/mcp/tools/mailbox.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)
- [clawteam/team/plan.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/plan.py)
- [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)
- [skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)
</details>

# Messaging & Inbox System

## Overview

The Messaging & Inbox System in ClawTeam provides inter-agent communication capabilities for coordinating agent swarms. It enables point-to-point messaging, broadcasts, and structured request/response patterns for team coordination including plan approvals, join requests, and graceful shutdowns.

Messages are stored persistently in team-specific inboxes as JSON files, allowing asynchronous communication between agents that may not be running simultaneously. Each agent has its own inbox within a team's directory structure at `~/.clawteam/teams/{team}/inboxes/{agent}/`. 资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Architecture

```mermaid
graph TD
    A[Agent] -->|mailbox_send| B[TeamMailbox]
    A -->|mailbox_receive| B
    A -->|mailbox_broadcast| B
    B --> C[File System]
    C --> D[~/.clawteam/teams/{team}/inboxes/]
    E[Leader] -->|Plan messages| B
    F[Worker] -->|Plan messages| B
    
    subgraph "Message Types"
        G[message]
        H[broadcast]
        I[join_request]
        J[plan_approval_request]
        K[shutdown_request]
        L[idle]
    end
```

## Message Types

The system supports the following message types defined in the `MessageType` enum:

| Type | Direction | Purpose |
|------|-----------|---------|
| `message` | Point-to-point | General communication between agents |
| `broadcast` | One-to-all | Broadcast to all team members |
| `join_request` | Worker → Leader | Request to join a team |
| `join_approved` / `join_rejected` | Leader → Worker | Join request response |
| `plan_approval_request` | Worker → Leader | Submit plan for review |
| `plan_approved` / `plan_rejected` | Leader → Worker | Plan review response |
| `shutdown_request` | Leader → Worker | Request worker shutdown |
| `shutdown_approved` / `shutdown_rejected` | Worker → Leader | Shutdown response |
| `idle` | Worker → Leader | Agent has no more work |

资料来源：[clawteam/team/plan.py:12-40](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/team/plan.py)

## Core API Functions

### mailbox_send

Send a message to a specific agent within a team.

```python
def mailbox_send(
    team_name: str,
    from_agent: str,
    to_agent: str,
    content: str,
    msg_type: str | None = None,
    request_id: str | None = None,
    key: str | None = None,
    proposed_name: str | None = None,
    capabilities: str | None = None,
    feedback: str | None = None,
    reason: str | None = None,
    assigned_name: str | None = None,
    agent_id: str | None = None,
    team_name: str | None = None,
    plan_file: str | None = None,
    summary: str | None = None,
    plan: str | None = None,
    last_task: str | None = None,
    status: str | None = None,
) -> dict
```

资料来源：[clawteam/mcp/tools/mailbox.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)

### mailbox_broadcast

Broadcast a message to all team members, with optional exclusions.

```python
def mailbox_broadcast(
    team_name: str,
    from_agent: str,
    content: str,
    msg_type: str | None = None,
    key: str | None = None,
    exclude: list[str] | None = None,
) -> list[dict]
```

| Parameter | Type | Description |
|-----------|------|-------------|
| `team_name` | str | Target team name |
| `from_agent` | str | Sender identifier |
| `content` | str | Message content |
| `msg_type` | str | Message type (defaults to `broadcast`) |
| `key` | str | Optional categorization key |
| `exclude` | list[str] | Agent names to exclude from broadcast |

资料来源：[clawteam/mcp/tools/mailbox.py:28-41](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)

### mailbox_receive

Receive and consume pending inbox messages. Messages are removed from the inbox after retrieval.

```python
def mailbox_receive(
    team_name: str,
    agent_name: str,
    limit: int = 10,
) -> list[dict]
```

| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| `team_name` | str | Team identifier | Required |
| `agent_name` | str | Agent inbox to check | Required |
| `limit` | int | Maximum messages to retrieve | 10 |

资料来源：[clawteam/mcp/tools/mailbox.py:44-47](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)

### mailbox_peek

Preview pending inbox messages without consuming them. Messages remain available for future retrieval.

```python
def mailbox_peek(
    team_name: str,
    agent_name: str,
) -> list[dict]
```

资料来源：[clawteam/mcp/tools/mailbox.py:50-53](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)

### mailbox_peek_count

Get the count of pending messages without retrieving content.

```python
def mailbox_peek_count(
    team_name: str,
    agent_name: str,
) -> dict
```

Returns:
```json
{
  "agentName": "alice",
  "count": 5
}
```

资料来源：[clawteam/mcp/tools/mailbox.py:56-59](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)

## CLI Commands

### inbox send

Send a message to another agent.

```bash
clawteam inbox send <team> <from-agent> <to-agent> <content> [--type TYPE]
```

### inbox receive

Receive and consume pending messages.

```bash
clawteam inbox receive <team> --agent <agent-name> [--limit N]
```

### inbox peek

Preview messages without consuming.

```bash
clawteam inbox peek <team> --agent <agent-name>
```

### inbox count

Count pending messages.

```bash
clawteam inbox count <team> --agent <agent-name>
```

### inbox broadcast

Broadcast to all team members.

```bash
clawteam inbox broadcast <team> <from-agent> <content> [--exclude AGENT1,AGENT2]
```

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Message Flow Patterns

### Point-to-Point Messaging

```mermaid
sequenceDiagram
    participant A as Agent Alice
    participant M as TeamMailbox
    participant B as Agent Bob
    
    A->>M: mailbox_send(to=Bob, content="Task update")
    M->>M: Store msg-{timestamp}-{uuid}.json
    B->>M: mailbox_receive(agent=Bob)
    M->>B: Return and remove message
```

### Plan Approval Flow

```mermaid
graph LR
    A[Worker] -->|plan_approval_request| B[Leader]
    B -->|Review| B
    B -->|plan_approved| A
    B -->|plan_rejected| A
```

Example workflow:
```bash
# Worker submits plan
clawteam plan submit dev-team coder "Auth system redesign" \
  --summary "Modernize auth system"

# Leader reviews inbox
clawteam inbox receive dev-team --agent leader
# => plan_approval_request with planId

# Leader approves or rejects
clawteam plan approve dev-team <plan-id> coder --feedback "Looks good, proceed"
```

资料来源：[skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)

### Shutdown Flow

```mermaid
sequenceDiagram
    participant L as Leader
    participant M as TeamMailbox
    participant W as Worker
    
    L->>M: lifecycle request-shutdown
    M->>W: shutdown_request
    W->>W: Complete current work
    W->>M: lifecycle approve-shutdown
    M->>L: shutdown_approved
```

资料来源：[skills/clawteam/references/workflows.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/workflows.md)

## Storage Layout

Messages are persisted in the following structure:

```
~/.clawteam/
├── teams/{team}/
│   └── inboxes/
│       └── {agent}/
│           ├── msg-{timestamp}-{uuid}.json   # Individual messages
│           ├── msg-{timestamp}-{uuid}.json
│           └── ...
└── plans/
    └── {agent}-{id}.md                        # Plan documents
```

Each message file contains structured JSON with metadata including sender, recipient, message type, timestamp, and type-specific fields.

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Data Model

### Message Payload

```python
@dataclass
class MessagePayload:
    msg_type: MessageType
    from_agent: str
    to_agent: str
    content: str
    request_id: str | None
    key: str | None
    proposed_name: str | None
    capabilities: str | None
    feedback: str | None
    reason: str | None
    assigned_name: str | None
    agent_id: str | None
    team_name: str | None
    plan_file: str | None
    summary: str | None
    plan: str | None
    last_task: str | None
    status: str | None
```

资料来源：[clawteam/mcp/tools/mailbox.py:1-20](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/mailbox.py)

## Best Practices

1. **Always check inbox before declaring idle** - Agents should check `clawteam task list {team}` and inbox before reporting idle status.

2. **Use peek before receive** - Preview messages with `mailbox_peek` when you need to selectively process messages without consuming all pending items.

3. **Set request IDs for tracking** - When sending plan or shutdown requests, include a unique `request_id` to correlate responses.

4. **Send cost reports** - After completing work, report costs using:
   ```bash
   clawteam cost report {team} --input-tokens <N> --output-tokens <N> --cost-cents <N>
   ```

5. **Monitor team health** - Use JSON output for scripting:
   ```bash
   clawteam --json board show dev-team | jq '.members[] | select(.inboxCount > 0) | .name'
   ```

资料来源：[clawteam/spawn/prompt.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/spawn/prompt.py)

---

<a id='page-board-dashboard'></a>

## Board & Monitoring Dashboard

### 相关页面

相关主题：[Task Management System](#page-task-management), [Team Management](#page-team-management)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [clawteam/board/server.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/server.py)
- [clawteam/board/renderer.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/renderer.py)
- [clawteam/board/collector.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/collector.py)
- [clawteam/board/gource.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/gource.py)
- [clawteam/mcp/tools/board.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/board.py)
- [website/src/App.jsx](https://github.com/HKUDS/ClawTeam/blob/main/website/src/App.jsx)
- [skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)
- [skills/clawteam/SKILL.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/SKILL.md)
</details>

# Board & Monitoring Dashboard

The Board is ClawTeam's centralized monitoring and coordination interface for agent swarms. It provides real-time visibility into team tasks, agent statuses, message exchanges, and activity history through both CLI commands and a browser-based dashboard.

## Purpose & Scope

The Board system serves as the coordination nerve center for multi-agent teams:

- **Task Visualization** — Kanban-style task boards showing blockers, priority, ownership, and progress across all agents
- **Persistent Coordination** — Handoffs, aliases, and notes remain visible after prompts scroll away
- **Team Awareness** — Inbox counts, member status, and message history accessible in one view
- **Activity Visualization** — Gource-based git activity rendering to visualize team contributions over time

资料来源：[skills/clawteam/SKILL.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/SKILL.md)

## Architecture

```mermaid
graph TD
    subgraph "Board Subsystem"
        A[board show] --> B[Board Server]
        C[board live] --> B
        D[board overview] --> B
        
        B --> E[Collector Module]
        B --> F[Renderer Module]
        B --> G[Gource Module]
        
        E --> H[Task Store]
        E --> I[Message Store]
        E --> J[Team Config]
    end
    
    subgraph "Output Formats"
        F --> K[Human Readable]
        F --> L[JSON API]
        G --> M[Gource Visualization]
    end
```

The Board module consists of four primary components:

| Component | File | Responsibility |
|-----------|------|----------------|
| **server.py** | `clawteam/board/server.py` | HTTP/web server, API endpoints, command handlers |
| **collector.py** | `clawteam/board/collector.py` | Aggregates data from task stores, message stores, team configs |
| **renderer.py** | `clawteam/board/renderer.py` | Formats board data for human or JSON output |
| **gource.py** | `clawteam/board/gource.py` | Generates git activity visualizations |

资料来源：[clawteam/board/server.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/server.py)

## Data Model

The Board draws data from three primary storage locations under `~/.clawteam/`:

```
~/.clawteam/
├── teams/{team}/
│   ├── config.json          # TeamConfig (name, members, leader)
│   └── inboxes/{agent}/     # msg-{timestamp}-{uuid}.json files
├── tasks/{team}/
│   └── task-{id}.json       # Individual task files
└── plans/
    └── {agent}-{id}.md      # Plan documents
```

### Task Statuses

| Status | Description | Behavior |
|--------|-------------|----------|
| `pending` | Not yet started | Available for assignment |
| `in_progress` | Currently being worked on | Blocks dependent tasks |
| `completed` | Done | Auto-unblocks dependent tasks |
| `blocked` | Waiting on other tasks | Remains blocked until blockers complete |

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

### Message Types

| Type | Description |
|------|-------------|
| `message` | General point-to-point message |
| `broadcast` | Broadcast to all members |
| `join_request` / `join_approved` / `join_rejected` | Team join lifecycle |
| `plan_approval_request` / `plan_approved` / `plan_rejected` | Plan review lifecycle |
| `shutdown_request` / `shutdown_approved` / `shutdown_rejected` | Agent shutdown lifecycle |
| `idle` | Agent idle notification |

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Board Commands

### `board show`

Display detailed team board data with kanban visualization.

```bash
clawteam board show <team>
clawteam --json board show <team>
```

| Output Mode | Description |
|-------------|-------------|
| Human | Renders kanban board with tasks grouped by status |
| JSON | Includes member inbox identity fields plus persistent message history |

The JSON output includes member-aware message aliases:

- `memberKey` — Unique member identifier
- `inboxName` — Agent's inbox directory name
- `fromLabel` / `toLabel` — Human-readable sender/recipient labels

These fields enable the browser board to filter inbox history by team member.

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

### `board overview`

Show summary of all teams in a table format.

```bash
clawteam board overview
clawteam --json board overview
```

Returns metadata for each team:

| Field | Description |
|-------|-------------|
| `name` | Team identifier |
| `description` | Team purpose description |
| `leadAgentId` | Leader agent ID |
| `memberCount` | Number of active members |

### `board live`

Launch a live-refreshing kanban board that auto-updates at configurable intervals.

```bash
clawteam board live <team> [--interval 2.0]
```

Press `Ctrl+C` to stop the live view. Default refresh interval is 2.0 seconds.

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## MCP Board Tools

For integration with AI agents, the Board exposes MCP (Model Context Protocol) tools in `clawteam/mcp/tools/board.py`:

```python
# Available MCP tools for board interaction
- board_show       # Show team board data
- board_overview   # List all teams summary
- board_live       # Start live monitoring
```

These tools allow AI agents to query board state programmatically without CLI invocation.

资料来源：[clawteam/mcp/tools/board.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/mcp/tools/board.py)

## Browser Dashboard (website/src/App.jsx)

The website provides a browser-accessible board interface at `website/src/App.jsx`. The browser board includes:

### Visual Components

| Component | Description |
|-----------|-------------|
| **Hero Section** | Main landing area with CLI mockup visualization |
| **Features Grid** | Cards highlighting core capabilities |
| **Workflow Steps** | Installation and setup instructions |
| **Documentation Links** | Quick access to SKILL.md and CLI reference |

The TerminalMockup component renders a simulated CLI session showing team operations:

```jsx
<TeamTerminalMockup/>
```

This mockup demonstrates:
- Team creation: `clawteam team spawn-team docs-sprint`
- Agent spawning: `clawteam spawn tmux claude-code --agent-name builder`
- Status checks: `clawteam team status docs-sprint`

资料来源：[website/src/App.jsx](https://github.com/HKUDS/ClawTeam/blob/main/website/src/App.jsx)

## Gource Activity Visualization

The `gource.py` module provides git-aware execution visualization:

```mermaid
graph LR
    A[Git Repos] --> B[Gource Renderer]
    C[Worktrees] --> B
    D[Diffs] --> B
    E[Merge State] --> B
    
    B --> F[Activity Timeline]
```

Gource renders agent activity as a timeline visualization, showing:
- File changes over time
- Agent contribution patterns
- Merge and branch activity

资料来源：[clawteam/board/gource.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/gource.py)

## Integration with Task System

The Board integrates closely with the task management system:

```mermaid
graph LR
    A[Task Create] --> B[Task Store]
    C[Task Update] --> B
    D[Task Complete] --> E[Auto-Unblock]
    
    B --> F[Board Collector]
    F --> G[Board Renderer]
    G --> H[CLI / Browser]
    
    E --> B
```

Task commands that feed into the Board:

| Command | Board Impact |
|---------|-------------|
| `task create` | Adds new task to kanban |
| `task update --status` | Moves task between columns |
| `task update --owner` | Assigns/reassigns task |
| `task list` | Filters visible tasks |

When a task is marked `completed`, the system automatically unblocks any tasks that were blocked by it (moving them from `blocked` to `pending` if no other blockers remain).

资料来源：[skills/clawteam/references/cli-reference.md](https://github.com/HKUDS/ClawTeam/blob/main/skills/clawteam/references/cli-reference.md)

## Configuration

Board behavior is controlled through team configuration stored in `~/.clawteam/teams/{team}/config.json`:

```json
{
  "name": "team-name",
  "members": ["leader", "agent-1", "agent-2"],
  "leader": "leader"
}
```

The collector module reads this config along with task and message stores to build the complete board view.

资料来源：[clawteam/board/collector.py](https://github.com/HKUDS/ClawTeam/blob/main/clawteam/board/collector.py)

## Quick Reference

| Command | Purpose |
|---------|---------|
| `clawteam board show <team>` | View team kanban board |
| `clawteam board overview` | List all teams summary |
| `clawteam board live <team>` | Live-refreshing board view |
| `clawteam task list <team>` | List tasks with filters |
| `clawteam team status <team>` | Show team config and members |

---

---

## Doramagic 踩坑日志

项目：HKUDS/ClawTeam

摘要：发现 15 个潜在踩坑项，其中 1 个为 high/blocking；最高优先级：安全/权限坑 - 来源证据：Security testing for multi-agent swarms: agent isolation, delegation trust, inbox spoofing。

## 1. 安全/权限坑 · 来源证据：Security testing for multi-agent swarms: agent isolation, delegation trust, inbox spoofing

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Security testing for multi-agent swarms: agent isolation, delegation trust, inbox spoofing
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_d8bd96f00b7c46c6813bc15c32a84625 | https://github.com/HKUDS/ClawTeam/issues/76 | 来源类型 github_issue 暴露的待验证使用条件。

## 2. 配置坑 · 可能修改宿主 AI 配置

- 严重度：medium
- 证据强度：source_linked
- 发现：项目面向 Claude/Cursor/Codex/Gemini/OpenCode 等宿主，或安装命令涉及用户配置目录。
- 对用户的影响：安装可能改变本机 AI 工具行为，用户需要知道写入位置和回滚方法。
- 建议检查：列出会写入的配置文件、目录和卸载/回滚步骤。
- 防护动作：涉及宿主配置目录时必须给回滚路径，不能只给安装命令。
- 证据：capability.host_targets | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | host_targets=claude, claude_code, cursor, chatgpt

## 3. 配置坑 · 来源证据：Proposal: 8-PR sequence — canonical WorkerState, persistent event log, project namespacing, contract verify states, SCM…

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：Proposal: 8-PR sequence — canonical WorkerState, persistent event log, project namespacing, contract verify states, SCM plugin + reaction engine
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_114771b2a1474b358b05a6a9e61807f6 | https://github.com/HKUDS/ClawTeam/issues/157 | 来源类型 github_issue 暴露的待验证使用条件。

## 4. 能力坑 · 能力判断依赖假设

- 严重度：medium
- 证据强度：source_linked
- 发现：README/documentation is current enough for a first validation pass.
- 对用户的影响：假设不成立时，用户拿不到承诺的能力。
- 建议检查：将假设转成下游验证清单。
- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。
- 证据：capability.assumptions | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | README/documentation is current enough for a first validation pass.

## 5. 维护坑 · 维护活跃度未知

- 严重度：medium
- 证据强度：source_linked
- 发现：未记录 last_activity_observed。
- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。
- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。
- 证据：evidence.maintainer_signals | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | last_activity_observed missing

## 6. 安全/权限坑 · 下游验证发现风险项

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：下游已经要求复核，不能在页面中弱化。
- 建议检查：进入安全/权限治理复核队列。
- 防护动作：下游风险存在时必须保持 review/recommendation 降级。
- 证据：downstream_validation.risk_items | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | no_demo; severity=medium

## 7. 安全/权限坑 · 存在安全注意事项

- 严重度：medium
- 证据强度：source_linked
- 发现：No sandbox install has been executed yet; downstream must verify before user use.
- 对用户的影响：用户安装前需要知道权限边界和敏感操作。
- 建议检查：转成明确权限清单和安全审查提示。
- 防护动作：安全注意事项必须面向用户前置展示。
- 证据：risks.safety_notes | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | No sandbox install has been executed yet; downstream must verify before user use.

## 8. 安全/权限坑 · 存在评分风险

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：风险会影响是否适合普通用户安装。
- 建议检查：把风险写入边界卡，并确认是否需要人工复核。
- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。
- 证据：risks.scoring_risks | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | no_demo; severity=medium

## 9. 安全/权限坑 · 来源证据：Agent Definitions Feature is Non-Functional: Parsed but Not Applied

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Agent Definitions Feature is Non-Functional: Parsed but Not Applied
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_dc9ad856da7a4a828860da94afadc7ec | https://github.com/HKUDS/ClawTeam/issues/146 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 10. 安全/权限坑 · 来源证据：High: /api/proxy board endpoint enables SSRF and arbitrary outbound fetches

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：High: /api/proxy board endpoint enables SSRF and arbitrary outbound fetches
- 对用户的影响：可能阻塞安装或首次运行。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_61dec732a08f4279a590654f0eecea51 | https://github.com/HKUDS/ClawTeam/issues/104 | 来源类型 github_issue 暴露的待验证使用条件。

## 11. 安全/权限坑 · 来源证据：Worker agents exit after first turn despite 'ongoing job' task prompt

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Worker agents exit after first turn despite 'ongoing job' task prompt
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_26124d52e6d948b2bf15809390ef2589 | https://github.com/HKUDS/ClawTeam/issues/148 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 12. 安全/权限坑 · 来源证据：[Feature Request] Optimize Worker Workspace Size and Enable Headless IPC

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：[Feature Request] Optimize Worker Workspace Size and Enable Headless IPC
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_63b04b7d23e74c71a8c1f8dddcaa9281 | https://github.com/HKUDS/ClawTeam/issues/45 | 来源讨论提到 node 相关条件，需在安装/试用前复核。

## 13. 安全/权限坑 · 来源证据：v0.2.0 — Stabilization Release

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：v0.2.0 — Stabilization Release
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_2aca0ffb17f94d8bb219737c9f275e7f | https://github.com/HKUDS/ClawTeam/releases/tag/v0.2.0 | 来源类型 github_release 暴露的待验证使用条件。

## 14. 维护坑 · issue/PR 响应质量未知

- 严重度：low
- 证据强度：source_linked
- 发现：issue_or_pr_quality=unknown。
- 对用户的影响：用户无法判断遇到问题后是否有人维护。
- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。
- 防护动作：issue/PR 响应未知时，必须提示维护风险。
- 证据：evidence.maintainer_signals | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | issue_or_pr_quality=unknown

## 15. 维护坑 · 发布节奏不明确

- 严重度：low
- 证据强度：source_linked
- 发现：release_recency=unknown。
- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。
- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。
- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。
- 证据：evidence.maintainer_signals | art_abc9b09559e64bd4983fa470a78389f3 | https://github.com/HKUDS/ClawTeam#readme | release_recency=unknown

<!-- canonical_name: HKUDS/ClawTeam; human_manual_source: deepwiki_human_wiki -->
