Skip to content

Commit abf0d65

Browse files
bokelleyclaude
andauthored
docs(agents): add parallel agent coordination protocol to CLAUDE.md (#430)
* docs(agents): add parallel agent coordination protocol to CLAUDE.md Adds write-scope partitioning pattern, prompt template, and pre-spawn checklist to prevent silent file-collision overwrites when spawning parallel sub-agents (observed as W2/W3 cycle collisions, issue #425). https://claude.ai/code/session_01BojvrVjuAKWkJFda4dBMDU * docs(agents): fix blocker feedback on parallel agent coordination section - Use git log for collision check (git diff --name-only is ambiguous after commits) - Add "no globs" note on write scope - Add guidance for dynamic file discovery during execution - Add shared-file ownership rule for checklist - Drop misleading "was introduced after" rationale paragraph; replace with present-tense enforcement rule https://claude.ai/code/session_01BojvrVjuAKWkJFda4dBMDU --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3035c25 commit abf0d65

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,43 @@ git worktree remove /tmp/claude-issue-<N>-<slug>
185185
**Branch naming:** always follow `claude/issue-<N>-<short-slug>` — branch-protection
186186
rules enforce this pattern and PRs from non-conforming names may be rejected.
187187

188+
## Parallel Agent Coordination
189+
190+
When spawning parallel sub-agents, each agent must receive an explicit write-scope
191+
declaration in its prompt. Agents do not detect or refuse out-of-scope writes at
192+
runtime; this contract is the only enforcement mechanism.
193+
194+
**Prompt template for a parallel sub-agent:**
195+
196+
```
197+
Task: <what this agent should do>
198+
199+
Read scope (consult freely):
200+
- <file or glob pattern>
201+
- <file or glob pattern>
202+
203+
Write scope (the ONLY files this agent may create or modify — exact paths, no globs):
204+
- <exact file path>
205+
- <exact file path>
206+
207+
Do not edit files outside your write scope even if you believe the change
208+
would be an improvement. If you discover during execution that you need to write
209+
a file outside your scope, stop and record it in your reply instead.
210+
```
211+
212+
**Pre-spawn checklist:**
213+
214+
1. List every file any agent in the group is expected to write. If an agent may
215+
discover additional files during execution, note that in your scope planning —
216+
do not silently expand the write scope at runtime.
217+
2. Partition that set so each file appears in exactly one agent's write scope.
218+
For files both agents need to write, assign one owner; have the other emit the
219+
required change as a note in its reply.
220+
3. Pass each agent its partition explicitly (see template above).
221+
4. After all agents complete, check for collisions:
222+
`git log --name-only --oneline -<N>` (N = number of agent commits), then look
223+
for the same file appearing in more than one entry.
224+
188225
## Additional Important Reminders
189226

190227
**NEVER**:

0 commit comments

Comments
 (0)