Skip to content

Commit 6d9b811

Browse files
jwaldripclaude
andcommitted
feat: make Agent Teams the primary execution model for /construct
Restructure the construct skill so that Agent Teams (parallel teammate spawning, monitor/react loop, per-unit hat tracking) is the primary execution path when CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is set. The previous sequential subagent approach is preserved as a fallback. - construct: Add team create/reconnect, parallel unit spawn, monitor loop, team shutdown, and unitStates/teamName schema in iteration.json - advance: Add Step 2c to spawn newly unblocked units as teammates - fail: Add Step 4b with retry tracking (max 3) and teammate re-spawn - reset: Add Step 1b for team cleanup (shutdown + TeamDelete) - resume: Add Step 5b for team reconnection on resume - enforce-iteration: Add teammate guard so unit sessions exit early - subagent-context: Add Team Communication instructions for teammates - inject-context: Add Agent Teams status display in session context Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6a0326 commit 6d9b811

File tree

8 files changed

+401
-33
lines changed

8 files changed

+401
-33
lines changed

hooks/enforce-iteration.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ if [ -z "$ITERATION_JSON" ] && [[ "$CURRENT_BRANCH" == ai-dlc/*/* ]]; then
3737
ITERATION_JSON=$(han keep load --branch "$INTENT_BRANCH" iteration.json --quiet 2>/dev/null || echo "")
3838
fi
3939

40+
# Unit-branch sessions (teammates or subagents) should NOT be told to /construct
41+
# The orchestrator on the intent branch manages the construction loop
42+
if [ -n "$INTENT_BRANCH" ]; then
43+
echo "## AI-DLC: Unit Session Ending"
44+
echo ""
45+
echo "Ensure you committed changes and saved progress."
46+
exit 0
47+
fi
48+
4049
if [ -z "$ITERATION_JSON" ]; then
4150
# No AI-DLC state - not using the methodology, skip
4251
exit 0

hooks/inject-context.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,19 @@ if [ -n "$INTENT_DIR" ] && [ -d "$INTENT_DIR" ] && ls "$INTENT_DIR"/unit-*.md 1>
439439
fi
440440
fi
441441

442+
# Display Agent Teams status if enabled
443+
if [ -n "${CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:-}" ]; then
444+
TEAM_NAME="ai-dlc-${INTENT_SLUG}"
445+
TEAM_CONFIG="$HOME/.claude/teams/${TEAM_NAME}/config.json"
446+
if [ -f "$TEAM_CONFIG" ]; then
447+
echo "### Agent Teams"
448+
echo ""
449+
echo "**Team:** \`${TEAM_NAME}\`"
450+
echo "**Mode:** Parallel execution enabled"
451+
echo ""
452+
fi
453+
fi
454+
442455
# Load hat instructions from markdown files
443456
# Resolution order: 1) User override (.ai-dlc/hats/), 2) Plugin built-in (hats/)
444457
HAT_FILE=""

hooks/subagent-context.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,15 @@ echo ""
287287
echo "Output status messages directly - users see them in real-time."
288288
echo "Document blockers in \`han keep save blockers.md\` for persistence (unit-scoped)."
289289
echo ""
290+
291+
# Team communication instructions (Agent Teams mode)
292+
if [ -n "${CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:-}" ]; then
293+
echo "### Team Communication"
294+
echo ""
295+
echo "You are a **teammate** in an Agent Teams session."
296+
echo "- Report completion/issues to team lead via SendMessage"
297+
echo "- Do NOT call /construct, /advance, or /fail — the lead handles orchestration"
298+
echo "- Use TaskUpdate to mark shared tasks as completed when done"
299+
echo "- Coordinate with other teammates through the team lead"
300+
echo ""
301+
fi

skills/advance/SKILL.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,28 @@ ${dagSummary.blockedUnits.join('\n')}
101101
Review blockers and unblock units to continue.`;
102102
```
103103

104+
### Step 2c: Spawn Newly Unblocked Units (Agent Teams)
105+
106+
When `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` is enabled and completing a unit unblocks new units:
107+
108+
```bash
109+
AGENT_TEAMS_ENABLED="${CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:-}"
110+
```
111+
112+
If `AGENT_TEAMS_ENABLED` is set and `readyCount > 0` after completing a unit:
113+
114+
1. Read `teamName` from `iteration.json`
115+
2. For each newly ready unit:
116+
- Initialize `unitStates.{unit}.hat = "planner"` and `unitStates.{unit}.retries = 0`
117+
- Create unit worktree
118+
- Mark unit as `in_progress`
119+
- Spawn planner teammate via Task with `team_name` and `name`
120+
3. Save updated state to `iteration.json`
121+
122+
This replaces the sequential "loop back to builder" behavior when Agent Teams is active. Instead of the lead picking up the next unit sequentially, newly unblocked units are spawned as parallel teammates immediately.
123+
124+
**Without Agent Teams:** The existing behavior (reset hat to builder, let `/construct` pick next unit) continues unchanged.
125+
104126
### Step 3: Update State
105127

106128
```bash

0 commit comments

Comments
 (0)