explain-architecture-pattern — Claude Code command
The explain-architecture-pattern command identifies architecture and design patterns in a codebase, then explains the structure behind them. Use it when the project’s organization needs a clear rationale.
MIT ★ 2,744 updated 2026-10-08
.claude/commands/explain-architecture-pattern.mdWhat explain-architecture-pattern does
The command examines folders, filenames, and relationships between modules. It identifies architectural and design patterns, describes where they appear, and explains why the current structure may have been chosen.
Claude Code can use the analysis to describe data flow, module boundaries, dependencies, integrations, and file organization. Its response may include Markdown, ASCII diagrams, and code examples, along with strengths, trade-offs, and possible improvements.
The result depends on the project structure and the relationships visible in the codebase. Hidden or inaccessible parts of the project cannot contribute to the explanation.
What it helps with
- identify the architecture pattern used in a project
- explain folder structure and module boundaries
- trace requests, events, and data transformations
- show how a Repository or CQRS pattern is implemented
- compare architectural benefits with added trade-offs
Example prompts for the agent
- Explain the architecture pattern used in this project.
- Check whether this codebase follows MVC, MVP, or MVVM, and map the component relationships.
- Analyze the auth module and explain the design patterns implemented there.
How to install explain-architecture-pattern
Manually: put the files in place
.claude/commands/explain-architecture-pattern.mdCall it with /explain-architecture-pattern. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/explain-architecture-pattern.mdCall it with /prompts:explain-architecture-pattern. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/explain-architecture-pattern.prompt.mdManually: put the files in place
.gemini/commands/explain-architecture-pattern.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about explain-architecture-pattern
How do I install explain-architecture-pattern in Claude Code?
Place the command file at .claude/commands/explain-architecture-pattern.md.
What does explain-architecture-pattern do?
It finds architecture and design patterns in a codebase, explains their purpose, and maps component relationships with prose, diagrams, and code examples.
What does the command need to analyze architecture?
It needs access to the codebase so it can inspect folders, files, and relationships between modules.
Source text
explain-architecture-pattern.md · MIT
# Explain Architecture Pattern Identify and explain architectural patterns, design patterns, and structural decisions found in the codebase. This helps understand the "why" behind code organization and design choices. ## Usage Examples ### Basic Usage "Explain the architecture pattern used in this project" "What design patterns are implemented in the auth module?" "Analyze the folder structure and explain the architecture" ### Specific Pattern Analysis "Is this using MVC, MVP, or MVVM?" "Explain the microservices architecture here" "What's the event-driven pattern in this code?" "How is the repository pattern implemented?" ## Instructions for Claude When explaining architecture patterns: 1. **Analyze Project Structure**: Examine folder organization, file naming, and module relationships 2. **Identify Patterns**: Recognize common architectural and design patterns 3. **Explain Rationale**: Describe why these patterns might have been chosen 4. **Visual Representation**: Use ASCII diagrams or markdown to illustrate relationships 5. **Practical Examples**: Show how the pattern is implemented with code examples ### Common Architecture Patterns #### Application Architecture - **MVC (Model-View-Controller)** - **MVP (Model-View-Presenter)** - **MVVM (Model-View-ViewModel)** - **Clean Architecture** - **Hexagonal Architecture** - **Microservices** - **Monolithic** - **Serverless** - **Event-Driven** - **Domain-Driven Design (DDD)** #### Design Patterns - **Creational**: Factory, Singleton, Builder, Prototype - **Structural**: Adapter, Decorator, Facade, Proxy - **Behavioral**: Observer, Strategy, Command, Iterator - **Concurrency**: Producer-Consumer, Thread Pool - **Architectural**: Repository, Unit of Work, CQRS #### Frontend Patterns - **Component-Based Architecture** - **Flux/Redux Pattern** - **Module Federation** - **Micro-Frontends** - **State Management Patterns** #### Backend Patterns - **RESTful Architecture** - **GraphQL Schema Design** - **Service Layer Pattern** - **Repository Pattern** - **Dependency Injection** ### Analysis Areas #### Code Organization - Project structure rationale - Module boundaries and responsibilities - Separation of concerns - Dependency management - Configuration patterns #### Data Flow - Request/response cycle - State management - Event propagation - Data transformation layers - Caching strategies #### Integration Points - API design patterns - Database access patterns - Third-party integrations - Message queue usage - Service communication ### Output Format Structure the explanation as: ```markdown ## Architecture Pattern Analysis ### Overview Brief description of the overall architecture identified ### 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 pattern ``` **Diagram**: ``` ┌─────────────┐ ┌─────────────┐ │ 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 logic ``` #### Key Relationships - How components interact - Dependency flow - Communication patterns ### Recommendations - Patterns that could enhance current architecture - Potential improvements - Consistency suggestions ``` Remember to: - Use clear, accessible language - Provide context for technical decisions - Show concrete examples from the actual code - Explain benefits and trade-offs objectively
© centminmod · MIT · centminmod/my-claude-code-setup