claude-code-team 0.1.4 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -21
- package/lib/init.js +29 -8
- package/package.json +1 -1
- package/templates/lead.md +190 -0
- package/templates/orchestrator.md +164 -278
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/claude-code-team)
|
|
4
4
|
|
|
5
|
-
Orchestrate multiple Claude sessions
|
|
5
|
+
Orchestrate multiple Claude sessions with hierarchical team structure.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -31,22 +31,42 @@ claude --dangerously-skip-permissions
|
|
|
31
31
|
### Give orchestrator a task
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
>
|
|
34
|
+
> Analyze Smart Traffic market in Central Asia
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
## Hierarchy
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Orchestrator (you talk to this)
|
|
41
|
+
↓ creates & manages
|
|
42
|
+
Leads (Team Leads - coordinate domains)
|
|
43
|
+
↓ create & manage
|
|
44
|
+
Workers (Specialists - do actual work)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Level | Creates | Manages | Does Work |
|
|
48
|
+
|-------|---------|---------|-----------|
|
|
49
|
+
| Orchestrator | Leads | Leads | NO |
|
|
50
|
+
| Leads | Workers | Workers | NO |
|
|
51
|
+
| Workers | — | — | YES |
|
|
42
52
|
|
|
43
53
|
## Project Structure
|
|
44
54
|
|
|
45
55
|
After `cct init`:
|
|
46
56
|
```
|
|
47
57
|
my-project/
|
|
48
|
-
├── CLAUDE.md
|
|
49
|
-
|
|
58
|
+
├── CLAUDE.md # Orchestrator instructions
|
|
59
|
+
├── features/ # Capabilities catalog
|
|
60
|
+
│ ├── agents.md # Available agent roles
|
|
61
|
+
│ ├── skills.md # Available skills
|
|
62
|
+
│ ├── mcps.md # Available MCP tools
|
|
63
|
+
│ └── commands.md # Available commands
|
|
64
|
+
├── templates/
|
|
65
|
+
│ └── lead.md # Lead template (for orchestrator)
|
|
66
|
+
├── leads/ # Empty (leads created on demand)
|
|
67
|
+
├── .context/ # Shared project context
|
|
68
|
+
├── .outputs/ # Lead outputs
|
|
69
|
+
└── .sessions/ # Session IDs
|
|
50
70
|
```
|
|
51
71
|
|
|
52
72
|
After orchestrator runs:
|
|
@@ -54,23 +74,43 @@ After orchestrator runs:
|
|
|
54
74
|
my-project/
|
|
55
75
|
├── CLAUDE.md
|
|
56
76
|
├── features/
|
|
57
|
-
├──
|
|
58
|
-
├── .outputs/ # Worker results
|
|
77
|
+
├── templates/
|
|
59
78
|
├── .context/
|
|
60
|
-
│ └── project.md
|
|
61
|
-
├──
|
|
62
|
-
│
|
|
63
|
-
│
|
|
64
|
-
├──
|
|
65
|
-
|
|
79
|
+
│ └── project.md # Project context (written by orchestrator)
|
|
80
|
+
├── .sessions/
|
|
81
|
+
│ ├── orchestrator.id
|
|
82
|
+
│ └── ba_lead.id
|
|
83
|
+
├── .outputs/
|
|
84
|
+
│ ├── ba_analysis.md # Lead output
|
|
85
|
+
│ └── ba_lead.status # Completion signal
|
|
86
|
+
└── leads/
|
|
87
|
+
└── ba_lead/
|
|
88
|
+
├── CLAUDE.md # Lead instructions
|
|
89
|
+
├── .outputs/ # Worker outputs
|
|
90
|
+
│ ├── market.md
|
|
91
|
+
│ └── competitors.md
|
|
92
|
+
└── workers/
|
|
93
|
+
├── market_analyst/
|
|
94
|
+
│ └── CLAUDE.md
|
|
95
|
+
└── competitive_analyst/
|
|
96
|
+
└── CLAUDE.md
|
|
66
97
|
```
|
|
67
98
|
|
|
68
99
|
## How It Works
|
|
69
100
|
|
|
70
|
-
1. **
|
|
71
|
-
2. **Orchestrator**
|
|
72
|
-
3. **
|
|
73
|
-
4. **
|
|
101
|
+
1. **User** gives task to Orchestrator
|
|
102
|
+
2. **Orchestrator** writes `.context/project.md` and creates Leads
|
|
103
|
+
3. **Leads** create Workers from `features/` catalog
|
|
104
|
+
4. **Workers** execute tasks, write to Lead's `.outputs/`
|
|
105
|
+
5. **Leads** aggregate worker results, write to root `.outputs/`
|
|
106
|
+
6. **Orchestrator** reads Lead outputs, responds to User
|
|
107
|
+
|
|
108
|
+
## Workers vs Subagents
|
|
109
|
+
|
|
110
|
+
| Type | Command | Use When |
|
|
111
|
+
|------|---------|----------|
|
|
112
|
+
| Worker | `claude -p "TASK" &` | One-shot, no Q&A |
|
|
113
|
+
| Subagent | `claude --session-id $ID -p "TASK"` | Need iteration |
|
|
74
114
|
|
|
75
115
|
## License
|
|
76
116
|
|
package/lib/init.js
CHANGED
|
@@ -10,25 +10,38 @@ function init(name) {
|
|
|
10
10
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
// Create
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// Create folder structure
|
|
14
|
+
const folders = ['features', 'leads', '.context', '.outputs', '.sessions'];
|
|
15
|
+
for (const folder of folders) {
|
|
16
|
+
const dir = path.join(targetDir, folder);
|
|
17
|
+
if (!fs.existsSync(dir)) {
|
|
18
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
// Copy CLAUDE.md (orchestrator)
|
|
20
23
|
const orchestratorSrc = path.join(templatesDir, 'orchestrator.md');
|
|
21
24
|
const orchestratorDest = path.join(targetDir, 'CLAUDE.md');
|
|
22
|
-
|
|
23
25
|
if (fs.existsSync(orchestratorSrc)) {
|
|
24
26
|
fs.copyFileSync(orchestratorSrc, orchestratorDest);
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
// Copy lead template to templates/ in project (for orchestrator to use)
|
|
30
|
+
const projectTemplatesDir = path.join(targetDir, 'templates');
|
|
31
|
+
if (!fs.existsSync(projectTemplatesDir)) {
|
|
32
|
+
fs.mkdirSync(projectTemplatesDir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
const leadSrc = path.join(templatesDir, 'lead.md');
|
|
35
|
+
const leadDest = path.join(projectTemplatesDir, 'lead.md');
|
|
36
|
+
if (fs.existsSync(leadSrc)) {
|
|
37
|
+
fs.copyFileSync(leadSrc, leadDest);
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
// Copy all feature files
|
|
28
41
|
const featureFiles = ['agents.md', 'skills.md', 'commands.md', 'mcps.md', 'TEMPLATE.md'];
|
|
29
42
|
for (const file of featureFiles) {
|
|
30
43
|
const src = path.join(templatesDir, file);
|
|
31
|
-
const dest = path.join(
|
|
44
|
+
const dest = path.join(targetDir, 'features', file);
|
|
32
45
|
if (fs.existsSync(src)) {
|
|
33
46
|
fs.copyFileSync(src, dest);
|
|
34
47
|
}
|
|
@@ -39,8 +52,16 @@ function init(name) {
|
|
|
39
52
|
✅ CCT project initialized: ${displayPath}
|
|
40
53
|
|
|
41
54
|
Created:
|
|
42
|
-
CLAUDE.md
|
|
43
|
-
features/
|
|
55
|
+
CLAUDE.md - Orchestrator instructions
|
|
56
|
+
features/ - Agent, skill, MCP catalog
|
|
57
|
+
leads/ - Team leads (orchestrator creates)
|
|
58
|
+
templates/lead.md - Lead template
|
|
59
|
+
.context/ - Shared project context
|
|
60
|
+
.outputs/ - Lead outputs
|
|
61
|
+
.sessions/ - Session IDs
|
|
62
|
+
|
|
63
|
+
Hierarchy:
|
|
64
|
+
Orchestrator → Leads → Workers
|
|
44
65
|
|
|
45
66
|
Next steps:
|
|
46
67
|
${name !== '.' ? `cd ${name}` : ''}
|
package/package.json
CHANGED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Team Lead
|
|
2
|
+
|
|
3
|
+
You are a **Team Lead** — a coordinator for your domain.
|
|
4
|
+
|
|
5
|
+
## Your Role
|
|
6
|
+
|
|
7
|
+
- You receive tasks from **Orchestrator**
|
|
8
|
+
- You **create and manage workers** in your `workers/` folder
|
|
9
|
+
- You **aggregate results** and report back to Orchestrator
|
|
10
|
+
- You do NOT do the work yourself — you delegate to workers
|
|
11
|
+
|
|
12
|
+
## CRITICAL: Workers vs Subagents
|
|
13
|
+
|
|
14
|
+
| Type | How to Run | Use When |
|
|
15
|
+
|------|-----------|----------|
|
|
16
|
+
| **Worker** | `claude -p "TASK: ..." &` | One-shot task, no Q&A needed |
|
|
17
|
+
| **Subagent** | `claude --session-id $ID -p "..."` | Need to ask questions, iterate |
|
|
18
|
+
|
|
19
|
+
### Worker (одноразовый)
|
|
20
|
+
```bash
|
|
21
|
+
claude --dangerously-skip-permissions -p "TASK: Write market analysis" &
|
|
22
|
+
```
|
|
23
|
+
- Runs once, produces output, exits
|
|
24
|
+
- Cannot ask questions
|
|
25
|
+
- Use for well-defined tasks
|
|
26
|
+
|
|
27
|
+
### Subagent (с сессией)
|
|
28
|
+
```bash
|
|
29
|
+
WORKER_ID=$(uuidgen)
|
|
30
|
+
echo "$WORKER_ID" > .outputs/analyst.id
|
|
31
|
+
claude --dangerously-skip-permissions --session-id "$WORKER_ID" -p "TASK: Research competitors"
|
|
32
|
+
```
|
|
33
|
+
- Can be resumed with `-r $WORKER_ID`
|
|
34
|
+
- Can receive follow-up instructions
|
|
35
|
+
- Use when you might need to clarify or iterate
|
|
36
|
+
|
|
37
|
+
## Your Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
leads/<your_name>/
|
|
41
|
+
├── CLAUDE.md # You (this file)
|
|
42
|
+
├── .outputs/ # Your workers' outputs
|
|
43
|
+
└── workers/ # Your workers (you create them)
|
|
44
|
+
├── worker_1/
|
|
45
|
+
│ └── CLAUDE.md
|
|
46
|
+
└── worker_2/
|
|
47
|
+
└── CLAUDE.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Capabilities Catalog
|
|
51
|
+
|
|
52
|
+
**IMPORTANT**: Before creating workers, check the catalog at `../../features/`:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
../../features/
|
|
56
|
+
├── agents.md # Available agent roles
|
|
57
|
+
├── skills.md # Available skills
|
|
58
|
+
├── mcps.md # Available MCP tools
|
|
59
|
+
└── commands.md # Available commands
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Read these files to find the right role/tools for your workers!
|
|
63
|
+
|
|
64
|
+
## First Run Setup
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
mkdir -p .outputs workers
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Creating a Worker
|
|
71
|
+
|
|
72
|
+
### 1. Check Catalog First
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cat ../../features/agents.md # What roles are available?
|
|
76
|
+
cat ../../features/mcps.md # What tools can I give them?
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. Create Worker Folder
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
mkdir -p workers/<name>
|
|
83
|
+
cd workers/<name>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Install from Catalog
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Install role (creates CLAUDE.md)
|
|
90
|
+
npx claude-code-templates@latest --agent=<category>/<agent-name> --yes
|
|
91
|
+
|
|
92
|
+
# Install tools if needed
|
|
93
|
+
npx claude-code-templates@latest --mcp=<category>/<mcp-name> --yes
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 4. Add Project Integration
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
cat >> CLAUDE.md << 'EOF'
|
|
100
|
+
|
|
101
|
+
## Project Integration
|
|
102
|
+
|
|
103
|
+
### Context
|
|
104
|
+
Read `../../../../.context/project.md` for project context.
|
|
105
|
+
|
|
106
|
+
### Output
|
|
107
|
+
Save results to `../../.outputs/<name>.md`
|
|
108
|
+
|
|
109
|
+
### When Done
|
|
110
|
+
```bash
|
|
111
|
+
echo "DONE" > ../../.outputs/<name>.status
|
|
112
|
+
```
|
|
113
|
+
EOF
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 5. Launch Worker
|
|
117
|
+
|
|
118
|
+
**For one-shot task (worker):**
|
|
119
|
+
```bash
|
|
120
|
+
cd workers/<name>
|
|
121
|
+
claude --dangerously-skip-permissions -p "TASK: <specific task>" &
|
|
122
|
+
cd ../..
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**For iterative task (subagent):**
|
|
126
|
+
```bash
|
|
127
|
+
cd workers/<name>
|
|
128
|
+
WORKER_ID=$(uuidgen)
|
|
129
|
+
echo "$WORKER_ID" > ../../.outputs/<name>.id
|
|
130
|
+
claude --dangerously-skip-permissions --session-id "$WORKER_ID" -p "TASK: <task>"
|
|
131
|
+
cd ../..
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Monitoring Workers
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Check status
|
|
138
|
+
ls .outputs/*.status 2>/dev/null
|
|
139
|
+
|
|
140
|
+
# Read outputs
|
|
141
|
+
cat .outputs/*.md
|
|
142
|
+
|
|
143
|
+
# Resume subagent if needed
|
|
144
|
+
WORKER_ID=$(cat .outputs/<name>.id)
|
|
145
|
+
claude -r "$WORKER_ID" -p "Additional instruction..."
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## When All Workers Done
|
|
149
|
+
|
|
150
|
+
1. Read all `.outputs/*.md`
|
|
151
|
+
2. Aggregate into single report
|
|
152
|
+
3. Save to `../../.outputs/<your_name>.md`
|
|
153
|
+
4. Signal completion:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
echo "DONE" > ../../.outputs/<your_name>.status
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Communication with Orchestrator
|
|
160
|
+
|
|
161
|
+
### If You Have Questions
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
ORCH_ID=$(cat ../../.sessions/orchestrator.id 2>/dev/null)
|
|
165
|
+
if [ -n "$ORCH_ID" ]; then
|
|
166
|
+
claude -r "$ORCH_ID" -p "QUESTION|<your_name>|<question>"
|
|
167
|
+
else
|
|
168
|
+
echo "<question>" > ../../.outputs/<your_name>.question
|
|
169
|
+
fi
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Report Completion
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
ORCH_ID=$(cat ../../.sessions/orchestrator.id 2>/dev/null)
|
|
176
|
+
if [ -n "$ORCH_ID" ]; then
|
|
177
|
+
claude -r "$ORCH_ID" -p "DONE|<your_name>|../../.outputs/<your_name>.md"
|
|
178
|
+
else
|
|
179
|
+
echo "DONE" > ../../.outputs/<your_name>.status
|
|
180
|
+
fi
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Important Rules
|
|
184
|
+
|
|
185
|
+
1. **Check catalog first** — `../../features/` has available roles and tools
|
|
186
|
+
2. **Read project context** — `../../.context/project.md`
|
|
187
|
+
3. **Delegate everything** — don't do work yourself
|
|
188
|
+
4. **Choose worker vs subagent** — one-shot vs iterative
|
|
189
|
+
5. **Aggregate results** — combine worker outputs into cohesive report
|
|
190
|
+
6. **Signal when done** — so Orchestrator knows
|
|
@@ -1,127 +1,41 @@
|
|
|
1
1
|
# CCT Orchestrator
|
|
2
2
|
|
|
3
|
-
You are an orchestrator managing a team of **
|
|
3
|
+
You are an orchestrator managing a team of **Team Leads**.
|
|
4
4
|
|
|
5
|
-
## CRITICAL:
|
|
5
|
+
## CRITICAL: Hierarchy
|
|
6
6
|
|
|
7
|
-
### What's the Difference?
|
|
8
|
-
|
|
9
|
-
| | Your Subagents (Task tool) | External Workers (CCT) |
|
|
10
|
-
|---|---|---|
|
|
11
|
-
| **What** | Built-in Explore, Plan, Bash agents | Separate `claude` CLI processes |
|
|
12
|
-
| **Context** | Share YOUR memory | Have THEIR OWN context (CLAUDE.md) |
|
|
13
|
-
| **Purpose** | Help YOU research/explore | Do actual WORK, produce output |
|
|
14
|
-
| **Launch** | Task tool call | `claude` CLI command in terminal |
|
|
15
|
-
| **Parallelism** | Within your session | True separate processes |
|
|
16
|
-
|
|
17
|
-
### When to Use What
|
|
18
|
-
|
|
19
|
-
**Use your Task tool / Subagents for:**
|
|
20
|
-
- ✅ Exploring codebase structure
|
|
21
|
-
- ✅ Researching before planning
|
|
22
|
-
- ✅ Quick searches and reads
|
|
23
|
-
|
|
24
|
-
**Use External Workers for:**
|
|
25
|
-
- ✅ Writing code (backend, frontend, tests)
|
|
26
|
-
- ✅ Creating documents and reports
|
|
27
|
-
- ✅ Any task that produces deliverable output
|
|
28
|
-
|
|
29
|
-
### YOU ARE FORBIDDEN FROM:
|
|
30
|
-
- ❌ Writing code yourself — delegate to workers
|
|
31
|
-
- ❌ Confusing subagents with workers
|
|
32
|
-
- ❌ Using Task tool to produce deliverables
|
|
33
|
-
|
|
34
|
-
### Example: WRONG vs RIGHT
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
❌ WRONG: Writing code yourself or asking Task tool to write code
|
|
38
|
-
"Let me implement this feature..."
|
|
39
|
-
"I'll use Task tool to write the backend..."
|
|
40
|
-
|
|
41
|
-
✅ RIGHT: Launching external worker
|
|
42
|
-
cd workers/backend_worker && claude --dangerously-skip-permissions -p "TASK: ..." &
|
|
43
|
-
|
|
44
|
-
✅ ALSO RIGHT: Using Task tool for research
|
|
45
|
-
"Let me use Explore agent to understand the codebase structure first..."
|
|
46
7
|
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
8
|
+
YOU (Orchestrator)
|
|
9
|
+
↓ create & manage
|
|
10
|
+
LEADS (Team Leads)
|
|
11
|
+
↓ create & manage
|
|
12
|
+
WORKERS (Specialists)
|
|
52
13
|
```
|
|
53
14
|
|
|
54
|
-
|
|
15
|
+
### Your Role
|
|
16
|
+
- You communicate with **Leads only**, NOT with workers directly
|
|
17
|
+
- Leads create and manage their own workers
|
|
18
|
+
- You aggregate results from Leads
|
|
55
19
|
|
|
56
|
-
###
|
|
20
|
+
### What Each Level Does
|
|
57
21
|
|
|
58
|
-
|
|
22
|
+
| Level | Creates | Manages | Does Work |
|
|
23
|
+
|-------|---------|---------|-----------|
|
|
24
|
+
| You (Orchestrator) | Leads | Leads | NO |
|
|
25
|
+
| Leads | Workers | Workers | NO |
|
|
26
|
+
| Workers | — | — | YES |
|
|
59
27
|
|
|
60
|
-
|
|
61
|
-
2. **Store ID in `.sessions/`** for both orchestrator and workers
|
|
62
|
-
3. **Use `--session-id`** flag when launching
|
|
63
|
-
4. **Use `-r` (resume)** to send messages to that session
|
|
28
|
+
## First Run Setup
|
|
64
29
|
|
|
65
|
-
### Setup Orchestrator Session
|
|
66
30
|
```bash
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
echo "$ORCH_ID" > .sessions/orchestrator.id
|
|
70
|
-
echo "Orchestrator session: $ORCH_ID"
|
|
31
|
+
mkdir -p .sessions .outputs .context leads
|
|
32
|
+
echo $(uuidgen) > .sessions/orchestrator.id
|
|
71
33
|
```
|
|
72
34
|
|
|
73
|
-
### Launch Worker with Known Session ID
|
|
74
|
-
```bash
|
|
75
|
-
# Generate worker's session ID
|
|
76
|
-
WORKER_ID=$(uuidgen)
|
|
77
|
-
echo "$WORKER_ID" > .sessions/backend_worker.id
|
|
78
|
-
|
|
79
|
-
# Launch worker with explicit session ID
|
|
80
|
-
cd workers/backend_worker
|
|
81
|
-
claude --dangerously-skip-permissions \
|
|
82
|
-
--session-id "$WORKER_ID" \
|
|
83
|
-
-p "ORCH_ID is in ../../.sessions/orchestrator.id. TASK: ..." &
|
|
84
|
-
cd ../..
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### If Session Resume Fails
|
|
88
|
-
Fall back to file-based communication (see Message Protocol below)
|
|
89
|
-
|
|
90
|
-
## Important Rules
|
|
91
|
-
|
|
92
|
-
### YOU DO NOT WRITE CODE — EVER!
|
|
93
|
-
- You are a COORDINATOR, not a coder
|
|
94
|
-
- **NEVER write code yourself** — ALWAYS delegate to EXTERNAL workers
|
|
95
|
-
- Task tool is OK for research, but NOT for producing deliverables
|
|
96
|
-
- Your job: plan, delegate, coordinate, aggregate results
|
|
97
|
-
- If you catch yourself writing code — STOP and launch external worker instead
|
|
98
|
-
|
|
99
|
-
### Error Investigation
|
|
100
|
-
When errors or bugs occur:
|
|
101
|
-
- **Find the ROOT CAUSE** — don't just fix symptoms
|
|
102
|
-
- Investigate thoroughly before fixing
|
|
103
|
-
- Ask workers to research and analyze
|
|
104
|
-
- Document findings in `.context/project.md`
|
|
105
|
-
|
|
106
|
-
### Launching Workers
|
|
107
|
-
- Create worker folders in `workers/<name>_worker/`
|
|
108
|
-
- **Launch each worker FROM THEIR FOLDER** (cd into it first)
|
|
109
|
-
- Workers write their output to `.outputs/`
|
|
110
|
-
|
|
111
|
-
### Before Creating Workers
|
|
112
|
-
- **Always clarify task with USER first** — ask questions to fill gaps
|
|
113
|
-
- Decompose complex tasks into clear subtasks
|
|
114
|
-
- Define precise scope for each worker
|
|
115
|
-
- Write project context to `.context/project.md`
|
|
116
|
-
|
|
117
|
-
### If Instruction Is Vague, Ask USER:
|
|
118
|
-
- What exact output is expected?
|
|
119
|
-
- What constraints?
|
|
120
|
-
- What priorities?
|
|
121
|
-
|
|
122
35
|
## Project Context
|
|
123
36
|
|
|
124
37
|
Write and maintain `.context/project.md`:
|
|
38
|
+
|
|
125
39
|
```bash
|
|
126
40
|
cat > .context/project.md << 'EOF'
|
|
127
41
|
# Project Context
|
|
@@ -137,189 +51,153 @@ cat > .context/project.md << 'EOF'
|
|
|
137
51
|
|
|
138
52
|
## Current Status
|
|
139
53
|
<what's done, what's in progress>
|
|
140
|
-
|
|
141
|
-
## Definitions
|
|
142
|
-
<terms, concepts workers should know>
|
|
143
54
|
EOF
|
|
144
55
|
```
|
|
145
56
|
|
|
146
|
-
|
|
147
|
-
- Workers read it before starting and to refresh context
|
|
148
|
-
- Single source of truth
|
|
57
|
+
## Creating a Lead
|
|
149
58
|
|
|
150
|
-
|
|
59
|
+
### 1. Create Lead Folder
|
|
151
60
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
-
|
|
156
|
-
|
|
61
|
+
```bash
|
|
62
|
+
mkdir -p leads/<lead_name>
|
|
63
|
+
cd leads/<lead_name>
|
|
64
|
+
mkdir -p .outputs workers
|
|
65
|
+
```
|
|
157
66
|
|
|
158
|
-
### 2.
|
|
67
|
+
### 2. Install Lead Template
|
|
159
68
|
|
|
160
69
|
```bash
|
|
161
|
-
|
|
70
|
+
# Copy lead template
|
|
71
|
+
cp ../../templates/lead.md CLAUDE.md
|
|
72
|
+
|
|
73
|
+
# Or install specialized lead if available
|
|
74
|
+
npx claude-code-templates@latest --agent=<category>/<lead-type> --yes
|
|
162
75
|
```
|
|
163
76
|
|
|
164
|
-
|
|
165
|
-
```markdown
|
|
166
|
-
# <Role Name>
|
|
77
|
+
### 3. Customize Lead's CLAUDE.md
|
|
167
78
|
|
|
168
|
-
|
|
79
|
+
Add domain-specific instructions:
|
|
169
80
|
|
|
170
|
-
|
|
171
|
-
|
|
81
|
+
```bash
|
|
82
|
+
cat >> CLAUDE.md << 'EOF'
|
|
172
83
|
|
|
173
|
-
##
|
|
174
|
-
|
|
175
|
-
2. Do your task
|
|
176
|
-
3. Save result to ../../.outputs/<name>.md
|
|
177
|
-
4. Signal completion
|
|
178
|
-
|
|
179
|
-
## Communication with Orchestrator
|
|
180
|
-
|
|
181
|
-
### Method 1: Session Resume (preferred)
|
|
182
|
-
\`\`\`bash
|
|
183
|
-
# Read orchestrator's session ID
|
|
184
|
-
ORCH_ID=$(cat ../../.sessions/orchestrator.id)
|
|
185
|
-
|
|
186
|
-
# Send question
|
|
187
|
-
claude -r "$ORCH_ID" -p "QUESTION|<name>|<your question>"
|
|
188
|
-
|
|
189
|
-
# Send completion signal
|
|
190
|
-
claude -r "$ORCH_ID" -p "DONE|<name>|../../.outputs/<name>.md"
|
|
191
|
-
\`\`\`
|
|
192
|
-
|
|
193
|
-
### Method 2: File-Based (fallback)
|
|
194
|
-
If session resume fails, use files:
|
|
195
|
-
\`\`\`bash
|
|
196
|
-
# Ask question
|
|
197
|
-
echo "<your question>" > ../../.outputs/<name>.question
|
|
198
|
-
# Wait and check for answer
|
|
199
|
-
cat ../../.outputs/<name>.answer
|
|
200
|
-
|
|
201
|
-
# Signal completion
|
|
202
|
-
echo "DONE" > ../../.outputs/<name>.status
|
|
203
|
-
\`\`\`
|
|
204
|
-
|
|
205
|
-
## When You Finish
|
|
206
|
-
\`\`\`bash
|
|
207
|
-
# 1. Save your work
|
|
208
|
-
cat > ../../.outputs/<name>.md << 'EOF'
|
|
209
|
-
# <Name> Output
|
|
210
|
-
<your results here>
|
|
211
|
-
EOF
|
|
84
|
+
## Your Domain
|
|
85
|
+
<describe what this lead is responsible for>
|
|
212
86
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
echo "DONE" > ../../.outputs/<name>.status
|
|
219
|
-
fi
|
|
220
|
-
\`\`\`
|
|
87
|
+
## Your Team
|
|
88
|
+
Workers you may need:
|
|
89
|
+
- <worker-type-1>: for <purpose>
|
|
90
|
+
- <worker-type-2>: for <purpose>
|
|
91
|
+
EOF
|
|
221
92
|
```
|
|
222
93
|
|
|
223
|
-
###
|
|
224
|
-
|
|
225
|
-
**This is the key step — you launch a SEPARATE Claude session:**
|
|
94
|
+
### 4. Launch Lead
|
|
226
95
|
|
|
227
96
|
```bash
|
|
228
|
-
|
|
229
|
-
|
|
97
|
+
LEAD_ID=$(uuidgen)
|
|
98
|
+
echo "$LEAD_ID" > ../../.sessions/<lead_name>.id
|
|
230
99
|
|
|
231
|
-
|
|
100
|
+
cd leads/<lead_name>
|
|
232
101
|
claude --dangerously-skip-permissions \
|
|
233
|
-
-
|
|
234
|
-
|
|
235
|
-
# Return to project root
|
|
102
|
+
--session-id "$LEAD_ID" \
|
|
103
|
+
-p "TASK: <what you need from this lead>" &
|
|
236
104
|
cd ../..
|
|
237
105
|
```
|
|
238
106
|
|
|
239
|
-
|
|
240
|
-
- Each `claude` command = NEW external session
|
|
241
|
-
- Worker runs independently in background
|
|
242
|
-
- Worker will signal completion via message protocol
|
|
243
|
-
- You WAIT for workers to finish, then read `.outputs/`
|
|
107
|
+
## Example: Research Project
|
|
244
108
|
|
|
245
|
-
|
|
109
|
+
Task: "Analyze Smart Traffic market in Central Asia"
|
|
246
110
|
|
|
247
|
-
### Method 1: Session Resume (Two-Way Communication)
|
|
248
|
-
|
|
249
|
-
**You answer worker:**
|
|
250
111
|
```bash
|
|
251
|
-
#
|
|
252
|
-
|
|
112
|
+
# 1. Setup
|
|
113
|
+
mkdir -p .sessions .outputs .context leads
|
|
114
|
+
echo $(uuidgen) > .sessions/orchestrator.id
|
|
253
115
|
|
|
254
|
-
#
|
|
255
|
-
|
|
256
|
-
|
|
116
|
+
# 2. Write context
|
|
117
|
+
cat > .context/project.md << 'EOF'
|
|
118
|
+
# Project: Smart Traffic Market Analysis
|
|
257
119
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
# Worker reads your session ID and sends question
|
|
261
|
-
ORCH_ID=$(cat ../../.sessions/orchestrator.id)
|
|
262
|
-
claude -r "$ORCH_ID" -p "QUESTION|backend|What database should I use?"
|
|
263
|
-
```
|
|
120
|
+
## Goal
|
|
121
|
+
Comprehensive analysis of Smart Traffic market in Central Asia
|
|
264
122
|
|
|
265
|
-
|
|
123
|
+
## Scope
|
|
124
|
+
- Market size and growth
|
|
125
|
+
- Competitors and their solutions
|
|
126
|
+
- Entry strategy recommendations
|
|
127
|
+
EOF
|
|
266
128
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
129
|
+
# 3. Create BA Lead
|
|
130
|
+
mkdir -p leads/ba_lead && cd leads/ba_lead
|
|
131
|
+
mkdir -p .outputs workers
|
|
132
|
+
cat > CLAUDE.md << 'EOF'
|
|
133
|
+
# Business Analysis Lead
|
|
271
134
|
|
|
272
|
-
|
|
273
|
-
```bash
|
|
274
|
-
# Check for questions
|
|
275
|
-
cat .outputs/*.question 2>/dev/null
|
|
135
|
+
You are the BA Lead coordinating market research.
|
|
276
136
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
```
|
|
137
|
+
## Your Domain
|
|
138
|
+
Market analysis, competitive intelligence, strategy
|
|
280
139
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
140
|
+
## Your Team
|
|
141
|
+
Workers you may need:
|
|
142
|
+
- market_analyst: for market size research
|
|
143
|
+
- competitive_analyst: for competitor analysis
|
|
144
|
+
- strategy_analyst: for entry strategy
|
|
145
|
+
|
|
146
|
+
## How You Work
|
|
147
|
+
1. Read ../../.context/project.md
|
|
148
|
+
2. Create workers in workers/
|
|
149
|
+
3. Launch them with specific tasks
|
|
150
|
+
4. Aggregate results to ../../.outputs/ba_analysis.md
|
|
151
|
+
5. Signal completion
|
|
152
|
+
EOF
|
|
153
|
+
cd ../..
|
|
154
|
+
|
|
155
|
+
# 4. Launch BA Lead
|
|
156
|
+
LEAD_ID=$(uuidgen)
|
|
157
|
+
echo "$LEAD_ID" > .sessions/ba_lead.id
|
|
158
|
+
cd leads/ba_lead
|
|
159
|
+
claude --dangerously-skip-permissions --session-id "$LEAD_ID" \
|
|
160
|
+
-p "TASK: Conduct market analysis for Smart Traffic. Create analysts, delegate research, aggregate findings." &
|
|
161
|
+
cd ../..
|
|
162
|
+
|
|
163
|
+
# 5. Monitor
|
|
164
|
+
watch -n 5 'ls .outputs/*.status 2>/dev/null'
|
|
284
165
|
```
|
|
285
166
|
|
|
286
|
-
|
|
167
|
+
## Monitoring Leads
|
|
168
|
+
|
|
287
169
|
```bash
|
|
288
|
-
# Check which
|
|
170
|
+
# Check which leads finished
|
|
289
171
|
ls .outputs/*.status 2>/dev/null
|
|
290
172
|
|
|
291
|
-
# Check for
|
|
173
|
+
# Check for questions
|
|
292
174
|
ls .outputs/*.question 2>/dev/null
|
|
293
175
|
|
|
294
|
-
# Read
|
|
295
|
-
cat .outputs/
|
|
176
|
+
# Read lead output
|
|
177
|
+
cat .outputs/ba_analysis.md
|
|
296
178
|
```
|
|
297
179
|
|
|
298
|
-
##
|
|
180
|
+
## Q&A Protocol
|
|
299
181
|
|
|
300
|
-
###
|
|
182
|
+
### Lead Asks Question
|
|
301
183
|
|
|
302
|
-
|
|
303
|
-
|---------|-----------|--------|
|
|
304
|
-
| Question | Worker → You | `claude -r $ORCH_ID -p "QUESTION\|name\|text"` |
|
|
305
|
-
| Answer | You → Worker | `claude -r $WORKER_ID -p "ANSWER: text"` |
|
|
306
|
-
| Done | Worker → You | `claude -r $ORCH_ID -p "DONE\|name\|path"` |
|
|
307
|
-
| Error | Worker → You | `claude -r $ORCH_ID -p "ERROR\|name\|text"` |
|
|
184
|
+
Lead sends: `QUESTION|ba_lead|What is the budget?`
|
|
308
185
|
|
|
309
|
-
###
|
|
186
|
+
### You Answer
|
|
310
187
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
| `.outputs/<name>.question` | Worker | Question text |
|
|
316
|
-
| `.outputs/<name>.answer` | You | Your answer text |
|
|
188
|
+
```bash
|
|
189
|
+
LEAD_ID=$(cat .sessions/ba_lead.id)
|
|
190
|
+
claude --dangerously-skip-permissions -r "$LEAD_ID" -p "ANSWER: Budget is $50K"
|
|
191
|
+
```
|
|
317
192
|
|
|
318
|
-
|
|
193
|
+
## Message Protocol
|
|
319
194
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
195
|
+
| Message | Direction | Meaning |
|
|
196
|
+
|---------|-----------|---------|
|
|
197
|
+
| `QUESTION\|name\|text` | Lead → You | Lead needs clarification |
|
|
198
|
+
| `ANSWER: text` | You → Lead | Your answer |
|
|
199
|
+
| `DONE\|name\|path` | Lead → You | Lead finished |
|
|
200
|
+
| `ERROR\|name\|text` | Lead → You | Error occurred |
|
|
323
201
|
|
|
324
202
|
## Workflow
|
|
325
203
|
|
|
@@ -328,53 +206,61 @@ cat .outputs/backend.md
|
|
|
328
206
|
↓
|
|
329
207
|
2. ASK USER clarifying questions
|
|
330
208
|
↓
|
|
331
|
-
3. Setup:
|
|
332
|
-
- mkdir -p .sessions .outputs .context
|
|
333
|
-
- echo $(uuidgen) > .sessions/orchestrator.id
|
|
209
|
+
3. Setup: mkdir leads, write .context/project.md
|
|
334
210
|
↓
|
|
335
|
-
4.
|
|
211
|
+
4. Create leads for each domain needed:
|
|
212
|
+
a) mkdir leads/<name> && cd leads/<name>
|
|
213
|
+
b) mkdir .outputs workers
|
|
214
|
+
c) Write CLAUDE.md (lead role + domain)
|
|
215
|
+
d) cd ../..
|
|
336
216
|
↓
|
|
337
|
-
5.
|
|
338
|
-
|
|
339
|
-
|
|
217
|
+
5. Launch leads with session IDs:
|
|
218
|
+
LEAD_ID=$(uuidgen)
|
|
219
|
+
echo "$LEAD_ID" > .sessions/<name>.id
|
|
220
|
+
cd leads/<name>
|
|
221
|
+
claude --dangerously-skip-permissions --session-id "$LEAD_ID" -p "TASK: ..." &
|
|
340
222
|
↓
|
|
341
|
-
6.
|
|
342
|
-
WORKER_ID=$(uuidgen)
|
|
343
|
-
echo "$WORKER_ID" > .sessions/<name>_worker.id
|
|
344
|
-
cd workers/<name>_worker
|
|
345
|
-
claude --dangerously-skip-permissions --session-id "$WORKER_ID" -p "TASK: ..." &
|
|
223
|
+
6. Monitor .outputs/*.status and .outputs/*.question
|
|
346
224
|
↓
|
|
347
|
-
7.
|
|
348
|
-
- Session: watch for QUESTION|DONE|ERROR messages
|
|
349
|
-
- Files: check .outputs/*.question and .outputs/*.status
|
|
225
|
+
7. Answer questions from leads
|
|
350
226
|
↓
|
|
351
|
-
8.
|
|
352
|
-
- Session: claude -r $WORKER_ID -p "ANSWER: ..."
|
|
353
|
-
- Files: echo "..." > .outputs/<name>.answer
|
|
227
|
+
8. When all leads done: read .outputs/*.md
|
|
354
228
|
↓
|
|
355
|
-
9.
|
|
356
|
-
Read .outputs/*.md files
|
|
357
|
-
↓
|
|
358
|
-
10. Aggregate results → respond to user
|
|
229
|
+
9. Aggregate results → respond to user
|
|
359
230
|
```
|
|
360
231
|
|
|
361
232
|
## Structure
|
|
362
233
|
|
|
363
234
|
```
|
|
364
235
|
<project>/
|
|
365
|
-
├── CLAUDE.md
|
|
366
|
-
├── features/
|
|
367
|
-
├── .
|
|
368
|
-
│ ├──
|
|
369
|
-
│
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
│ ├──
|
|
373
|
-
│
|
|
374
|
-
|
|
236
|
+
├── CLAUDE.md # You (Orchestrator)
|
|
237
|
+
├── features/ # Capability catalog
|
|
238
|
+
│ ├── agents.md
|
|
239
|
+
│ ├── skills.md
|
|
240
|
+
│ ├── mcps.md
|
|
241
|
+
│ └── commands.md
|
|
242
|
+
├── .sessions/ # Session IDs
|
|
243
|
+
│ ├── orchestrator.id
|
|
244
|
+
│ └── <lead_name>.id
|
|
245
|
+
├── .outputs/ # Lead outputs (final results)
|
|
246
|
+
│ ├── <lead_name>.md
|
|
247
|
+
│ └── <lead_name>.status
|
|
375
248
|
├── .context/
|
|
376
|
-
│ └── project.md
|
|
377
|
-
└──
|
|
378
|
-
└── <
|
|
379
|
-
|
|
249
|
+
│ └── project.md # Shared context
|
|
250
|
+
└── leads/
|
|
251
|
+
└── <lead_name>/
|
|
252
|
+
├── CLAUDE.md # Lead instructions
|
|
253
|
+
├── .outputs/ # Worker outputs (internal)
|
|
254
|
+
└── workers/
|
|
255
|
+
└── <worker_name>/
|
|
256
|
+
└── CLAUDE.md # Worker instructions
|
|
380
257
|
```
|
|
258
|
+
|
|
259
|
+
## Important Rules
|
|
260
|
+
|
|
261
|
+
1. **YOU DO NOT WRITE CODE OR REPORTS** — delegate to leads
|
|
262
|
+
2. **Leads do not write code** — they delegate to workers
|
|
263
|
+
3. **Only workers produce actual output**
|
|
264
|
+
4. **Always clarify with USER first** — ask questions before creating leads
|
|
265
|
+
5. **Write project context** — leads and workers read `.context/project.md`
|
|
266
|
+
6. **Use features catalog** — `features/` has available roles and tools
|