| name | Analyze Codebase |
| allowed-tools | Bash, Read, Write |
| description | Generate a developer-focused codebase_analysis.md |
Analyze Codebase (Modular Templates)
Follow the Workflow for the FOLDER_PATH then Report the completed work.
Variables
FOLDER_PATH: (to be provided by user)
Workflow
If no FOLDER_PATH is provided, STOP immediately and ask the user to provide it.
Step 1: Project Detection & Template Loading
First, analyze the target directory to detect project type and load appropriate templates:
- Scan for key indicator files in the target directory
- Load base analysis template from
.assets/base.md - Load technology-specific templates based on detection
- Merge templates into comprehensive analysis structure
Step 2: Technology Detection Logic
Detect project types by scanning for these files:
- MCP Server:
package.jsoncontains@modelcontextprotocol/sdk - Next.js:
next.config.jsornext.config.tsexists - Cloudflare Worker:
wrangler.tomlorwrangler.jsoncexists - React App:
package.jsoncontainsreact - TypeScript:
tsconfig.jsonexists - Jest Testing:
jest.config.jsorjest.config.cjsexists - iOS App:
Package.swiftor*.xcodeprojexists - Python:
requirements.txtorpyproject.tomlexists
Step 3: Template Integration
For each detected technology, read the corresponding template file:
Base Template: Always include /assets/base.md
Technology Templates (include if detected):
- MCP Server →
/assets/mcp-server.md - Next.js →
/assets/nextjs.md - Cloudflare Workers →
/assets/cloudflare-worker.md - TypeScript →
/assets/typescript.md - Jest →
/assets/jest-testing.md - iOS →
/assets/ios-swift.md
Step 4: Execute Comprehensive Analysis
Using the merged template structure, analyze the codebase following these sections:
- Project Overview (from base template)
- Technology-Specific Analysis (from detected templates)
- Directory Structure Analysis (enhanced by tech templates)
- File-by-File Breakdown (guided by tech-specific patterns)
- Architecture Deep Dive (incorporating tech-specific patterns)
- Testing Analysis (if testing framework detected)
- Deployment Analysis (if deployment config detected)
- Technology Stack Breakdown (comprehensive based on detections)
- Visual Architecture Diagram (enhanced with tech-specific components)
- Key Insights & Recommendations (tech-specific improvements)
Step 5: Create Analysis Document
Create a comprehensive codebase_analysis.md that includes:
- Detected technologies and their specific analysis sections
- Integration between different technology stacks
- Technology-specific recommendations and best practices
Report
# [Project Name] Modular Codebase Analysis
> Modular Codebase Analysis - Last updated: [timestamp]
> Detected Technologies: [list of detected tech stack]
## Technology Detection Results
- **Project Type**: [Primary type based on detection]
- **Tech Stack**: [All detected technologies]
- **Templates Applied**: [List of templates that were merged]
## Quick Reference
### Primary Entry Points
[Technology-specific entry points based on detected stack]
### Key Integration Files
[Files specific to detected technologies]
### Common Patterns
[Patterns from merged templates]
## Testing Focus
[Testing analysis based on detected framework]
## Environment Setup
[Environment information based on detected deployment type]
## Debug Tips
[Debug information specific to detected technologies]
## Technology-Specific Insights
[Insights from each applied template]
Example Usage
When you run this command on the compass project:
Detection Phase:
- Finds
wrangler.jsonc→ Cloudflare Worker detected - Finds
@modelcontextprotocol/sdkin package.json → MCP Server detected - Finds
jest.config.cjs→ Jest testing detected - Finds
tsconfig.json→ TypeScript detected
- Finds
Template Loading:
- Read
/assets/base.md - Read
/assets/mcp-server.md - Read
/assets/cloudflare-worker.md - Read
/assets/typescript.md - Read
/assets/jest-testing.md
- Read
Merged Analysis: Creates comprehensive analysis combining all templates
This approach ensures you get the right analysis depth for each project's specific technology stack.