Deep analysis

From sequenzia/agent-alchemy · View interactive version

Deep analysis is an AI agent skill from the GitHub repository sequenzia/agent-alchemy. Deep exploration and synthesis workflow with dynamic planning and hub-and-spoke coordination. Use for deep analysis, deep understanding, or codebase investigation.

How to use this skill

Skill file

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.

  1. Read settings:
  1. Determine invocation mode:
  1. Resolve settings:
  1. Set REQUIRE_APPROVAL:
  1. Parse session settings (also under the deep-analysis section):
  1. Set behavioral flags:

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:

  1. Check if .agents/sessions/exploration-cache/manifest.md exists
  2. If found, read the manifest and verify:
  1. If cache is valid:
  1. If cache is invalid or absent: Set CACHE_HIT = false

Step 2: Interrupted Session Check

If ENABLE_CHECKPOINTING = true:

  1. Check if .agents/sessions/__da_live__/checkpoint.md exists
  2. If found, read the checkpoint to determine last_completed_phase
  3. Prompt the user to choose:
  1. If not found: proceed normally

Step 3: Initialize Session Directory

If ENABLE_CHECKPOINTING = true AND CACHE_HIT = false:

  1. Create .agents/sessions/__da_live__/ directory
  2. Write checkpoint.md:

```markdown

## Deep Analysis Session

```

  1. Write progress.md:

```markdown

## Deep Analysis Progress

### Phase Log

```


Phase 1: Reconnaissance & Planning

Goal: Perform codebase reconnaissance, generate dynamic focus areas, and compose a team plan.

  1. Determine analysis context:
  1. Rapid codebase reconnaissance:

Quickly map the codebase structure. This should take 1-2 minutes, not deep investigation.

Fallback: If reconnaissance fails (empty project, unusual structure, errors), use the static focus area templates from Step 3b.

  1. 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:

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

```

  1. Compose the team plan:

Assemble a structured plan document from the reconnaissance and focus area findings:

```markdown

## Team Plan: Deep Analysis

### Analysis Context

[context from Step 1]

### Reconnaissance Summary

### Focus Areas

#### Focus Area 1: [Label]

#### Focus Area 2: [Label]

[... repeated for each focus area]

### Worker Composition

| Role | Count | Purpose |

|------|-------|---------|

| Explorer | [N] | Independent focus area exploration |

| Synthesizer | 1 | Merge findings, deep investigation |

### Task Dependencies

```

  1. Checkpoint (if ENABLE_CHECKPOINTING = true):

Phase 2: Review & Approval

Goal: Present the team plan for user review and approval before allocating resources.

If `REQUIRE_APPROVAL = false`

Skip to Phase 3 with a brief note: "Auto-approving team plan (skill-invoked mode). Proceeding with [N] explorers and 1 synthesizer."

If `REQUIRE_APPROVAL = true`

  1. Present the team plan to the user (output the plan from Phase 1 Step 4), then prompt the user to choose:
  1. If "Modify" (up to 3 cycles):
  1. If "Regenerate" (up to 2 cycles):
  1. Checkpoint (if ENABLE_CHECKPOINTING = true):

Phase 3: Team Assembly

Goal: Set up workers, create tasks, and assign work using the approved plan.

  1. Prepare workers:

Based on the approved plan, prepare the following workers:

  1. Create tasks:

For each focus area, create an exploration task with: subject ("Explore: [Focus area label]"), detailed exploration instructions including directories, starting files, search terms, and complexity estimate.

Create a synthesis task: "Synthesize and evaluate exploration findings" -- blocked by all exploration tasks.

  1. Assign exploration tasks:

For each exploration task, delegate to the corresponding explorer worker with the task details: focus area label, directories, starting files, and search patterns.

  1. Checkpoint (if ENABLE_CHECKPOINTING = true):

Phase 4: Focused Exploration

Goal: Workers explore their assigned areas independently.

Monitoring

After assigning exploration tasks, monitor progress:

  1. When an explorer completes, record their findings. If ENABLE_CHECKPOINTING = true, write explorer-{N}-findings.md to .agents/sessions/__da_live__/ and update checkpoint.
  2. Workers explore independently -- no cross-worker communication (hub-and-spoke topology)
  3. Workers can respond to follow-up questions from the synthesizer
  4. Each worker marks its task as completed when done
  5. 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

This is a structural check, not a quality assessment:

  1. Verify all exploration tasks are completed
  2. Check that each worker produced a report with content
  3. If a worker failed completely (empty or error output):
  1. If all produced content: proceed immediately to Step 2

Step 2: Launch Synthesis

  1. Assign the synthesis task to the synthesizer worker
  2. Provide the synthesizer with:
  1. The synthesizer has shell access for deep investigation -- git history analysis, dependency trees, static analysis, or any investigation that basic file reading cannot handle
  2. Wait for the synthesizer to complete
  1. Checkpoint (if ENABLE_CHECKPOINTING = true):

Phase 6: Completion + Cleanup

Goal: Collect results, present to user, and clean up.

  1. Collect synthesis output:
  1. Write exploration cache (if CACHE_TTL > 0):

```markdown

## Exploration Cache Manifest

```

  1. Present or return results:
  1. Shut down workers:

Signal all workers that analysis is complete and they can stop.

  1. Archive session and cleanup:

Error Handling

Settings Check Failure

Planning Phase Failure

Approval Phase Failure

Partial Worker Failure

Synthesizer Failure

General Failures

If any phase fails:

  1. Explain what went wrong
  2. Ask the user how to proceed:

Session Recovery

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 assign explorers whose findings files are missing. Add existing findings to synthesizer context. |

| Phase 5 | Load all explorer findings from session dir. Launch a fresh synthesizer with the persisted findings. |

| Phase 6 | Load synthesis.md from session dir. Proceed directly to present/return results and cleanup. |

Recovery procedure:

  1. Read checkpoint.md to determine last_completed_phase and session state (worker names, task assignments)
  2. Load any persisted artifacts from the session directory (team_plan, explorer findings, synthesis)
  3. Resume from Phase last_completed_phase + 1 using the loaded state
  4. For Phase 4 recovery: compare persisted explorer-{N}-findings.md files against expected explorer list to determine which explorers still need to run

Coordination

Integration Notes

What this component does: Orchestrates a multi-phase deep analysis workflow: reconnaissance, dynamic planning, user approval, parallel exploration via independent workers, synthesis with deep investigation, caching, and session checkpointing/recovery.

Origin: Skill (orchestrator, keystone)

Capabilities needed:

Adaptation guidance:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.