ported/20260305-191444/skills/codebase-analysis/SKILL.md
Produce a structured codebase analysis report with architecture overview, critical files, patterns, and actionable recommendations.
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 explorer agents used (from the deep-analysis team plan, or 0 if cached)Goal: Present a structured analysis to the user.
Load diagram guidance:
Load 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 (multiple selections allowed):
Then prompt the user for 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 prompt the user to choose:
If approved, apply updates to the files.
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.
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 a file write or edit fails when applying documentation updates:
If a code-architect or code-explorer agent fails during actionable insight processing:
Exploration and synthesis agent 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 the team, and manages the exploration/synthesis lifecycle. See that skill for team setup, approval flow, agent model tiers, and failure handling details.
Use this template 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 (flowchart or C4 Context) showing the major layers/components. Use `classDef` with `color:#000` for all node styles. Example:}
```mermaid
flowchart TD
subgraph presentation["Presentation"]
A[Web UI]:::primary
end
subgraph application["Application"]
B[API Server]:::secondary
end
subgraph data["Data"]
C[(Database)]:::neutral
end
A --> B --> C
classDef primary fill:#dbeafe,stroke:#2563eb,color:#000
classDef secondary fill:#f3e8ff,stroke:#7c3aed,color:#000
classDef neutral fill:#f3f4f6,stroke:#6b7280,color:#000
| 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 | | Styling | {e.g., Tailwind CSS} | {e.g., v4} | UI styling | | Testing | {e.g., Jest} | — | Test runner | | Build | {e.g., esbuild} | — | Bundler |
{Include only technologies actually detected in config files or code. Omit categories that don't apply.}
{Limit to 5-10 most important files}
| File | Purpose | Relevance |
|------|---------|-----------|
| path/to/file | Brief description | High/Medium |
path/to/critical-file{Describe how key components connect — limit to 15-20 most significant connections. Use Mermaid flowcharts for both data flows and dependency maps.}
Data Flow:
flowchart LR
A[Input]:::primary --> B[Processing]:::secondary --> C[Output]:::success
classDef primary fill:#dbeafe,stroke:#2563eb,color:#000
classDef secondary fill:#f3e8ff,stroke:#7c3aed,color:#000
classDef success fill:#dcfce7,stroke:#16a34a,color:#000
Component Dependencies:
flowchart LR
A[Component A]:::primary -->|calls| B[Component B]:::primary
C[Module]:::secondary -->|depends on| D[Service]:::secondary
classDef primary fill:#dbeafe,stroke:#2563eb,color:#000
classDef secondary fill:#f3e8ff,stroke:#7c3aed,color:#000
Cross-Cutting Concerns:
flowchart RL
A[Component A]:::primary --> L[Logger]:::neutral
B[Component B]:::primary --> L
C[Module]:::secondary --> L
classDef primary fill:#dbeafe,stroke:#2563eb,color:#000
classDef secondary fill:#f3e8ff,stroke:#7c3aed,color:#000
classDef neutral fill:#f3f4f6,stroke:#6b7280,color:#000
{For complex architectures, group connections by subsystem using subgraphs rather than listing individually}
| Challenge | Severity | Impact | |-----------|----------|--------| | {Description} | High/Medium/Low | {What could go wrong} |
---
### Section Guidelines
#### Executive Summary
- Lead with the most important finding, not a generic overview
- Keep to 2-3 sentences maximum
- Include at least one actionable insight
#### Critical Files
- Limit to 5-10 files — these should be the files someone must understand
- Include both the "what" (purpose) and "why" (relevance to analysis context)
- File Details should cover exports, logic, and connections
#### Patterns & Conventions
- Only include patterns that are consistently applied (not one-off occurrences)
- Note deviations from patterns — these are often more interesting than the patterns themselves
#### Relationship Map
- Focus on the most important connections, not an exhaustive dependency graph
- Use directional language (calls, depends on, triggers, reads from)
- Highlight any circular dependencies or unexpected couplings
- **Depth**: Include 2-3 levels of dependency depth — direct dependencies and their key subdependencies
- **Format**: Use Mermaid flowcharts for both linear flows and complex dependency webs. Apply `classDef` with `color:#000` for readability.
- **Scope limit**: Cap at 15-20 connections. If more exist, group related connections under subsystem labels.
#### Challenges & Risks
- Rate severity based on likelihood and impact combined
- Include specific details, not vague warnings
- Focus on challenges relevant to the analysis context
#### Recommendations
- Make recommendations actionable — "consider" is weaker than "use X for Y"
- **Cite source challenge**: Each recommendation must reference the specific challenge it addresses using the format: _(addresses: {Challenge name})_. This creates reliable severity links for the actionable insights step.
- Limit to 3-5 recommendations to maintain focus
---
### Adapting the Template
#### For Feature-Focused Analysis
- Emphasize integration points and files that would need modification
- Include a "Feature Implementation Context" section before Recommendations
- Focus Challenges on implementation risks
#### For General Codebase Understanding
- Broader Architecture Overview with layer descriptions
- More extensive Patterns & Conventions section
- Focus Recommendations on areas for improvement or further investigation
#### For Debugging/Investigation
- Emphasize the execution path and data flow
- Include a "Relevant Execution Paths" section
- Focus Critical Files on the suspected problem area
---
## Actionable Insights Template
# Actionable Insights Template
Use this template when presenting and processing actionable items in Phase 3's "Address Actionable Insights" action.
---
### Item List Format
Present extracted items grouped by severity, highest first:
```markdown
### High Severity
1. **{Title}** — _{Source: Challenges & Risks}_
{Brief description of the issue and its impact}
2. **{Title}** — _{Source: Recommendations}_
{Brief description and rationale}
### Medium Severity
3. **{Title}** — _{Source: Recommendations}_
{Brief description and rationale}
### Low Severity
4. **{Title}** — _{Source: Other Findings}_
{Brief description}
Provide rough effort alongside complexity to help users prioritize:
| 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 |
Present each proposed fix using this structure:
#### {Item Title} ({Severity})
**Complexity:** Simple / Complex (architectural) / Complex (investigation)
**Effort:** Low (~minutes) / Medium (~30min) / High (~1hr+)
**Files to modify:**
| File | Change Type |
|------|-------------|
| `path/to/file` | Edit / Create / Delete |
**Proposed changes:**
{Description of what will change and why. For simple fixes, show the specific code changes. For complex fixes, describe the approach.}
**Rationale:**
{Why this approach was chosen. Reference the original finding.}
After processing all selected items, present:
## Actionable Insights Summary
### Items Addressed
| # | Item | Severity | Files Modified |
|---|------|----------|----------------|
| 1 | {Title} | High | `file1.ts`, `file2.ts` |
| 2 | {Title} | Medium | `file3.ts` |
### Items Skipped
| # | Item | Severity | Reason |
|---|------|----------|--------|
| 3 | {Title} | Low | User skipped |
### Files Modified
| File | Changes |
|------|---------|
| `path/to/file` | {Brief description of change} |
**Total:** {N} items addressed, {M} items skipped, {P} files modified
What this component does: Wraps the deep-analysis skill with structured reporting, post-analysis actions (save reports, update docs, retain insights), and an actionable insights workflow for addressing findings.
Capabilities needed:
Adaptation guidance:
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.