Skip to content

Commit d64eee1

Browse files
cahaselerclaude
andauthored
feat: integrate native task system for real-time orchestration (#186)
* feat: integrate native task system for real-time orchestration Add guidance for using Claude Code's native task tools (TaskCreate, TaskUpdate, TaskList) during phase execution: - Native tasks = session coordination layer (real-time tracking) - Markdown tasks.md = persistent record (survives compactions) Key changes to commands/tasks.md: - New "Real-Time Task Coordination" section explaining two-layer approach - TaskUpdate calls in sequential phase execution flow - TaskList usage for parallel phase dependency tracking Key changes to templates/tasks-template.md: - "Real-Time Coordination" section in Orchestration Model - Setup instructions for creating tasks with blockedBy dependencies - Updated sequential/parallel execution to use native task status - Checkpoint sync instructions for markdown persistence The blockedBy feature automatically enforces TDD order (can't start Tests until Stub completes) and surfaces ready-to-dispatch work via TaskList. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: standardize task naming and clarify sync timing - Use consistent short format "PN: Step" (e.g., "P1: Stub") for task names - Clarify markdown sync happens after each phase, not just at checkpoints - Replace "..." with explicit comment "(repeat pattern for each phase)" Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Craig Haseler <cahaseler@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 92798a4 commit d64eee1

File tree

2 files changed

+140
-28
lines changed

2 files changed

+140
-28
lines changed

commands/tasks.md

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,43 +193,109 @@ Phase 4 ──┘
193193
194194
When the user approves this task breakdown and says to begin implementation:
195195
196+
### Real-Time Task Coordination (Native Task System)
197+
198+
Use Claude Code's native task system (`TaskCreate`, `TaskUpdate`, `TaskList`) for **real-time coordination** during the session. The markdown `tasks.md` file remains the **persistent record**.
199+
200+
**Two-layer approach:**
201+
- **Native tasks** = Session coordination layer (tracks what's happening NOW)
202+
- **Markdown tasks.md** = Persistent record (survives compactions, documents history)
203+
204+
**At the start of each phase set:**
205+
1. Create native tasks for each step with proper dependencies:
206+
```
207+
TaskCreate: "P1: Stub" (description: files, exports needed)
208+
TaskCreate: "P1: Tests" (description: test requirements)
209+
TaskCreate: "P1: Implement" (description: make tests pass)
210+
TaskCreate: "P1: Validate" (description: verify requirements)
211+
212+
TaskUpdate: "P1: Tests" addBlockedBy: ["P1: Stub"]
213+
TaskUpdate: "P1: Implement" addBlockedBy: ["P1: Tests"]
214+
TaskUpdate: "P1: Validate" addBlockedBy: ["P1: Implement"]
215+
```
216+
217+
2. For parallel phases, create all tasks upfront with cross-phase dependencies:
218+
```
219+
# Phase 2 and 3 can run in parallel, but each has internal TDD order
220+
TaskUpdate: "P2: Tests" addBlockedBy: ["P2: Stub"]
221+
TaskUpdate: "P3: Tests" addBlockedBy: ["P3: Stub"]
222+
# Phase 4 depends on Phase 2 completing
223+
TaskUpdate: "P4: Stub" addBlockedBy: ["P2: Validate"]
224+
```
225+
226+
**During execution:**
227+
- `TaskUpdate` status to `in_progress` when dispatching a subagent
228+
- `TaskUpdate` status to `completed` when subagent returns successfully
229+
- Use `TaskList` to see what's unblocked and ready to dispatch
230+
231+
**After each phase (and at checkpoints):**
232+
- Sync native task completion back to markdown checkboxes in `tasks.md`
233+
- This ensures the persistent record is updated for context compaction
234+
235+
**Why this matters:**
236+
- Native `blockedBy` enforces TDD order automatically (can't start Tests until Stub completes)
237+
- `TaskList` shows exactly what's ready to dispatch vs. blocked
238+
- Status visible in Claude Code's UI
239+
- Markdown update at checkpoints preserves state across sessions
240+
196241
### For Sequential Phases
197242
198243
Dispatch subagents one at a time in TDD order:
199244
200245
1. **Stub Writer**:
201246
```
247+
TaskUpdate: "PN: Stub" status: in_progress
202248
Task tool with subagent_type: stub-writer
203249
Prompt: "Phase N: [Phase Name]. Create stubs for [files] with exports: [list exports needed]"
204250
```
205-
→ On success: Check off "Stub" checkbox in tasks.md
251+
→ On success: `TaskUpdate: "PN: Stub" status: completed`
206252
207253
2. **Test Writer** (after stub complete):
208254
```
255+
TaskUpdate: "PN: Tests" status: in_progress
209256
Task tool with subagent_type: test-generation
210257
Prompt: "Phase N: [Phase Name]. Write tests for [requirements]. Test files: [paths]. Run tests and report output."
211258
```
212-
→ On success: Check off "Tests" checkbox in tasks.md
259+
→ On success: `TaskUpdate: "PN: Tests" status: completed`
213260
214261
3. **Implementer** (after tests written and failing):
215262
```
263+
TaskUpdate: "PN: Implement" status: in_progress
216264
Task tool with subagent_type: implementer
217265
Prompt: "Phase N: [Phase Name]. Make tests pass. Implementation files: [paths]. Run tests and report output."
218266
```
219-
→ On success: Check off "Implement" checkbox in tasks.md
267+
→ On success: `TaskUpdate: "PN: Implement" status: completed`
220268
221269
4. **Validator** (after implementation):
222270
```
271+
TaskUpdate: "PN: Validate" status: in_progress
223272
Task tool with subagent_type: validator
224273
Prompt: "Phase N: [Phase Name]. Verify: [requirements from spec]. Run tests independently. Report pass/fail."
225274
```
226-
→ On success: Check off "Validate" checkbox in tasks.md
275+
→ On success: `TaskUpdate: "PN: Validate" status: completed`
227276
228-
**IMPORTANT**: Update tasks.md checkboxes immediately after each subagent returns successfully. This keeps progress visible and ensures state is preserved across context compactions.
277+
**After each phase completes**: Update tasks.md checkboxes to sync the persistent record. This ensures state is preserved across context compactions.
229278
230279
### For Parallel Phases and Dependency Enforcement
231280
232-
See `${CLAUDE_PLUGIN_ROOT}/templates/tasks-template.md` for the orchestration patterns (pipeline flow, polling fallback, dependency rules). These are included in the generated tasks.md and followed during execution.
281+
**Create all native tasks upfront** with `blockedBy` relationships:
282+
```
283+
# All stubs can start immediately (no blockers)
284+
TaskCreate: "P2: Stub", "P3: Stub", "P4: Stub"
285+
286+
# Tests blocked by their phase's stub
287+
TaskUpdate: "P2: Tests" addBlockedBy: ["P2: Stub"]
288+
TaskUpdate: "P3: Tests" addBlockedBy: ["P3: Stub"]
289+
290+
# Implement blocked by tests, Validate blocked by implement
291+
# (repeat pattern for each phase)
292+
```
293+
294+
**Use `TaskList`** to see what's unblocked and ready to dispatch. The native system enforces dependencies automatically - you can't accidentally start Tests before Stub completes.
295+
296+
**Pipeline flow**: As each step completes, its dependents become unblocked. Dispatch newly-unblocked tasks immediately for maximum parallelism.
297+
298+
See `${CLAUDE_PLUGIN_ROOT}/templates/tasks-template.md` for additional orchestration patterns (polling fallback, dependency diagrams). These are included in the generated tasks.md.
233299
234300
### For Waived Phases
235301

templates/tasks-template.md

Lines changed: 68 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ The orchestrator coordinates these agents, reviews their output, updates checkbo
2525
- **Checkpoints**: Pause for user approval at designated points
2626
- **Escalation**: Stop new work, settle in-flight agents, then raise issues
2727

28+
### Real-Time Coordination (Native Task System)
29+
30+
Use Claude Code's native task tools for **real-time coordination** during the session:
31+
32+
- **Native tasks** (`TaskCreate`, `TaskUpdate`, `TaskList`) = Session coordination layer
33+
- **This markdown file** = Persistent record (survives compactions)
34+
35+
**Workflow:**
36+
1. At phase set start: Create native tasks with `blockedBy` dependencies
37+
2. During execution: `TaskUpdate` status as subagents dispatch/complete
38+
3. Use `TaskList` to see what's unblocked and ready
39+
4. After each phase: Sync completed tasks back to markdown checkboxes
40+
2841
---
2942

3043
## Phase 1: [Phase Name]
@@ -111,37 +124,67 @@ Document which phases can run in parallel and which have dependencies.
111124

112125
## Orchestration Instructions
113126

114-
### Sequential Phase Execution
127+
### Setup: Create Native Tasks
115128

116-
For each phase, dispatch subagents in order:
129+
Before starting implementation, create native tasks for all steps with dependencies:
117130

118131
```
119-
1. Task tool: subagent_type=stub-writer
120-
Prompt: "Phase N: [Name]. Create stubs for [files] with exports: [list]"
132+
# Create all tasks for Phase 1
133+
TaskCreate: subject="P1: Stub", description="Create exports for [files]"
134+
TaskCreate: subject="P1: Tests", description="Write failing tests"
135+
TaskCreate: subject="P1: Implement", description="Make tests pass"
136+
TaskCreate: subject="P1: Validate", description="Verify requirements"
137+
138+
# Set up TDD dependency chain
139+
TaskUpdate: "P1: Tests" addBlockedBy: ["P1: Stub"]
140+
TaskUpdate: "P1: Implement" addBlockedBy: ["P1: Tests"]
141+
TaskUpdate: "P1: Validate" addBlockedBy: ["P1: Implement"]
142+
143+
# For parallel phases, add cross-phase dependencies as needed
144+
TaskUpdate: "P4: Stub" addBlockedBy: ["P2: Validate"] # P4 depends on P2
145+
```
121146

122-
2. Task tool: subagent_type=test-generation
123-
Prompt: "Phase N: [Name]. Write tests for [requirements]. Files: [paths]. Run tests, report output."
147+
### Sequential Phase Execution
124148

125-
3. Task tool: subagent_type=implementer
126-
Prompt: "Phase N: [Name]. Make tests pass. Files: [paths]. Run tests, report output."
149+
For each phase, use `TaskList` to find unblocked tasks, then dispatch:
127150

128-
4. Task tool: subagent_type=validator
129-
Prompt: "Phase N: [Name]. Verify: [requirements]. Run tests independently. Report pass/fail."
151+
```
152+
1. TaskUpdate: "P1: Stub" status: in_progress
153+
Task tool: subagent_type=stub-writer
154+
Prompt: "Phase 1: [Name]. Create stubs for [files] with exports: [list]"
155+
→ On success: TaskUpdate: "P1: Stub" status: completed
156+
157+
2. TaskUpdate: "P1: Tests" status: in_progress
158+
Task tool: subagent_type=test-generation
159+
Prompt: "Phase 1: [Name]. Write tests for [requirements]. Files: [paths]. Run tests, report output."
160+
→ On success: TaskUpdate: "P1: Tests" status: completed
161+
162+
3. TaskUpdate: "P1: Implement" status: in_progress
163+
Task tool: subagent_type=implementer
164+
Prompt: "Phase 1: [Name]. Make tests pass. Files: [paths]. Run tests, report output."
165+
→ On success: TaskUpdate: "P1: Implement" status: completed
166+
167+
4. TaskUpdate: "P1: Validate" status: in_progress
168+
Task tool: subagent_type=validator
169+
Prompt: "Phase 1: [Name]. Verify: [requirements]. Run tests independently. Report pass/fail."
170+
→ On success: TaskUpdate: "P1: Validate" status: completed
130171
```
131172

132173
### Parallel Phase Execution
133174

134-
When multiple phases are marked [P], use **pipeline flow**:
175+
When multiple phases are marked [P], use **pipeline flow** with native task coordination:
135176

136-
1. **Dispatch** ALL stub writers with `run_in_background: true` in a single message
137-
2. **Post status** to user: "Dispatched stub writers for Phases X, Y, Z."
138-
3. **Orchestration loop**:
139-
- Do any pending work (check off completed steps, dispatch next agents for completed phases)
140-
- Process any notifications that arrived while working
141-
- If no pending work: poll all active agents with `AgentOutputTool(block: false)`
142-
- If all still running: `Bash(sleep 30)` to idle efficiently, then poll again
177+
1. **Create all native tasks upfront** with `blockedBy` dependencies (see Setup above)
178+
2. **Use `TaskList`** to see all unblocked tasks ready to dispatch
179+
3. **Dispatch** all unblocked stub writers with `run_in_background: true` in a single message
180+
4. **Post status** to user: "Dispatched stub writers for Phases X, Y, Z."
181+
5. **Orchestration loop**:
182+
- `TaskList` to find newly unblocked tasks (e.g., Tests for completed Stubs)
183+
- Dispatch unblocked tasks, `TaskUpdate` status to in_progress
184+
- As agents complete, `TaskUpdate` status to completed
185+
- Repeat until all tasks complete
143186

144-
This creates true pipeline parallelism - Phase 1's test writer starts as soon as Phase 1's stub finishes, even while other stubs run. Notifications usually arrive promptly, but the 30-second polling fallback catches any that don't.
187+
The native `blockedBy` system automatically tracks what's ready - no manual dependency checking needed. As each step completes, its dependents become unblocked and appear in `TaskList`.
145188

146189
### Dependency Enforcement
147190

@@ -156,9 +199,12 @@ Dependencies mean the full Stub → Tests → Implement → Validate cycle, not
156199

157200
### At Checkpoints
158201

159-
1. Summarize completed phases with pass/fail status
160-
2. List upcoming phases
161-
3. Wait for user approval before continuing
202+
1. **Sync to markdown**: Update all checkboxes in this file to match native task completion
203+
2. Summarize completed phases with pass/fail status
204+
3. List upcoming phases
205+
4. Wait for user approval before continuing
206+
207+
*The markdown sync ensures progress is preserved across context compactions.*
162208

163209
### On Complications
164210

0 commit comments

Comments
 (0)