ported/20260304-102613/core-tools/skills/codebase-analysis/SKILL.md
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 codebase do", "codebase report", "project analysis", "audit this codebase", or "how is this project structured".
npx skillsauth add sequenzia/agent-alchemy codebase-analysisInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Execute a structured 3-phase codebase analysis workflow to gather insights.
Goal: Explore the codebase and synthesize findings.
Determine analysis context:
Check for cached results:
.agents/sessions/exploration-cache/manifest.md existscodebase_path matches the current working directory, and timestamp is within the configured cache TTL (default 24 hours).agents/sessions/exploration-cache/synthesis.md and recon from recon_summary.md. Set CACHE_HIT = true and CACHE_TIMESTAMP to the cache's timestamp. Skip step 3 and proceed directly to step 4.CACHE_HIT = false, and proceed to step 3CACHE_HIT = false and proceed to step 3Run deep-analysis workflow:
CACHE_TIMESTAMP = null (fresh results, no prior cache)Verify results and capture metadata:
CACHE_HIT), cache timestamp if applicable (CACHE_TIMESTAMP), and the number of exploration workers used (from the deep-analysis team plan, or 0 if cached)Goal: Present a structured analysis to the user.
Load diagram guidance:
Use report template:
Present the analysis: Structure the report with these sections:
Proceed immediately to Phase 3.
Goal: Let the user save, document, or retain analysis insights from the report through a multi-step interactive flow.
Prompt the user to choose (multiple selections allowed):
If the user selects no actions, the workflow is complete. Thank the user and end.
Process selected actions in the following fixed order. Complete all sub-steps for each action before moving to the next.
Step 2a-1: Prompt for file location
internal/docs/ directory exists in the project root
internal/docs/codebase-analysis-report-{YYYY-MM-DD}.mdcodebase-analysis-report-{YYYY-MM-DD}.md in the project rootStep 2a-2: Generate and save the report
Step 2b-1: Gather report requirements
Step 2b-2: Prompt for file location
internal/docs/ directory exists in the project root
internal/docs/custom-report-{YYYY-MM-DD}.mdcustom-report-{YYYY-MM-DD}.md in the project rootStep 2b-3: Generate and save the custom report
Step 2c-1: Select documentation files and gather directions
Prompt the user to choose which files to update (multiple selections allowed):
Then ask the user: "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 prompt the user to choose:
If approved, apply updates.
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.
Prompt the user to choose:
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:
Assess complexity:
Plan the fix:
Present proposal: Show files to modify, specific changes, and rationale
User approval -- prompt the user to choose:
Step 3d: Summarize results
Present a summary covering:
Summarize which actions were executed and confirm the workflow is complete.
If any phase fails:
If writing documentation updates fails:
If an architecture or exploration specialist fails during actionable insight processing:
Exploration and synthesis coordination is handled by the deep-analysis skill in Phase 1, which uses hub-and-spoke coordination. Deep-analysis performs reconnaissance, composes a team plan (auto-approved when invoked by another skill), assembles workers, and manages the exploration/synthesis lifecycle. See that skill for team setup, approval flow, and failure handling details.
Use this structure when presenting analysis findings in Phase 2.
# Codebase Analysis Report
**Analysis Context**: {What was analyzed and why}
**Codebase Path**: {Path analyzed}
**Date**: {YYYY-MM-DD}
{If the report exceeds approximately 100 lines, add a **Table of Contents** here linking to each major section.}
---
## Executive Summary
{Lead with the most important finding. 2-3 sentences covering: what was analyzed, the key architectural insight, and the primary recommendation or risk.}
---
## Architecture Overview
{2-3 paragraphs describing:}
- How the codebase is structured (layers, modules, boundaries)
- The design philosophy and architectural style
- Key architectural decisions and their rationale
{Include a Mermaid architecture diagram showing the major layers/components. Follow technical-diagrams styling rules.}
---
## Tech Stack
| Category | Technology | Version (if detected) | Role |
|----------|-----------|----------------------|------|
| Language | {e.g., TypeScript} | {e.g., 5.x} | Primary language |
| Framework | {e.g., Next.js} | {e.g., 16} | Web framework |
{Include only technologies actually detected in config files or code.}
---
## Critical Files
{Limit to 5-10 most important files}
| File | Purpose | Relevance |
|------|---------|-----------|
| `path/to/file` | Brief description | High/Medium |
### File Details
#### `path/to/critical-file`
- **Key exports**: What this file provides to others
- **Core logic**: What it does
- **Connections**: What depends on it and what it depends on
---
## Patterns & Conventions
### Code Patterns
- **Pattern**: Description and where it's used
### Naming Conventions
- **Convention**: Description and examples
### Project Structure
- **Organization**: How files and directories are organized
---
## Relationship Map
{Describe how key components connect. Use Mermaid flowcharts for data flows and dependency maps. Cap at 15-20 connections.}
---
## Challenges & Risks
| Challenge | Severity | Impact |
|-----------|----------|--------|
| {Description} | High/Medium/Low | {What could go wrong} |
---
## Recommendations
1. **{Recommendation}** _(addresses: {Challenge name})_: {Brief rationale}
2. **{Recommendation}** _(addresses: {Challenge name})_: {Brief rationale}
---
## Analysis Methodology
- **Exploration workers**: {Number} workers with focus areas: {list}
- **Synthesis**: Findings merged and critical files read in depth
- **Scope**: {What was included and what was intentionally excluded}
- **Cache status**: {Fresh analysis / Cached results from YYYY-MM-DD}
classDef and color:#000. Cap at 15-20 connections.Present extracted items grouped by severity, highest first:
From Challenges & Risks Table: Use the Severity column value directly.
From Recommendations Section: Use the cited challenge's severity. If no citation, default to Medium.
From Other Findings: Default to Low unless explicitly critical.
| Complexity | Typical Effort | Description | |-----------|---------------|-------------| | Simple | Low (~minutes) | Single targeted change, clear fix | | Complex -- Architectural | Medium-High (~30min-1hr+) | Multi-file refactoring, design decisions | | Complex -- Investigation | Medium (~15-30min) + varies | Investigation phase + fix implementation |
After processing all selected items:
| # | Item | Severity | Files Modified |
|---|------|----------|----------------|
| 1 | {Title} | High | file1.ts, file2.ts |
Total: {N} items addressed, {M} items skipped, {P} files modified
What this component does: Orchestrates a full codebase analysis workflow: exploration via deep-analysis, structured reporting with Mermaid diagrams, interactive post-analysis actions (save reports, update docs, address insights), and actionable insight processing with complexity-based specialist delegation.
Origin: Skill (orchestrator)
Capabilities needed:
Adaptation guidance:
AskUserQuestion calls with structured YAML options. Adapt to whatever user interaction mechanism the target harness provides.development
Systematic, hypothesis-driven debugging workflow with triage-based track routing. Use when asked to "fix this bug", "debug this", "why is this failing", "this is broken", "investigate this error", "track down this issue", or any debugging situation. Supports --deep flag to force full investigation.
development
Executes diagnostic investigation tasks to test debugging hypotheses. Runs tests, traces execution, checks git history, and reports evidence. (converted from agent)
content-media
Provides architectural pattern knowledge for designing feature implementations including MVC, event-driven, microservices, and CQRS patterns. Use when designing system architecture or choosing implementation patterns.
documentation
Provides Mermaid diagram syntax, best practices, and styling rules for technical visualizations. Use when creating diagrams, flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, architecture diagrams, C4 diagrams, or any visual documentation in markdown.