Skip to content

Commit 36672ba

Browse files
catlog22claude
andcommitted
fix: resolve multi-perspective parallel search design ambiguity in analyze-with-file
Two issues fixed: 1. Default perspective selection now auto-recommends Technical + Architectural when dimensions >= 2, instead of always defaulting to single comprehensive view (which caused Phase B to never trigger). 2. Phase B pseudocode replaced forEach sequential pattern with explicit parallel Agent() call pattern — all perspective agents must be launched in the same response block for concurrent execution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aeaf545 commit 36672ba

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

.claude/commands/workflow/analyze-with-file.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,31 +230,45 @@ Do NOT write files.
230230
}
231231
```
232232
233-
**Phase B — Perspective Deep-Dive** (parallel, only for multi-perspective, max 4):
233+
**Phase B — Perspective Deep-Dive** (PARALLEL, only for multi-perspective, max 4):
234234
Each perspective agent receives shared Layer 1 results, performs only Layer 2-3 on its relevant subset.
235235
Skip if single-perspective (single mode proceeds directly to Step 2 CLI analysis with Layer 1 results).
236236
237+
**CRITICAL — Parallel Execution**: Launch ALL perspective Agent() calls in the SAME response block so Claude Code executes them concurrently. Do NOT use a loop that waits for each agent before starting the next.
238+
237239
```javascript
238240
// Per-perspective Layer 2-3 — receives shared discovery, avoids re-scanning
239241
// Only runs in multi-perspective mode
242+
// PARALLEL: All Agent() calls MUST appear in ONE response — Claude Code runs them concurrently
240243
const sharedDiscovery = readJSON(`${sessionFolder}/exploration-codebase.json`)
241-
const perspectiveFiles = sharedDiscovery.relevant_files
242-
.filter(f => f.dimensions.includes(perspective.dimension))
243244
244-
selectedPerspectives.forEach(perspective => {
245-
Agent({
246-
subagent_type: "cli-explore-agent",
247-
run_in_background: false,
248-
description: `Deep-dive: ${perspective.name}`,
249-
prompt: `
245+
// Prepare per-perspective file lists
246+
const perspectiveFileLists = Object.fromEntries(
247+
selectedPerspectives.map(p => [
248+
p.name,
249+
sharedDiscovery.relevant_files.filter(f => f.dimensions.includes(p.dimension))
250+
])
251+
)
252+
253+
// Launch ALL agents in a SINGLE response block (not sequentially):
254+
// Agent({ ..perspective1.. }) ← call 1
255+
// Agent({ ..perspective2.. }) ← call 2 (same response)
256+
// Agent({ ..perspective3.. }) ← call 3 (same response)
257+
258+
// Each agent call follows this template:
259+
Agent({
260+
subagent_type: "cli-explore-agent",
261+
run_in_background: false,
262+
description: `Deep-dive: ${perspective.name}`,
263+
prompt: `
250264
## Analysis Context
251265
Topic: ${topic_or_question}
252266
Perspective: ${perspective.name} - ${perspective.focus}
253267
Session: ${sessionFolder}
254268
255269
## SHARED DISCOVERY (Layer 1 already completed — DO NOT re-scan)
256270
Relevant files for this perspective:
257-
${perspectiveFiles.map(f => `- ${f.path}: ${f.annotation}`).join('\n')}
271+
${perspectiveFileLists[perspective.name].map(f => `- ${f.path}: ${f.annotation}`).join('\n')}
258272
Patterns found: ${sharedDiscovery.patterns.join(', ')}
259273
260274
## Layer 2 — Structure Tracing (Depth)
@@ -270,7 +284,6 @@ Patterns found: ${sharedDiscovery.patterns.join(', ')}
270284
Write to: ${sessionFolder}/explorations/${perspective.name}.json
271285
Schema: {perspective, relevant_files, key_findings, code_anchors: [{file, lines, snippet, significance}], call_chains: [{entry, chain, files}], questions_for_user, _metadata}
272286
`
273-
})
274287
})
275288
```
276289
@@ -731,7 +744,7 @@ ${implScope.map((item, i) => `${i+1}. **${item.objective}** [${item.priority}]
731744
| **Business** | Codex | Value, ROI, stakeholder impact | Business implications |
732745
| **Domain Expert** | Gemini | Domain patterns, best practices, standards | Industry knowledge |
733746
734-
User multi-selects up to 4 in Phase 1, default: single comprehensive view.
747+
User multi-selects up to 4 in Phase 1. Default: if dimensions >= 2, pre-select Technical + Architectural; if dimensions == 1, single comprehensive view.
735748
736749
### Dimension-Direction Mapping
737750

0 commit comments

Comments
 (0)