Deep Analysis Workflow
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 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 a configuration file exists for the project
- If it exists, look for a
deep-analysissection with these settings: direct-invocation-approval: Whether to require approval when invoked directly (default:true)invocation-by-skill-approval: Whether to require approval when loaded by another skill (default:false)cache-ttl-hours: Hours before exploration cache expires; 0 disables caching (default:24)enable-checkpointing: Write session checkpoints at phase boundaries (default:true)enable-progress-indicators: Display phase progress messages (default:true)
- Determine invocation mode:
- Direct invocation: The user invoked deep-analysis directly or standalone
- Skill-invoked: Another skill (e.g., codebase-analysis, feature-dev, docs-manager) loaded and is executing this workflow
- Resolve settings:
- Use found settings, or defaults if absent
- If the file is malformed, warn the user and use defaults
- Set behavioral flags:
REQUIRE_APPROVAL= direct-invocation-approval (if direct) or invocation-by-skill-approval (if skill-invoked)CACHE_TTL= cache-ttl-hours valueENABLE_CHECKPOINTING= enable-checkpointing valueENABLE_PROGRESS= enable-progress-indicators value
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 = 0 AND ENABLE_CHECKPOINTING = false.
Step 1: Exploration Cache Check
If CACHE_TTL > 0:
- Check if
.agents/sessions/exploration-cache/manifest.mdexists - If found, read the manifest and verify:
analysis_contextmatches the current analysis context (or is a superset)codebase_pathmatches the current working directorytimestampis withinCACHE_TTLhours of now- Config files referenced in
config_checksumhave not been modified since the cache was written (check mod-times ofpackage.json,tsconfig.json,pyproject.toml, etc.) - If cache is valid:
- Skill-invoked mode: Auto-accept the cache. Set
CACHE_HIT = true. Read cachedsynthesis.mdandrecon_summary.md. Skip to Phase 6 step 2 (present/return results). - Direct invocation: Prompt the user to choose:
- Use cached results — Set
CACHE_HIT = true, skip to Phase 6 step 2 - Refresh analysis — Set
CACHE_HIT = false, proceed normally - If cache is invalid or absent: Set
CACHE_HIT = false
Step 2: Interrupted Session Check
If ENABLE_CHECKPOINTING = true:
- Check if
.agents/sessions/__da_live__/checkpoint.mdexists - 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 (see Session Recovery in Error Handling)
- Start fresh — Archive the interrupted session to
.agents/sessions/da-interrupted-{timestamp}/and proceed normally - If not found: proceed normally
Step 3: Initialize Session Directory
If ENABLE_CHECKPOINTING = true AND CACHE_HIT = false:
- Create
.agents/sessions/__da_live__/directory - Write
checkpoint.md:
```markdown ## Deep Analysis Session
- analysis_context: [context from arguments or caller]
- codebase_path: [current working directory]
- started: [ISO timestamp]
- current_phase: 0
- status: initialized
```
- Write
progress.md:
```markdown ## Deep Analysis Progress
- Phase: 0 of 6
- Status: Session initialized
### Phase Log
- [timestamp] Phase 0: Session initialized
```
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 (feature area, question, or general exploration goal)
- 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"
- Set
PATH = current working directory - Inform the user: "Exploring codebase at:
PATH" with the analysis context
- Rapid codebase reconnaissance:
Quickly map the codebase structure. This should take 1-2 minutes, not deep investigation.
- Directory structure: List top-level directories to understand the project layout
- Language and framework detection: Read config files (
package.json,tsconfig.json,pyproject.toml,Cargo.toml,go.mod, etc.) to identify primary language(s) and framework(s) - File distribution: Search for files with patterns like
src/**/*.ts,**/*.pyto 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 (function names, component names, route paths) 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 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:
- 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
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 con