Deep exploration and synthesis workflow using Agent Teams with dynamic planning and hub-and-spoke coordination. Use when asked for "deep analysis", "deep understanding", "analyze codebase", "explore and analyze", or "investigate codebase".
Executes structured multi-agent exploration of codebases using dynamic planning and hub-and-spoke coordination.
/plugin marketplace add sequenzia/agent-alchemy/plugin install agent-alchemy-core-tools@agent-alchemyThis skill is limited to using the following tools:
Execute a structured exploration + synthesis workflow using Agent Teams with 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 Bash-powered investigation.
This skill can be invoked standalone or loaded by other skills as a reusable building block. Approval behavior is configurable via .claude/agent-alchemy.local.md.
Goal: Determine whether the team plan requires user approval before execution.
Read settings file:
.claude/agent-alchemy.local.md existsdeep-analysis section with nested settings:
- **deep-analysis**:
- **direct-invocation-approval**: true
- **invocation-by-skill-approval**: false
Determine invocation mode:
/deep-analysis directly, or you are running this skill standaloneResolve settings:
deep-analysis section is absent, use defaults:
direct-invocation-approval: trueinvocation-by-skill-approval: falseSet REQUIRE_APPROVAL:
direct-invocation-approval value (default: true)invocation-by-skill-approval value (default: false)Parse session settings (also under the deep-analysis section):
- **deep-analysis**:
- **cache-ttl-hours**: 24
- **enable-checkpointing**: true
- **enable-progress-indicators**: true
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.Set behavioral flags:
CACHE_TTL = value of cache-ttl-hours (default: 24)ENABLE_CHECKPOINTING = value of enable-checkpointing (default: true)ENABLE_PROGRESS = value of enable-progress-indicators (default: true)Goal: Check for cached exploration results, detect interrupted sessions, and initialize the session directory.
Skip this phase entirely if
CACHE_TTL = 0ANDENABLE_CHECKPOINTING = false.
If CACHE_TTL > 0:
.claude/sessions/exploration-cache/manifest.md existsanalysis_context matches the current analysis context (or is a superset)codebase_path matches the current working directorytimestamp is within CACHE_TTL hours of nowconfig_checksum haven't been modified since the cache was written (check mod-times of package.json, tsconfig.json, pyproject.toml, etc.)CACHE_HIT = true. Read cached synthesis.md and recon_summary.md. Skip to Phase 6 step 2 (present/return results).AskUserQuestion to offer:
CACHE_HIT = true, skip to Phase 6 step 2CACHE_HIT = false, proceed normallyCACHE_HIT = falseIf ENABLE_CHECKPOINTING = true:
.claude/sessions/__da_live__/checkpoint.md existslast_completed_phaseAskUserQuestion to offer:
.claude/sessions/da-interrupted-{timestamp}/ and proceed normallyIf ENABLE_CHECKPOINTING = true AND CACHE_HIT = false:
.claude/sessions/__da_live__/ directorycheckpoint.md:
## Deep Analysis Session
- **analysis_context**: [context from arguments or caller]
- **codebase_path**: [current working directory]
- **started**: [ISO timestamp]
- **current_phase**: 0
- **status**: initialized
progress.md:
## Deep Analysis Progress
- **Phase**: 0 of 6
- **Status**: Session initialized
### Phase Log
- [timestamp] Phase 0: Session initialized
Goal: Perform codebase reconnaissance, generate dynamic focus areas, and compose a team plan.
If
ENABLE_PROGRESS = true: Display "[Phase 1/6] Reconnaissance & Planning — Mapping codebase structure..."
Determine analysis context:
$ARGUMENTS is provided, use it as the analysis context (feature area, question, or general exploration goal)PATH = current working directoryPATH" with the analysis contextRapid codebase reconnaissance: Use Glob, Grep, and Read to quickly map the codebase structure. This should take 1-2 minutes, not deep investigation.
Glob (e.g., */ pattern) to understand the project layoutpackage.json, tsconfig.json, pyproject.toml, Cargo.toml, go.mod, etc.) to identify primary language(s) and framework(s)Glob with patterns like src/**/*.ts, **/*.py to gauge the size and shape of different areasREADME.md, CLAUDE.md, or similar docs if they exist for project contextGrep to search for feature-related terms (function names, component names, route paths) to find hotspot directoriesFallback: If reconnaissance fails (empty project, unusual structure, errors), use the 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).
a) Dynamic focus areas (default):
Each focus area should include:
For feature-focused analysis, focus areas should track the feature's actual footprint:
Example:
Focus 1: "API routes and middleware in src/api/ and src/middleware/" (auth-related endpoints, request handling)
Focus 2: "React components in src/pages/profile/ and src/components/user/" (UI layer for user profiles)
Focus 3: "Data models and services in src/db/ and src/services/" (persistence and business logic)
For general analysis, focus areas should map to the codebase's actual structure:
Example:
Focus 1: "Next.js app layer in apps/web/src/" (pages, components, app router)
Focus 2: "Shared library in packages/core/src/" (utilities, types, shared logic)
Focus 3: "CLI and tooling in packages/cli/" (commands, configuration, build)
b) Static fallback focus areas (only if recon failed):
For feature-focused analysis:
Focus 1: Explore entry points and user-facing code related to the context
Focus 2: Explore data models, schemas, and storage related to the context
Focus 3: Explore utilities, helpers, and shared infrastructure
For general codebase understanding:
Focus 1: Explore application structure, entry points, and core logic
Focus 2: Explore configuration, infrastructure, and shared utilities
Focus 3: Explore shared utilities, patterns, and cross-cutting concerns
Compose the team plan:
Assemble a structured plan document from the reconnaissance and focus area findings:
## Team Plan: Deep Analysis
### Analysis Context
[context from Step 1]
### Reconnaissance Summary
- **Project:** [name/type]
- **Primary language/framework:** [detected]
- **Codebase size:** [file counts, key directories]
- **Key observations:** [2-3 bullets]
### Focus Areas
#### Focus Area 1: [Label]
- **Directories:** [list]
- **Starting files:** [2-3 files]
- **Search patterns:** [Grep patterns]
- **Complexity:** [Low/Medium/High]
- **Assigned to:** explorer-1 (sonnet)
#### Focus Area 2: [Label]
- **Directories:** [list]
- **Starting files:** [2-3 files]
- **Search patterns:** [Grep patterns]
- **Complexity:** [Low/Medium/High]
- **Assigned to:** explorer-2 (sonnet)
[... repeated for each focus area]
### Agent Composition
| Role | Count | Model | Purpose |
|------|-------|-------|---------|
| Explorer | [N] | sonnet | Independent focus area exploration |
| Synthesizer | 1 | opus | Merge findings, deep investigation |
### Task Dependencies
- Exploration Tasks 1-[N]: parallel (no dependencies)
- Synthesis Task: blocked by all exploration tasks
Checkpoint (if ENABLE_CHECKPOINTING = true):
.claude/sessions/__da_live__/checkpoint.md: set current_phase: 1.claude/sessions/__da_live__/team_plan.md with the full team plan from Step 4.claude/sessions/__da_live__/recon_summary.md with reconnaissance findings from Step 2progress.md: [timestamp] Phase 1: Reconnaissance complete — [N] focus areas identifiedGoal: Present the team plan for user review and approval before allocating resources.
If
ENABLE_PROGRESS = true: Display "[Phase 2/6] Review & Approval — Presenting team plan..."
REQUIRE_APPROVAL = falseSkip to Phase 3 with a brief note: "Auto-approving team plan (skill-invoked mode). Proceeding with [N] explorers and 1 synthesizer."
REQUIRE_APPROVAL = truePresent the team plan to the user (output the plan from Phase 1 Step 4), then use AskUserQuestion:
If "Modify" (up to 3 cycles):
AskUserQuestionIf "Regenerate" (up to 2 cycles):
AskUserQuestionCheckpoint (if ENABLE_CHECKPOINTING = true):
.claude/sessions/__da_live__/checkpoint.md: set current_phase: 2, record approval_mode (approved/auto-approved)progress.md: [timestamp] Phase 2: Plan approved (mode: [approval_mode])Goal: Create the team, spawn agents, create tasks, and assign work using the approved plan.
If
ENABLE_PROGRESS = true: Display "[Phase 3/6] Team Assembly — Creating team and spawning agents..."
Create the team:
TeamCreate with name deep-analysis-{timestamp} (e.g., deep-analysis-1707300000)Spawn teammates:
Use the Task tool with the team_name parameter to spawn teammates based on the approved plan:
N explorers (one per focus area) — subagent_type: "code-explorer", model: sonnet
explorer-1, explorer-2, ... explorer-N1 synthesizer — subagent_type: "code-synthesizer"
synthesizerCreate tasks:
Use TaskCreate for each task based on the approved plan's focus areas:
TaskUpdate to set addBlockedBy pointing to all exploration task IDsAssign exploration tasks (with status guard):
For each exploration task, apply the following status-guarded assignment:
TaskGet to check the task's current status and ownerpending AND owner is emptyTaskUpdate to set the owner to the corresponding explorerSendMessage:
SendMessage type: "message", recipient: "[explorer-N]",
content: "Your exploration task [ID] is assigned. Focus area: [label]. Directories: [list]. Starting files: [list]. Search patterns: [list]. Begin exploration now.",
summary: "Exploration task assigned"
Never re-assign a completed or in-progress task.
Checkpoint (if ENABLE_CHECKPOINTING = true):
.claude/sessions/__da_live__/checkpoint.md: set current_phase: 3, record team_name, explorer_names (list), task_ids (map of explorer → task ID), synthesis_task_idprogress.md: [timestamp] Phase 3: Team assembled — [N] explorers, 1 synthesizerGoal: Workers explore their assigned areas independently.
If
ENABLE_PROGRESS = true: Display "[Phase 4/6] Focused Exploration — 0/[N] explorers complete"
After assigning exploration tasks, monitor progress with status-aware tracking:
TaskGet to check their task statuscompleted: Record the explorer's findings. If ENABLE_CHECKPOINTING = true, write explorer-{N}-findings.md to .claude/sessions/__da_live__/ and update checkpoint.in_progress: The explorer is still working — do NOT re-send the assignmentpending and owner is set: The explorer received the assignment but hasn't started yet — wait, do NOT re-sendpending and owner is empty: Assignment may have been lost — re-assign using the status guard from Phase 3 step 4Never re-assign a completed or in-progress task. This is the primary duplicate prevention mechanism.
If ENABLE_PROGRESS = true: Update the progress display as explorers complete: "[Phase 4/6] Focused Exploration — [completed]/[N] explorers complete"
Goal: Verify exploration completeness, launch synthesis with deep investigation.
If
ENABLE_PROGRESS = true: Display "[Phase 5/6] Synthesis — Merging findings and investigating gaps..."
This is a structural check, not a quality assessment:
TaskList to verify all exploration tasks are completedblockedBy listUse TaskUpdate to assign the synthesis task: owner: "synthesizer"
Send the synthesizer a message with exploration context and recon findings:
SendMessage type: "message", recipient: "synthesizer",
content: "All exploration tasks are complete. Your synthesis task is now assigned.
Analysis context: [analysis context]
Codebase path: [PATH]
Recon findings from planning phase:
- Project structure: [brief summary of directory layout]
- Primary language/framework: [what was detected]
- Key areas identified: [the focus areas and why they were chosen]
The workers are: [list of explorer names from the approved plan]. You can message them with follow-up questions if you find conflicts or gaps in their findings.
You have Bash access for deep investigation — use it for git history analysis, dependency trees, static analysis, or any investigation that Read/Glob/Grep can't handle.
Read the completed exploration tasks via TaskGet to access their reports, then synthesize into a unified analysis. Evaluate completeness before finalizing.",
summary: "Synthesis task assigned, begin work"
Wait for the synthesizer to mark the synthesis task as completed
Checkpoint (if ENABLE_CHECKPOINTING = true):
.claude/sessions/__da_live__/checkpoint.md: set current_phase: 5.claude/sessions/__da_live__/synthesis.md with the synthesis resultsprogress.md: [timestamp] Phase 5: Synthesis completeGoal: Collect results, present to user, and tear down the team.
If
ENABLE_PROGRESS = true: Display "[Phase 6/6] Completion — Collecting results and cleaning up..."
Collect synthesis output:
Write exploration cache (if CACHE_TTL > 0):
.claude/sessions/exploration-cache/ directory (overwrite if exists)manifest.md:
## Exploration Cache Manifest
- **analysis_context**: [the analysis context used]
- **codebase_path**: [current working directory]
- **timestamp**: [ISO timestamp]
- **config_checksum**: [comma-separated list of config files and their mod-times]
- **ttl_hours**: [CACHE_TTL value]
- **explorer_count**: [N]
synthesis.md with the full synthesis outputrecon_summary.md with the Phase 1 reconnaissance findingsexplorer-{N}-findings.md for each explorer's findings (if not already persisted from Phase 4 checkpoints)Present or return results:
Shutdown teammates: Send shutdown requests to all spawned teammates (iterate over the actual agents from the approved plan):
SendMessage type: "shutdown_request", recipient: "explorer-1", content: "Analysis complete"
SendMessage type: "shutdown_request", recipient: "explorer-2", content: "Analysis complete"
[... for each explorer spawned]
SendMessage type: "shutdown_request", recipient: "synthesizer", content: "Analysis complete"
Archive session and cleanup team:
ENABLE_CHECKPOINTING = true: Move .claude/sessions/__da_live__/ to .claude/sessions/da-{timestamp}/TeamDelete to remove the team and its task list.claude/agent-alchemy.local.md exists but is malformed or the deep-analysis section is unparseable: warn the user ("Settings file found but could not parse deep-analysis settings — using defaults") and proceed with default approval values.AskUserQuestion with options:
blockedByIf any phase fails:
When resuming from an interrupted session (detected in Phase 0 Step 2), use the following per-phase strategy:
| Interrupted At | Recovery Strategy |
|---|---|
| Phase 1 | Restart from Phase 1 (reconnaissance is fast, ~1-2 min) |
| Phase 2 | Load saved team_plan.md from session dir, re-present for approval |
| Phase 3 | Load approved plan from checkpoint, restart team assembly |
| Phase 4 | Read completed explorer-{N}-findings.md files from session dir. Only spawn and assign explorers whose findings files are missing. Add existing findings to synthesizer context. |
| Phase 5 | Load all explorer findings from session dir. Spawn a fresh synthesizer and launch synthesis with the persisted findings. |
| Phase 6 | Load synthesis.md from session dir. Proceed directly to present/return results and cleanup. |
Recovery procedure:
checkpoint.md to determine last_completed_phase and session state (team_name, explorer_names, task_ids)last_completed_phase + 1 using the loaded stateexplorer-{N}-findings.md files against expected explorer list to determine which explorers still need to runWhen calling Task tool for teammates:
model: "opus" for the synthesizermodel: "sonnet" for workersteam_name parameter to join the teamExpert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.