Deep Analysis Workflow
Execute a structured exploration + synthesis workflow using hub-and-spoke coordination. The lead performs rapid reconnaissance to generate dynamic focus areas, composes a team plan for review, workers explore independently, and a synthesizer merges findings with deep investigation.
This skill can be invoked standalone or loaded by other skills as a reusable building block. Approval behavior is configurable.
Settings Check
Goal: Determine whether the team plan requires user approval before execution.
Read settings file:
- Check if
.agents/agent-alchemy.local.md exists
- If it exists, read it and look for a
deep-analysis section with nested settings
- If the file does not exist or is malformed, use defaults (see step 4)
Determine invocation mode:
- Direct invocation: The user invoked this skill directly
- Skill-invoked: Another skill loaded and is executing this workflow
Resolve settings:
- If settings were found, use them as-is
- If the file is missing or the
deep-analysis section is absent, use defaults:
direct-invocation-approval: true
invocation-by-skill-approval: false
Set REQUIRE_APPROVAL:
- If direct invocation → use
direct-invocation-approval value (default: true)
- If skill-invoked → use
invocation-by-skill-approval value (default: false)
Parse session settings (also under the deep-analysis section):
cache-ttl-hours: Number of hours before exploration cache expires. Default: 24. Set to 0 to disable caching entirely.
enable-checkpointing: Whether to write session checkpoints at phase boundaries. Default: true.
enable-progress-indicators: Whether to display [Phase N/6] progress messages. Default: true.
Phase 0: Session Setup
Goal: Check for cached exploration results, detect interrupted sessions, and initialize the session directory.
Skip this phase entirely if cache TTL is 0 AND checkpointing is disabled.
Step 1: Exploration Cache Check
If cache TTL > 0:
- Check if
.agents/sessions/exploration-cache/manifest.md exists
- If found, read the manifest and verify:
analysis_context matches the current analysis context (or is a superset)
codebase_path matches the current working directory
timestamp is within the configured TTL hours of now
- Config files referenced in
config_checksum haven't been modified since the cache was written
- If cache is valid:
- Skill-invoked mode: Auto-accept the cache. Read cached
synthesis.md and recon_summary.md. Skip to Phase 6 step 2 (present/return results).
- Direct invocation: Prompt the user to choose:
- Use cached results — Skip to Phase 6 step 2
- Refresh analysis — Proceed normally
- If cache is invalid or absent: Proceed normally
Step 2: Interrupted Session Check
If checkpointing is enabled:
- Check if
.agents/sessions/__da_live__/checkpoint.md exists
- If found, read the checkpoint to determine
last_completed_phase
- Prompt the user to choose:
- Resume from Phase [N+1] — Load checkpoint state, proceed from the interrupted phase
- Start fresh — Archive the interrupted session and proceed normally
- If not found: proceed normally
Step 3: Initialize Session Directory
If checkpointing is enabled and no cache hit:
- Create
.agents/sessions/__da_live__/ directory
- Write a
checkpoint.md with session metadata (analysis context, codebase path, start timestamp, current phase)
- Write a
progress.md to track phase completions
Phase 1: Reconnaissance & Planning
Goal: Perform codebase reconnaissance, generate dynamic focus areas, and compose a team plan.
Determine analysis context:
- If arguments are provided, use them as the analysis context
- If no arguments and this skill was loaded by another skill, use the calling skill's context
- If no arguments and standalone invocation, set context to "general codebase understanding"
Rapid codebase reconnaissance:
Search for files, read config files, and map the codebase structure. This should take 1-2 minutes, not deep investigation.
- Directory structure: Find top-level directories to understand the project layout
- Language and framework detection: Read config files (
package.json, tsconfig.json, pyproject.toml, etc.) to identify primary language(s) and framework(s)
- File distribution: Search for file patterns like
src/**/*.ts, **/*.py to gauge the size and shape of different areas
- Key documentation: Read
README.md, CLAUDE.md, or similar docs if they exist for project context
- For feature-focused analysis: Search for feature-related terms to find hotspot directories
- For general analysis: Identify the 3-5 largest or most architecturally significant directories
Fallback: If reconnaissance fails (empty project, unusual structure, errors), use static focus area templates from Step 3b.
Generate dynamic focus areas:
Based on reconnaissance findings, create focus areas tailored to the actual codebase. Default to 3 focus areas, but adjust based on codebase size and complexity (2 for small projects, up to 4 for large ones).
Each focus area should include:
- Label: Short description (e.g., "API layer in src/api/")
- Directories: Specific directories to explore
- Starting files: 2-3 key files to read first
- Search terms: Patterns to find related code
- Complexity estimate: Low/Medium/High based on file count and apparent structure
Compose the team plan:
Assemble a structured plan document:
- Analysis context
- Reconnaissance summary (project name, primary language/framework, codebase size, key observations)
- Focus areas with directories, starting files, search patterns, and complexity estimates
- Agent composition table (N explorers using a balanced model, 1 synthesizer using a high-reasoning model)
- Task dependencies (exploration tasks are parallel, synthesis is blocked by all exploration tasks)
Checkpoint (if enabled):
- Update session checkpoint, write team plan and recon summary, append to progress log
Phase 2: Review & Approval
Goal: Present the team plan for user review and approval before allocating resources.
If approval is not required
Skip to Phase 3 with a brief note: "Auto-approving team plan (skill-invoked mode). Proceeding with N explorers and 1 synthesizer."
If approval is required
Present the team plan, then prompt the user to choose:
- Approve — Proceed to Phase 3 as-is
- Modify — User describes changes (adjust focus areas, add/remove explorers, change scope)
- Regenerate — Re-run reconnaissance with user feedback
If "Modify" (up to 3 cycles): Apply modifications, re-present for approval
If "Regenerate" (up to 2 cycles): Re-run Phase 1 Step 2 with feedback, re-compose and re-present
Phase 3: Team Assembly
Goal: Create the team, delegate to agents, create tasks, and assign work using the approved plan.
Set up the team for the analysis session
Delegate exploration work:
- Assign N independent explorer agents (one per focus area), each using a balanced-reasoning model
- Each explorer receives: the codebase path, analysis context, and their specific focus area details
- Assign 1 synthesizer agent using a high-reasoning model
- The synthesizer receives: the codebase path, analysis context, and instructions to wait for exploration results
Create tasks for tracking:
- One exploration task per focus area
- One synthesis task blocked by all exploration tasks
Assign exploration tasks with status guards — only assign if status is pending and unowned. Never re-assign a completed or in-progress task.
Phase 4: Focused Exploration
Goal: Workers explore their assigned areas independently.
After assigning exploration tasks, monitor progress:
- When an explorer completes, record its findings. If checkpointing is enabled, persist findings to the session directory.
- Workers explore independently — no cross-worker messaging (hub-and-spoke topology)
- Workers can respond to follow-up questions from the synthesizer
- Wait for all exploration tasks to complete before proceeding to Phase 5
Phase 5: Evaluation and Synthesis
Goal: Verify exploration completeness, launch synthesis with deep investigation.
Step 1: Structural Completeness Check
- Verify all exploration tasks are completed
- Check that each worker produced a report with content
- If a worker failed completely, create a follow-up exploration task and wait for it
- If all produced content, proceed to Step 2
Step 2: Launch Synthesis
- Assign the synthesis task to the synthesizer
- Provide the synthesizer with all exploration results and recon findings
- The synthesizer can message explorers with follow-up questions to resolve conflicts and gaps
- The synthesizer has shell command access for git history analysis, dependency trees, and static analysis
- Wait for synthesis to complete
Phase 6: Completion + Cleanup
Goal: Collect results, present to user, and tear down the team.
Collect synthesis output from the synthesizer's report
Write exploration cache (if cache TTL > 0):
- Create
.agents/sessions/exploration-cache/ directory
- Write manifest with analysis context, codebase path, timestamp, config checksums, and TTL
- Write synthesis and recon summary results
Present or return results:
- Standalone invocation: Present the synthesized analysis to the user
- Loaded by another skill: Control returns to the calling workflow — do not present a standalone summary
Shut down all agents and archive/clean up the session
Error Handling
Settings Check Failure
- If settings file exists but is malformed: warn the user and proceed with defaults
Planning Phase Failure
- If reconnaissance fails: fall back to static focus area templates
- If the codebase appears empty: inform the user and ask how to proceed
Partial Worker Failure
- If one worker fails: create a follow-up task for the missed focus area
- If two workers fail: attempt follow-ups, but synthesize with partial results if follow-ups also fail
- If all workers fail: inform the user and offer to retry or abort
Synthesizer Failure
- Present the raw exploration results directly; offer to retry synthesis
Session Recovery
When resuming from an interrupted session, use per-phase strategy:
| Interrupted At |
Recovery Strategy |
| Phase 1 |
Restart from Phase 1 (reconnaissance is fast) |
| Phase 2 |
Load saved team plan, re-present for approval |
| Phase 3 |
Load approved plan, restart team assembly |
| Phase 4 |
Read completed explorer findings from session dir, only assign missing explorers |
| Phase 5 |
Load all explorer findings, launch fresh synthesis |
| Phase 6 |
Load synthesis, proceed to present results and cleanup |
Agent Coordination
- The lead acts as the planner: performs recon, composes the team plan, handles approval, assigns work
- Workers explore independently — no cross-worker messaging (hub-and-spoke topology)
- The synthesizer can ask workers follow-up questions to resolve conflicts and fill gaps
- The synthesizer has shell command access for deep investigation (git history, dependency trees, static analysis)
- Wait for task dependencies to resolve before proceeding
- Handle agent failures gracefully — continue with partial results
- Agent count and focus area details come from the approved plan, not hardcoded values
Integration Notes
What this component does: Orchestrates a multi-agent codebase exploration and synthesis workflow with dynamic focus area planning, caching, and session recovery.
Capabilities needed:
- File reading and searching
- Shell command execution
- User interaction / prompting
- Sub-agent delegation (multiple parallel explorers + 1 synthesizer)
Adaptation guidance:
- The exploration step delegates to multiple agents in parallel — implement as concurrent tasks if your harness supports it, or serialize if not
- The original used a 3-tier model strategy (fast/balanced/powerful) — use your default model unless specific steps need stronger reasoning
- Session files under
.agents/sessions/ provide caching and recovery — implement if your harness supports persistent state, or skip for simpler setups
Configurable parameters:
direct-invocation-approval (default: true) — Require plan approval when invoked directly
invocation-by-skill-approval (default: false) — Require approval when loaded by another skill
cache-ttl-hours (default: 24) — Hours before exploration cache expires; 0 disables caching
enable-checkpointing (default: true) — Write session checkpoints at phase boundaries
enable-progress-indicators (default: true) — Display phase progress messages
1---2name: deep-analysis-133description: Deep exploration and synthesis workflow with dynamic planning and hub-and-spoke coordination. Use for deep analysis, codebase understanding, or thorough investigation of a focus area.4---5
6# Deep Analysis Workflow
7
8Execute a structured exploration + synthesis workflow using hub-and-spoke coordination. The lead performs rapid reconnaissance to generate dynamic focus areas, composes a team plan for review, workers explore independently, and a synthesizer merges findings with deep investigation.
9
10This skill can be invoked standalone or loaded by other skills as a reusable building block. Approval behavior is configurable.
11
12## Settings Check
13
14**Goal:** Determine whether the team plan requires user approval before execution.
15
161. **Read settings file:**
17 - Check if `.agents/agent-alchemy.local.md` exists
18 - If it exists, read it and look for a `deep-analysis` section with nested settings
19 - If the file does not exist or is malformed, use defaults (see step 4)
20
212. **Determine invocation mode:**
22 - **Direct invocation:** The user invoked this skill directly
23 - **Skill-invoked:** Another skill loaded and is executing this workflow
24
253. **Resolve settings:**
26 - If settings were found, use them as-is
27 - If the file is missing or the `deep-analysis` section is absent, use defaults:
28 - `direct-invocation-approval`: `true`
29 - `invocation-by-skill-approval`: `false`
30
314. **Set `REQUIRE_APPROVAL`:**
32 - If direct invocation → use `direct-invocation-approval` value (default: `true`)
33 - If skill-invoked → use `invocation-by-skill-approval` value (default: `false`)
34
355. **Parse session settings** (also under the `deep-analysis` section):
36 - `cache-ttl-hours`: Number of hours before exploration cache expires. Default: `24`. Set to `0` to disable caching entirely.
37 - `enable-checkpointing`: Whether to write session checkpoints at phase boundaries. Default: `true`.
38 - `enable-progress-indicators`: Whether to display `[Phase N/6]` progress messages. Default: `true`.
39
40---
41
42## Phase 0: Session Setup
43
44**Goal:** Check for cached exploration results, detect interrupted sessions, and initialize the session directory.
45
46> Skip this phase entirely if cache TTL is 0 AND checkpointing is disabled.
47
48### Step 1: Exploration Cache Check
49
50If cache TTL > 0:
51
521. Check if `.agents/sessions/exploration-cache/manifest.md` exists
532. If found, read the manifest and verify:
54 - `analysis_context` matches the current analysis context (or is a superset)
55 - `codebase_path` matches the current working directory
56 - `timestamp` is within the configured TTL hours of now
57 - Config files referenced in `config_checksum` haven't been modified since the cache was written
583. **If cache is valid:**
59 - **Skill-invoked mode:** Auto-accept the cache. Read cached `synthesis.md` and `recon_summary.md`. Skip to Phase 6 step 2 (present/return results).
60 - **Direct invocation:** Prompt the user to choose:
61 - **Use cached results** — Skip to Phase 6 step 2
62 - **Refresh analysis** — Proceed normally
634. **If cache is invalid or absent:** Proceed normally
64
65### Step 2: Interrupted Session Check
66
67If checkpointing is enabled:
68
691. Check if `.agents/sessions/__da_live__/checkpoint.md` exists
702. If found, read the checkpoint to determine `last_completed_phase`
713. Prompt the user to choose:
72 - **Resume from Phase [N+1]** — Load checkpoint state, proceed from the interrupted phase
73 - **Start fresh** — Archive the interrupted session and proceed normally
744. If not found: proceed normally
75
76### Step 3: Initialize Session Directory
77
78If checkpointing is enabled and no cache hit:
79
801. Create `.agents/sessions/__da_live__/` directory
812. Write a `checkpoint.md` with session metadata (analysis context, codebase path, start timestamp, current phase)
823. Write a `progress.md` to track phase completions
83
84---
85
86## Phase 1: Reconnaissance & Planning
87
88**Goal:** Perform codebase reconnaissance, generate dynamic focus areas, and compose a team plan.
89
901. **Determine analysis context:**
91 - If arguments are provided, use them as the analysis context
92 - If no arguments and this skill was loaded by another skill, use the calling skill's context
93 - If no arguments and standalone invocation, set context to "general codebase understanding"
94
952. **Rapid codebase reconnaissance:**
96 Search for files, read config files, and map the codebase structure. This should take 1-2 minutes, not deep investigation.
97
98 - **Directory structure:** Find top-level directories to understand the project layout
99 - **Language and framework detection:** Read config files (`package.json`, `tsconfig.json`, `pyproject.toml`, etc.) to identify primary language(s) and framework(s)
100 - **File distribution:** Search for file patterns like `src/**/*.ts`, `**/*.py` to gauge the size and shape of different areas
101 - **Key documentation:** Read `README.md`, `CLAUDE.md`, or similar docs if they exist for project context
102 - **For feature-focused analysis:** Search for feature-related terms to find hotspot directories
103 - **For general analysis:** Identify the 3-5 largest or most architecturally significant directories
104
105 **Fallback:** If reconnaissance fails (empty project, unusual structure, errors), use static focus area templates from Step 3b.
106
1073. **Generate dynamic focus areas:**
108
109 Based on reconnaissance findings, create focus areas tailored to the actual codebase. Default to 3 focus areas, but adjust based on codebase size and complexity (2 for small projects, up to 4 for large ones).
110
111 Each focus area should include:
112 - **Label:** Short description (e.g., "API layer in src/api/")
113 - **Directories:** Specific directories to explore
114 - **Starting files:** 2-3 key files to read first
115 - **Search terms:** Patterns to find related code
116 - **Complexity estimate:** Low/Medium/High based on file count and apparent structure
117
1184. **Compose the team plan:**
119
120 Assemble a structured plan document:
121 - Analysis context
122 - Reconnaissance summary (project name, primary language/framework, codebase size, key observations)
123 - Focus areas with directories, starting files, search patterns, and complexity estimates
124 - Agent composition table (N explorers using a balanced model, 1 synthesizer using a high-reasoning model)
125 - Task dependencies (exploration tasks are parallel, synthesis is blocked by all exploration tasks)
126
1275. **Checkpoint** (if enabled):
128 - Update session checkpoint, write team plan and recon summary, append to progress log
129
130---
131
132## Phase 2: Review & Approval
133
134**Goal:** Present the team plan for user review and approval before allocating resources.
135
136### If approval is not required
137
138Skip to Phase 3 with a brief note: "Auto-approving team plan (skill-invoked mode). Proceeding with N explorers and 1 synthesizer."
139
140### If approval is required
141
1421. Present the team plan, then prompt the user to choose:
143 - **Approve** — Proceed to Phase 3 as-is
144 - **Modify** — User describes changes (adjust focus areas, add/remove explorers, change scope)
145 - **Regenerate** — Re-run reconnaissance with user feedback
146
1472. If "Modify" (up to 3 cycles): Apply modifications, re-present for approval
1483. If "Regenerate" (up to 2 cycles): Re-run Phase 1 Step 2 with feedback, re-compose and re-present
149
150---
151
152## Phase 3: Team Assembly
153
154**Goal:** Create the team, delegate to agents, create tasks, and assign work using the approved plan.
155
1561. **Set up the team** for the analysis session
157
1582. **Delegate exploration work:**
159 - Assign **N independent explorer agents** (one per focus area), each using a balanced-reasoning model
160 - Each explorer receives: the codebase path, analysis context, and their specific focus area details
161 - Assign **1 synthesizer agent** using a high-reasoning model
162 - The synthesizer receives: the codebase path, analysis context, and instructions to wait for exploration results
163
1643. **Create tasks** for tracking:
165 - One exploration task per focus area
166 - One synthesis task blocked by all exploration tasks
167
1684. **Assign exploration tasks** with status guards — only assign if status is pending and unowned. Never re-assign a completed or in-progress task.
169
170---
171
172## Phase 4: Focused Exploration
173
174**Goal:** Workers explore their assigned areas independently.
175
176After assigning exploration tasks, monitor progress:
177
1781. When an explorer completes, record its findings. If checkpointing is enabled, persist findings to the session directory.
1792. Workers explore independently — no cross-worker messaging (hub-and-spoke topology)
1803. Workers can respond to follow-up questions from the synthesizer
1814. **Wait for all exploration tasks to complete** before proceeding to Phase 5
182
183---
184
185## Phase 5: Evaluation and Synthesis
186
187**Goal:** Verify exploration completeness, launch synthesis with deep investigation.
188
189### Step 1: Structural Completeness Check
190
1911. Verify all exploration tasks are completed
1922. Check that each worker produced a report with content
1933. If a worker failed completely, create a follow-up exploration task and wait for it
1944. If all produced content, proceed to Step 2
195
196### Step 2: Launch Synthesis
197
1981. Assign the synthesis task to the synthesizer
1992. Provide the synthesizer with all exploration results and recon findings
2003. The synthesizer can message explorers with follow-up questions to resolve conflicts and gaps
2014. The synthesizer has shell command access for git history analysis, dependency trees, and static analysis
2025. Wait for synthesis to complete
203
204---
205
206## Phase 6: Completion + Cleanup
207
208**Goal:** Collect results, present to user, and tear down the team.
209
2101. **Collect synthesis output** from the synthesizer's report
211
2122. **Write exploration cache** (if cache TTL > 0):
213 - Create `.agents/sessions/exploration-cache/` directory
214 - Write manifest with analysis context, codebase path, timestamp, config checksums, and TTL
215 - Write synthesis and recon summary results
216
2173. **Present or return results:**
218 - **Standalone invocation:** Present the synthesized analysis to the user
219 - **Loaded by another skill:** Control returns to the calling workflow — do not present a standalone summary
220
2214. **Shut down all agents** and archive/clean up the session
222
223---
224
225## Error Handling
226
227### Settings Check Failure
228- If settings file exists but is malformed: warn the user and proceed with defaults
229
230### Planning Phase Failure
231- If reconnaissance fails: fall back to static focus area templates
232- If the codebase appears empty: inform the user and ask how to proceed
233
234### Partial Worker Failure
235- If one worker fails: create a follow-up task for the missed focus area
236- If two workers fail: attempt follow-ups, but synthesize with partial results if follow-ups also fail
237- If all workers fail: inform the user and offer to retry or abort
238
239### Synthesizer Failure
240- Present the raw exploration results directly; offer to retry synthesis
241
242### Session Recovery
243
244When resuming from an interrupted session, use per-phase strategy:
245
246| Interrupted At | Recovery Strategy |
247|----------------|-------------------|
248| Phase 1 | Restart from Phase 1 (reconnaissance is fast) |
249| Phase 2 | Load saved team plan, re-present for approval |
250| Phase 3 | Load approved plan, restart team assembly |
251| Phase 4 | Read completed explorer findings from session dir, only assign missing explorers |
252| Phase 5 | Load all explorer findings, launch fresh synthesis |
253| Phase 6 | Load synthesis, proceed to present results and cleanup |
254
255---
256
257## Agent Coordination
258
259- The lead acts as the planner: performs recon, composes the team plan, handles approval, assigns work
260- Workers explore independently — no cross-worker messaging (hub-and-spoke topology)
261- The synthesizer can ask workers follow-up questions to resolve conflicts and fill gaps
262- The synthesizer has shell command access for deep investigation (git history, dependency trees, static analysis)
263- Wait for task dependencies to resolve before proceeding
264- Handle agent failures gracefully — continue with partial results
265- Agent count and focus area details come from the approved plan, not hardcoded values
266
267## Integration Notes
268
269**What this component does:** Orchestrates a multi-agent codebase exploration and synthesis workflow with dynamic focus area planning, caching, and session recovery.
270
271**Capabilities needed:**
272- File reading and searching
273- Shell command execution
274- User interaction / prompting
275- Sub-agent delegation (multiple parallel explorers + 1 synthesizer)
276
277**Adaptation guidance:**
278- The exploration step delegates to multiple agents in parallel — implement as concurrent tasks if your harness supports it, or serialize if not
279- The original used a 3-tier model strategy (fast/balanced/powerful) — use your default model unless specific steps need stronger reasoning
280- Session files under `.agents/sessions/` provide caching and recovery — implement if your harness supports persistent state, or skip for simpler setups
281
282**Configurable parameters:**
283- `direct-invocation-approval` (default: true) — Require plan approval when invoked directly
284- `invocation-by-skill-approval` (default: false) — Require approval when loaded by another skill
285- `cache-ttl-hours` (default: 24) — Hours before exploration cache expires; 0 disables caching
286- `enable-checkpointing` (default: true) — Write session checkpoints at phase boundaries
287- `enable-progress-indicators` (default: true) — Display phase progress messages