Codebase analysis

From sequenzia/agent-alchemy · View interactive version

Codebase analysis is an AI agent skill from the GitHub repository sequenzia/agent-alchemy. Produce a structured codebase analysis report with architecture overview, critical files, patterns, and actionable recommendations. Use when asked to "analyze codebase", "explore codebase", "understand this codebase", "map the codebase", "give me an overview of this project", "what does this codebas

How to use this skill

Skill file

Codebase Analysis Workflow

Execute a structured 3-phase codebase analysis workflow to gather insights.

CRITICAL: Complete ALL 3 phases. The workflow is not complete until Phase 3: Post-Analysis Actions is finished. After completing each phase, immediately proceed to the next phase without waiting for user prompts.

Phase Overview

  1. Deep Analysis — Explore and synthesize codebase findings via deep-analysis skill
  2. Reporting — Present structured analysis to the user
  3. Post-Analysis Actions — Save, document, or retain analysis insights

Phase 1: Deep Analysis

Goal: Explore the codebase and synthesize findings.

  1. Determine analysis context:
  1. Check for cached results:
  1. Run deep-analysis workflow:
  1. Verify results and capture metadata:

Phase 2: Reporting

Goal: Present a structured analysis to the user.

  1. Load diagram guidance:
  1. Load report template:
  1. Present the analysis:

Structure the report with these sections:

  1. IMPORTANT: Proceed immediately to Phase 3.

Do NOT stop here. Do NOT wait for user input. The report is presented, but the workflow requires Post-Analysis Actions. Continue directly to Phase 3 now.


Phase 3: Post-Analysis Actions

Goal: Let the user save, document, or retain analysis insights from the report through a multi-step interactive flow.

Step 1: Select actions

Use AskUserQuestion with multiSelect: true to present all available actions:

If the user selects no actions, the workflow is complete. Thank the user and end.

Step 2: Execute selected actions

Process selected actions in the following fixed order. Complete all sub-steps for each action before moving to the next.

Action: Save Codebase Analysis Report

Step 2a-1: Prompt for file location

Step 2a-2: Generate and save the report

Action: Save Custom Report

Step 2b-1: Gather report requirements

Step 2b-2: Prompt for file location

Step 2b-3: Generate and save the custom report

Action: Update Project Documentation

Step 2c-1: Select documentation files and gather directions

Use AskUserQuestion with multiSelect: true:

Then use a single AskUserQuestion to gather update directions for all selected files: "What content from the analysis should be added or updated? Provide general directions or specific sections to focus on (applies across all selected files, or specify per-file directions)."

Step 2c-2: Generate and approve documentation drafts

For each selected file, read the existing file and generate a draft based on the user's directions and Phase 2 analysis data:

Present all drafts together in a single output, clearly labeled by file. Then use AskUserQuestion:

If approved, apply updates using Edit tool (existing files) or Write tool (new files).

Action: Keep Insights in Memory

Step 3: Actionable Insights Follow-up

Condition: This step always executes after Step 2 completes. The Phase 2 analysis is available in conversation context regardless of whether a report file was saved.

Use AskUserQuestion to ask:

If the user selects "Skip", proceed to Step 4.

If the user selects "Address actionable insights":

Step 3a: Extract actionable items from the report

Parse the Phase 2 report (in conversation context) to extract items from:

If no actionable items are found, inform the user and skip to Step 4.

Step 3b: Present severity-ranked item list

Step 3c: Process each selected item in priority order (High → Medium → Low)

For each item:

  1. Assess complexity:
  1. Plan the fix:
  1. Present proposal: Show files to modify, specific changes, and rationale
  1. User approval via AskUserQuestion:

Step 3d: Summarize results

Present a summary covering:

Step 4: Complete the workflow

Summarize which actions were executed and confirm the workflow is complete.


Error Handling

General

If any phase fails:

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

Documentation Update Failures (Step 2c)

If an Edit or Write call fails when applying documentation updates:

  1. Retry the operation once
  2. If still failing, present the drafted content to the user inline and suggest they apply it manually
  3. Continue with the remaining selected files

Agent Launch Failures (Step 3c)

If a code-architect or code-explorer agent fails during actionable insight processing:

  1. Fall back to direct investigation using Read, Glob, and Grep
  2. Propose a simpler fix based on available information
  3. If the item is too complex to address without agent assistance, inform the user and offer to skip

Agent Coordination

Exploration and synthesis agent coordination is handled by the deep-analysis skill in Phase 1, which uses Agent Teams with hub-and-spoke coordination. Deep-analysis performs reconnaissance, composes a team plan (auto-approved when invoked by another skill), assembles the team, and manages the exploration/synthesis lifecycle. See that skill for team setup, approval flow, agent model tiers, and failure handling details.


Additional Resources

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.