Skip to content

Commit 88ea7fc

Browse files
catlog22claude
andcommitted
refactor: deep Codex v4 API conversion for all 20 team skills
Upgrade all team-* skills from mechanical v3→v4 API renames to deep v4 tool integration with skill-adaptive patterns: - list_agents: health checks in handleResume, cleanup verification in handleComplete, added to allowed-tools and coordinator toolbox - Named targeting: task_name uses task-id (e.g. EXPLORE-001) instead of generic <role>-worker, enabling send_message/assign_task by name - Message semantics: send_message for supplementary cross-agent context vs assign_task for triggering work, with skill-specific examples - Model selection: per-role reasoning_effort guidance matching each skill's actual roles (not generic boilerplate) - timeout_ms: added to all wait_agent calls, timed_out handling in all 18 monitor.md files - Skill-adaptive v4 sections: ultra-analyze N-parallel coordination, lifecycle-v4 supervisor assign_task/send_message distinction, brainstorm ideator parallel patterns, iterdev generator-critic loops, frontend-debug iterative debug assign_task, perf-opt benchmark context sharing, executor lightweight trimmed v4, etc. 60 files changed across 20 team skills (SKILL.md, monitor.md, role.md) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3d39ac6 commit 88ea7fc

60 files changed

Lines changed: 2318 additions & 215 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codex/skills/team-arch-opt/SKILL.md

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: team-arch-opt
33
description: Unified team skill for architecture optimization. Uses team-worker agent architecture with role directories for domain logic. Coordinator orchestrates pipeline, workers are team-worker agents. Triggers on "team arch-opt".
4-
allowed-tools: spawn_agent(*), wait_agent(*), send_input(*), close_agent(*), report_agent_job_result(*), request_user_input(*), Read(*), Write(*), Edit(*), Bash(*), Glob(*), Grep(*), mcp__ace-tool__search_context(*)
4+
allowed-tools: spawn_agent(*), wait_agent(*), send_message(*), assign_task(*), close_agent(*), list_agents(*), report_agent_job_result(*), request_user_input(*), Read(*), Write(*), Edit(*), Bash(*), Glob(*), Grep(*), mcp__ace-tool__search_context(*)
55
---
66

77
# Team Architecture Optimization
@@ -54,7 +54,8 @@ Before calling ANY tool, apply this check:
5454

5555
| Tool Call | Verdict | Reason |
5656
|-----------|---------|--------|
57-
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
57+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_message`, `assign_task` | ALLOWED | Orchestration |
58+
| `list_agents` | ALLOWED | Agent health check |
5859
| `request_user_input` | ALLOWED | User interaction |
5960
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
6061
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
@@ -84,6 +85,8 @@ Coordinator spawns workers using this template:
8485
```
8586
spawn_agent({
8687
agent_type: "team_worker",
88+
task_name: "<task-id>",
89+
fork_context: false,
8790
items: [
8891
{ type: "text", text: `## Role Assignment
8992
role: <role>
@@ -107,11 +110,34 @@ pipeline_phase: <pipeline-phase>` },
107110
})
108111
```
109112

110-
After spawning, use `wait_agent({ ids: [...], timeout_ms: 900000 })` to collect results, then `close_agent({ id })` each worker.
113+
After spawning, use `wait_agent({ targets: [...], timeout_ms: 900000 })` to collect results, then `close_agent({ target: <name> })` each worker.
111114

112115
**Inner Loop roles** (refactorer): Set `inner_loop: true`.
113116
**Single-task roles** (analyzer, designer, validator, reviewer): Set `inner_loop: false`.
114117

118+
### Model Selection Guide
119+
120+
Architecture optimization is reasoning-intensive. All analysis and design roles need high reasoning effort.
121+
122+
| Role | reasoning_effort | Rationale |
123+
|------|-------------------|-----------|
124+
| analyzer | high | Deep structural analysis of codebase architecture |
125+
| designer | high | Architecture redesign requires careful reasoning about tradeoffs |
126+
| refactorer | high | Code transformations must preserve correctness |
127+
| validator | high | Validation must thoroughly check refactoring correctness |
128+
| reviewer | high | Code quality review demands deep understanding |
129+
130+
Override in spawn_agent when needed:
131+
```
132+
spawn_agent({
133+
agent_type: "team_worker",
134+
task_name: "<task-id>",
135+
fork_context: false,
136+
reasoning_effort: "high",
137+
items: [...]
138+
})
139+
```
140+
115141
## User Commands
116142

117143
| Command | Action |
@@ -161,6 +187,47 @@ After spawning, use `wait_agent({ ids: [...], timeout_ms: 900000 })` to collect
161187

162188
- [specs/pipelines.md](specs/pipelines.md) — Pipeline definitions, task registry, parallel modes
163189

190+
## v4 Agent Coordination
191+
192+
### Message Semantics
193+
194+
| Intent | API | Example |
195+
|--------|-----|---------|
196+
| Queue supplementary info (don't interrupt) | `send_message` | Send codebase patterns to running analyzer |
197+
| Assign new work / trigger processing | `assign_task` | Assign fix task to refactorer after review feedback |
198+
| Check running agents | `list_agents` | Verify agent health during resume |
199+
200+
### Agent Health Check
201+
202+
Use `list_agents({})` in handleResume and handleComplete:
203+
204+
```
205+
// Reconcile session state with actual running agents
206+
const running = list_agents({})
207+
// Compare with session.json active tasks
208+
// Reset orphaned tasks (in_progress but agent gone) to pending
209+
```
210+
211+
### Named Agent Targeting
212+
213+
Workers are spawned with `task_name: "<task-id>"` enabling direct addressing:
214+
- `send_message({ target: "ANALYZE-001", items: [...] })` -- queue analysis context without interrupting
215+
- `assign_task({ target: "REFACTOR-001", items: [...] })` -- assign fix task after review feedback
216+
- `close_agent({ target: "VALIDATE-001" })` -- cleanup by name
217+
218+
### Merged Exploration Pattern
219+
220+
For architecture analysis, analyzer may need broad codebase exploration. Consider spawning analyzer with `fork_context: true` when deep structural analysis of interconnected modules is needed:
221+
```
222+
spawn_agent({
223+
agent_type: "team_worker",
224+
task_name: "ANALYZE-001",
225+
fork_context: true, // Share coordinator's codebase context
226+
reasoning_effort: "high",
227+
items: [...]
228+
})
229+
```
230+
164231
## Error Handling
165232

166233
| Scenario | Resolution |

.codex/skills/team-arch-opt/roles/coordinator/commands/monitor.md

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ Fan-out mode adds per-branch grouping. Independent mode adds per-pipeline groupi
4141

4242
## handleResume
4343

44+
**Agent Health Check** (v4):
45+
```
46+
// Verify actual running agents match session state
47+
const runningAgents = list_agents({})
48+
// For each active_agent in tasks.json:
49+
// - If agent NOT in runningAgents -> agent crashed
50+
// - Reset that task to pending, remove from active_agents
51+
// This prevents stale agent references from blocking the pipeline
52+
```
53+
4454
1. Read tasks.json, check active_agents
4555
2. No active agents -> handleSpawnNext
4656
3. Has active agents -> check each status
@@ -74,6 +84,7 @@ state.tasks[taskId].status = 'in_progress'
7484
// 2) Spawn worker
7585
const agentId = spawn_agent({
7686
agent_type: "team_worker",
87+
task_name: taskId, // e.g., "DESIGN-001" — enables named targeting
7788
items: [
7889
{ type: "text", text: `## Role Assignment
7990
role: ${task.role}
@@ -109,20 +120,43 @@ state.active_agents[taskId] = { agentId, role: task.role, started_at: now }
109120
| Fan-out (REFACTOR-B{NN} done) | VALIDATE + REVIEW ready | Spawn both for that branch in parallel |
110121
| Independent | Any unblocked task | Spawn all ready tasks across all pipelines in parallel |
111122

123+
**Cross-Agent Supplementary Context** (v4):
124+
125+
When spawning workers in a later pipeline phase, send upstream results as supplementary context to already-running workers:
126+
127+
```
128+
// Example: Send design analysis results to running refactorers
129+
send_message({
130+
target: "<running-agent-task-name>",
131+
items: [{ type: "text", text: `## Supplementary Context\n${upstreamFindings}` }]
132+
})
133+
// Note: send_message queues info without interrupting the agent's current work
134+
```
135+
136+
Use `send_message` (not `assign_task`) for supplementary info that enriches but doesn't redirect the agent's current task.
137+
112138
### Wait and Process Results
113139

114140
After spawning all ready tasks:
115141

116142
```javascript
117-
// 4) Batch wait for all spawned workers
118-
const agentIds = Object.values(state.active_agents).map(a => a.agentId)
119-
wait_agent({ ids: agentIds, timeout_ms: 900000 })
120-
121-
// 5) Collect results
122-
for (const [taskId, agent] of Object.entries(state.active_agents)) {
123-
state.tasks[taskId].status = 'completed'
124-
close_agent({ id: agent.agentId })
125-
delete state.active_agents[taskId]
143+
// 4) Batch wait — use task_name for stable targeting (v4)
144+
const taskNames = Object.keys(state.active_agents)
145+
const waitResult = wait_agent({ targets: taskNames, timeout_ms: 900000 })
146+
if (waitResult.timed_out) {
147+
// Mark timed-out agents, close them, report to user
148+
for (const taskId of taskNames) {
149+
state.tasks[taskId].status = 'timed_out'
150+
close_agent({ target: taskId })
151+
delete state.active_agents[taskId]
152+
}
153+
} else {
154+
// 5) Collect results
155+
for (const [taskId, agent] of Object.entries(state.active_agents)) {
156+
state.tasks[taskId].status = 'completed'
157+
close_agent({ target: taskId }) // Use task_name, not agentId
158+
delete state.active_agents[taskId]
159+
}
126160
}
127161
```
128162

@@ -159,6 +193,14 @@ Fix cycle tracking per branch in tasks.json `fix_cycles`:
159193
160194
## handleComplete
161195

196+
**Cleanup Verification** (v4):
197+
```
198+
// Verify all agents are properly closed
199+
const remaining = list_agents({})
200+
// If any team agents still running -> close_agent each
201+
// Ensures clean session shutdown
202+
```
203+
162204
Pipeline done. Generate report and completion action.
163205

164206
Completion check by mode:

.codex/skills/team-arch-opt/roles/coordinator/role.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Orchestrate team-arch-opt: analyze -> dispatch -> spawn -> monitor -> report.
66

77
**You are a dispatcher, not a doer.** Your ONLY outputs are:
88
- Session state files (`.workflow/.team/` directory)
9-
- `spawn_agent` / `wait_agent` / `close_agent` / `send_input` calls
9+
- `spawn_agent` / `wait_agent` / `close_agent` / `send_message` / `assign_task` calls
1010
- Status reports to the user / `request_user_input` prompts
1111

1212
**FORBIDDEN** (even if the task seems trivial):
@@ -34,6 +34,8 @@ WRONG: Bash running build/test/lint commands — worker work
3434
- Handle review-fix cycles with max 3 iterations
3535
- Execute completion action in Phase 5
3636
- **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
37+
- Use `send_message` for supplementary context (non-interrupting) and `assign_task` for triggering new work
38+
- Use `list_agents` for session resume health checks and cleanup verification
3739

3840
### MUST NOT
3941
- Implement domain logic (analyzing, refactoring, reviewing) -- workers handle this
@@ -173,6 +175,16 @@ Delegate to @commands/monitor.md#handleSpawnNext:
173175
- auto_archive -> Archive & Clean (rm -rf session folder)
174176
- auto_keep -> Keep Active (status=paused)
175177

178+
## v4 Coordination Patterns
179+
180+
### Message Semantics
181+
- **send_message**: Queue supplementary info to a running agent. Does NOT interrupt current processing. Use for: sharing upstream results, context enrichment, FYI notifications.
182+
- **assign_task**: Assign new work and trigger processing. Use for: waking idle agents, redirecting work, requesting new output.
183+
184+
### Agent Lifecycle Management
185+
- **list_agents({})**: Returns all running agents. Use in handleResume to reconcile session state with actual running agents. Use in handleComplete to verify clean shutdown.
186+
- **Named targeting**: Workers spawned with `task_name: "<task-id>"` can be addressed by name in send_message, assign_task, and close_agent calls.
187+
176188
## Error Handling
177189

178190
| Error | Resolution |

.codex/skills/team-brainstorm/SKILL.md

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: team-brainstorm
33
description: Unified team skill for brainstorming team. Uses team-worker agent architecture with role directories for domain logic. Coordinator orchestrates pipeline, workers are team-worker agents. Triggers on "team brainstorm".
4-
allowed-tools: spawn_agent(*), wait_agent(*), send_input(*), close_agent(*), report_agent_job_result(*), request_user_input(*), Read(*), Write(*), Edit(*), Bash(*), Glob(*), Grep(*)
4+
allowed-tools: spawn_agent(*), wait_agent(*), send_message(*), assign_task(*), close_agent(*), list_agents(*), report_agent_job_result(*), request_user_input(*), Read(*), Write(*), Edit(*), Bash(*), Glob(*), Grep(*)
55
---
66

77
# Team Brainstorm
@@ -53,7 +53,8 @@ Before calling ANY tool, apply this check:
5353

5454
| Tool Call | Verdict | Reason |
5555
|-----------|---------|--------|
56-
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
56+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_message`, `assign_task` | ALLOWED | Orchestration |
57+
| `list_agents` | ALLOWED | Agent health check |
5758
| `request_user_input` | ALLOWED | User interaction |
5859
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
5960
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
@@ -83,6 +84,8 @@ Coordinator spawns workers using this template:
8384
```
8485
spawn_agent({
8586
agent_type: "team_worker",
87+
task_name: "<task-id>",
88+
fork_context: false,
8689
items: [
8790
{ type: "text", text: `## Role Assignment
8891
role: <role>
@@ -106,7 +109,7 @@ pipeline_phase: <pipeline-phase>` },
106109
})
107110
```
108111

109-
After spawning, use `wait_agent({ ids: [...], timeout_ms: 900000 })` to collect results, then `close_agent({ id })` each worker.
112+
After spawning, use `wait_agent({ targets: [...], timeout_ms: 900000 })` to collect results, then `close_agent({ target: <name> })` each worker.
110113

111114
**Parallel ideator spawn** (Full pipeline with N angles):
112115

@@ -115,6 +118,8 @@ When Full pipeline has N parallel IDEA tasks, spawn N distinct team-worker agent
115118
```
116119
spawn_agent({
117120
agent_type: "team_worker",
121+
task_name: "ideator-<N>",
122+
fork_context: false,
118123
items: [
119124
{ type: "text", text: `## Role Assignment
120125
role: ideator
@@ -139,7 +144,29 @@ pipeline_phase: <pipeline-phase>` },
139144
})
140145
```
141146

142-
After spawning, use `wait_agent({ ids: [...], timeout_ms: 900000 })` to collect results, then `close_agent({ id })` each worker.
147+
After spawning, use `wait_agent({ targets: [...], timeout_ms: 900000 })` to collect results, then `close_agent({ target: <name> })` each worker.
148+
149+
150+
### Model Selection Guide
151+
152+
| Role | model | reasoning_effort | Rationale |
153+
|------|-------|-------------------|-----------|
154+
| Ideator (IDEA-*) | (default) | high | Creative divergent thinking requires full reasoning |
155+
| Challenger (CHALLENGE-*) | (default) | high | Critical analysis of ideas needs deep reasoning |
156+
| Synthesizer (SYNTH-*) | (default) | medium | Aggregation and convergence over generation |
157+
| Evaluator (EVAL-*) | (default) | medium | Scoring and ranking against criteria |
158+
159+
Override model/reasoning_effort in spawn_agent when cost optimization is needed:
160+
```
161+
spawn_agent({
162+
agent_type: "team_worker",
163+
task_name: "<task-id>",
164+
fork_context: false,
165+
model: "<model-override>",
166+
reasoning_effort: "<effort-level>",
167+
items: [...]
168+
})
169+
```
143170

144171
## User Commands
145172

@@ -178,6 +205,47 @@ After spawning, use `wait_agent({ ids: [...], timeout_ms: 900000 })` to collect
178205

179206
- [specs/pipelines.md](specs/pipelines.md) — Pipeline definitions and task registry
180207

208+
## v4 Agent Coordination
209+
210+
### Message Semantics
211+
212+
| Intent | API | Example |
213+
|--------|-----|---------|
214+
| Share idea context across ideators | `send_message` | Send seed ideas to running ideator for cross-pollination |
215+
| Not used in this skill | `assign_task` | No resident agents -- all workers are one-shot |
216+
| Check running agents | `list_agents` | Verify parallel ideator health during Full pipeline |
217+
218+
### Parallel Ideator Coordination (Full Pipeline)
219+
220+
Full pipeline spawns N parallel ideators for different brainstorming angles. Use batch spawn + wait:
221+
222+
```
223+
// Spawn N ideators in parallel, each with a different angle
224+
const ideatorNames = ["IDEA-001", "IDEA-002", "IDEA-003"]
225+
for (const name of ideatorNames) {
226+
spawn_agent({ agent_type: "team_worker", task_name: name, fork_context: false, ... })
227+
}
228+
wait_agent({ targets: ideatorNames, timeout_ms: 900000 })
229+
// Collect all idea outputs, feed to challenger as upstream context
230+
```
231+
232+
### Agent Health Check
233+
234+
Use `list_agents({})` in handleResume and handleComplete:
235+
236+
```
237+
// Reconcile session state with actual running agents
238+
const running = list_agents({})
239+
// Compare with tasks.json active_agents
240+
// Reset orphaned tasks (in_progress but agent gone) to pending
241+
```
242+
243+
### Named Agent Targeting
244+
245+
Workers are spawned with `task_name: "<task-id>"` enabling direct addressing:
246+
- `send_message({ target: "IDEA-002", items: [...] })` -- share context from another ideator
247+
- `close_agent({ target: "IDEA-001" })` -- cleanup by name after wait_agent returns
248+
181249
## Error Handling
182250

183251
| Scenario | Resolution |

0 commit comments

Comments
 (0)