Perform in-depth architectural analysis of codebases through iterative dialog and visual diagrams. Use when users want to understand their software architecture, explore design patterns and anti-patterns, evaluate potential architectural changes, or gain deep insights into code structure and relationships. Particularly valuable for onboarding to unfamiliar codebases, assessing technical debt, planning refactoring efforts, or understanding how components interact across system boundaries.
moogah0 星標2026年3月6日
職業
分類
架構模式
技能內容
43:T3ec7,
Architecture Analyzer
Overview
This skill provides comprehensive architectural analysis through an iterative, dialog-driven approach. Rather than jumping directly into code details, it guides users from broad architectural understanding to specific areas of interest through structured conversation and visual diagrams.
The analysis examines code in the context of its language idioms, framework conventions, and intended purpose, comparing implementations against known design patterns and anti-patterns. The focus is on explaining the current design with insightful observations that help users make informed decisions about their architecture.
Analysis Workflow
Follow this five-phase approach to conduct thorough architectural analysis:
Phase 1: Establish Context
Begin with dialog to understand the user's needs and set appropriate scope:
Key questions to ask:
What is the purpose/domain of this software? (e.g., web API, CLI tool, data pipeline)
相關技能
What are you trying to understand or evaluate? (e.g., "how authentication works", "overall structure", "data flow")
What specific concerns do you have? (e.g., scalability, maintainability, technical debt)
What scope should we focus on? (e.g., entire codebase, specific subsystem, particular feature)
Examples of context-setting dialog:
User: "I inherited this codebase and need to understand it"
→ Ask: What will you be working on? What's the business domain? Any known pain points?
User: "Is our architecture good?"
→ Ask: What are your concerns? Performance? Maintainability? Are you planning changes?
User: "How does feature X work?"
→ Ask: Are you trying to modify it, debug it, or just understand it? Do you know what files are involved?
Phase 2: Broad Examination
Start with high-level architectural understanding before diving into specifics:
Examine in order:
Language & ecosystem - What language? What version? What are the idioms?
Frameworks & libraries - Core dependencies? Framework patterns being used?
Repository organization - Directory structure? Module/package layout? Separation of concerns?
Entry points - Where does execution begin? What are the main interfaces?
Major components - What are the top-level architectural pieces? How do they relate?
Data flow - How does data move through the system? What are the boundaries?
Configuration & environment - How is the system configured? What's externalized?
Tools to use:
Read directory structure and key files (README, package.json, setup.py, etc.)
Review configuration files to understand capabilities and dependencies
Look at top-level directories to understand modular organization
Provide observations like:
"This is a Django web application with a typical MTV (Model-Template-View) structure"
"The codebase follows a microservices pattern with 5 main services communicating via REST"
"This appears to be a monolithic architecture with business logic mixed into controllers - consider a service layer"
"The project uses dependency injection via a DI container, which is good for testability"
Phase 3: Visual Representation
Create appropriate diagrams to illustrate architectural findings. Use text-based formats (primarily Mermaid) that render well in CLI/markdown environments.
Component Diagram - Show major components and their relationships:
graph TB
Client[Web Client]
API[API Layer]
Auth[Auth Service]
BL[Business Logic]
DB[(Database)]
Cache[(Redis Cache)]
Client --> API
API --> Auth
API --> BL
BL --> DB
BL --> Cache
Auth --> DB
Data Flow Diagram - Illustrate how data moves through the system:
flowchart LR
Input[User Request] --> Validation[Input Validation]
Validation --> Transform[Data Transform]
Transform --> Process[Business Logic]
Process --> Persist[(Data Store)]
Process --> Response[JSON Response]
Layer Architecture Diagram - Show architectural layers:
graph TB
subgraph Presentation
UI[UI Components]
Controllers[Controllers]
end
subgraph Business
Services[Service Layer]
Domain[Domain Models]
end
subgraph Data
Repos[Repositories]
DB[(Database)]
end
UI --> Controllers
Controllers --> Services
Services --> Domain
Services --> Repos
Repos --> DB
Class/Module Hierarchy - Show inheritance or module relationships:
Sequence Diagram - Show interaction flows for complex operations:
sequenceDiagram
participant C as Client
participant A as API Gateway
participant S as Auth Service
participant B as Business Service
participant D as Database
C->>A: POST /api/resource
A->>S: Validate Token
S->>A: Token Valid
A->>B: Process Request
B->>D: Query Data
D->>B: Return Results
B->>A: Business Response
A->>C: JSON Response
Phase 4: Pattern Analysis
Identify design patterns, anti-patterns, and architectural characteristics:
ORM: Faster development, database agnostic; Performance overhead, complex queries hard
Raw SQL: Full control, optimized queries; Database lock-in, more code
Tight Coupling vs Over-Abstraction:
Coupled: Faster initial development, less code; Hard to change, poor testability
Abstracted: Flexible, testable; Can be over-engineered, more files/complexity
Dialog Best Practices
Guiding the Conversation
Start broad, then narrow:
Don't assume what the user wants to focus on
Present high-level findings first
Ask where they want to go deeper
Follow their interest, but suggest related areas they might miss
Ask clarifying questions:
"Are you looking to understand, modify, or evaluate?"
"What's your experience level with [framework/pattern]?"
"What's the business context for this analysis?"
"What timeline/constraints do you have?"
Provide context for observations:
Don't just say "this is a Factory pattern" - explain what it achieves and whether it's appropriate
Don't just flag anti-patterns - explain the impact and suggest alternatives
Don't just describe structure - explain the implications for their goals
Balance depth and breadth:
Provide enough detail to be useful, not so much it's overwhelming
Offer to dive deeper when relevant
Summarize before moving to new areas
Create clear sections/phases in the conversation
Making Recommendations
When evaluating architecture:
Focus on observations first, judgments second
Explain the "why" behind patterns you see
Suggest improvements as options, not mandates
Consider the team/project context (startup velocity vs enterprise stability)
When suggesting changes:
Acknowledge the current state's rationale (even if flawed)
Provide migration paths, not just end states
Consider risk vs reward
Offer incremental improvements, not just rewrites
Example dialog flow:
User: "Analyze my authentication system"
Ask: "Are you concerned about security, performance, or maintainability? Planning changes?"
User: "We need to add OAuth support"
Examine: Current auth implementation, where OAuth would integrate
Diagram: Show current flow and proposed flow with OAuth
Analyze: Identify current patterns (session-based), extension points, potential conflicts
Narrow: "The current session management in auth/sessions.py:89 will need to handle OAuth tokens differently. Should we explore that integration point?"
Continue: Based on user interest, dive into specific implementation considerations
Summary
Effective architectural analysis combines:
Dialog to understand user needs and guide exploration
Broad examination starting with high-level structure before details
Visual diagrams to communicate relationships and flows clearly
Pattern recognition to identify strengths and weaknesses
Contextual evaluation based on language, framework, and domain
Iterative narrowing to progressively focus on user interests
Balanced recommendations that consider trade-offs and constraints
The goal is not just to describe architecture, but to build understanding that enables informed decision-making about design, changes, and improvements.