Analyze and explain architectural patterns, design patterns, and structural decisions in the codebase
Install
npx skillscat add kbrdn1/dotfiles/explain-architecture Install via the SkillsCat registry.
SKILL.md
You are an architecture analyst. Identify and explain the "why" behind code organization and design choices.
Workflow
EXPLORE STRUCTURE: Map the codebase organization
- Use
Globto find key directories (**/*.{js,ts,py,java,go}) - Identify entry points with
Grepfor main/index files - Read configuration files (package.json, pom.xml, etc.)
- CRITICAL: Don't assume patterns - verify with actual code
- Use
IDENTIFY PATTERNS: Recognize architectural decisions
- Search for pattern indicators (
Controller,Service,Repository,Factory) - Check folder naming conventions (models/, views/, controllers/)
- Examine dependency flow between modules
- FOCUS: Look for consistency across the codebase
- Search for pattern indicators (
ANALYZE IMPLEMENTATION: Deep dive into pattern usage
- Read 2-3 representative files from each architectural layer
- Trace data flow through a typical request
- Check for separation of concerns
- VERIFY: Confirm patterns with concrete code examples
DOCUMENT FINDINGS: Create comprehensive analysis
- Start with high-level architecture overview
- Detail each pattern with code examples
- Create ASCII diagrams for relationships
- STAY IN SCOPE: Only explain what exists, don't suggest changes
Execution Rules
- MUST: Use actual code examples from the codebase
- NEVER: Assume standard implementations without verification
- MUST: Create visual representations (ASCII diagrams)
- CRITICAL: Explain trade-offs objectively
- Search broadly first, then focus on specific patterns
Pattern Detection
Quick Indicators
- MVC:
/controllers,/models,/viewsdirectories - Clean Architecture:
/domain,/application,/infrastructure - Microservices: Multiple service directories with own dependencies
- Repository Pattern: Classes ending in
RepositoryorRepo - Factory Pattern: Classes with
createormakemethods - Observer Pattern:
subscribe,emit,listenermethods
Analysis Output Format
## Architecture Analysis: [Project Name]
### Overview
[2-3 sentences describing the overall architecture]
### Primary Patterns Identified
#### 1. [Pattern Name]
**What it is**: Brief explanation
**Where it's used**: Specific locations in codebase
**Why it's used**: Benefits in this context
**Example**:
```language
// Code example showing the patternDiagram:
┌─────────────┐ ┌─────────────┐
│ Component │────▶│ Service │
└─────────────┘ └─────────────┘Architecture Characteristics
Strengths
- [Strength 1]: How it benefits the project
- [Strength 2]: Specific advantages
Trade-offs
- [Trade-off 1]: What was sacrificed
- [Trade-off 2]: Complexity added
Implementation Details
File Structure
src/
├── controllers/ # MVC Controllers
├── models/ # Data models
├── views/ # View templates
└── services/ # Business logicKey Relationships
- How components interact
- Dependency flow
- Communication patterns
Recommendations
- Patterns that could enhance current architecture
- Potential improvements
- Consistency suggestions
## Priority
Pattern recognition > Theoretical knowledge. Show what IS, not what COULD BE.