Architecture Patterns Skill
CRITICAL: The description field above controls when Claude auto-loads this skill.
Overview
Provides comprehensive architecture design capabilities including mermaid diagram generation, architecture documentation templates, diagram validation, and pattern libraries for common architectural styles (microservices, RAG systems, full-stack applications).
Instructions
Create Architecture Documentation
- Use
bash scripts/create-architecture.sh <project-path> <architecture-type> to scaffold project files (README, roadmap/*.json, specs/)
- Architecture types:
nextjs, fastapi, fullstack, microservices, rag, generic
- Generates complete architecture overview with mermaid diagrams
- Creates directory structure:
docs/architecture/ with overview, components, data-flow, deployment
- Includes table of contents and cross-references
Validate Mermaid Diagrams
- Use
bash scripts/validate-mermaid.sh <markdown-file> to check mermaid syntax
- Validates diagram types: graph, flowchart, sequenceDiagram, classDiagram, erDiagram, stateDiagram
- Checks for syntax errors, invalid node definitions, broken connections
- Reports line numbers of errors
- Provides suggestions for common fixes
Generate Diagram Placeholders
- Use
bash scripts/generate-diagrams.sh <output-dir> <diagram-types> to create diagram templates
- Diagram types:
component, data-flow, deployment, api, security, all
- Creates markdown files with properly formatted mermaid code blocks
- Includes comments explaining diagram sections
- Provides example nodes and relationships
Update Existing Architecture
- Use
bash scripts/update-architecture.sh <architecture-file> <section> to add new sections
- Sections:
component, api, security, deployment, data-flow
- Inserts section with proper heading hierarchy
- Adds mermaid diagram placeholder
- Preserves existing content and formatting
Export Diagrams to Files
- Use
bash scripts/export-diagrams.sh <markdown-file> <output-dir> to extract diagrams
- Extracts all mermaid code blocks from documentation
- Creates individual
.mmd files for each diagram
- Names files based on diagram titles or section headings
- Generates index.md listing all exported diagrams
Available Scripts
- create-architecture.sh: Scaffold complete architecture documentation with diagrams
- validate-mermaid.sh: Validate mermaid diagram syntax and structure
- generate-diagrams.sh: Create diagram template placeholders
- update-architecture.sh: Add new sections to existing project files (README, roadmap/*.json, specs/)
- export-diagrams.sh: Extract mermaid diagrams to separate files
Templates
- architecture-overview.md: Master architecture document template with TOC
- component-diagram.md: Component architecture with relationships
- data-flow-diagram.md: Data flow and processing pipelines
- deployment-diagram.md: Infrastructure and deployment architecture
- api-architecture.md: API design, endpoints, and authentication
- security-architecture.md: Security patterns, auth flows, data protection
Examples
See examples/ directory for detailed usage examples:
example-nextjs-architecture.md - Next.js 15 App Router architecture
example-fastapi-architecture.md - FastAPI backend with PostgreSQL
example-fullstack-architecture.md - Full stack Next.js + FastAPI
example-ai-rag-architecture.md - RAG system with vector database
example-microservices-architecture.md - Microservices pattern with API gateway
Architecture Patterns
Component Architecture Pattern
- Define system components and boundaries
- Show component relationships and dependencies
- Identify shared services and libraries
- Document component responsibilities
Data Flow Pattern
- Map data movement through system
- Show transformation and processing stages
- Identify data sources and destinations
- Document data formats and protocols
Deployment Pattern
- Define infrastructure components
- Show service deployment topology
- Identify scaling and redundancy strategies
- Document environment configurations
API Architecture Pattern
- Design API structure and endpoints
- Define authentication and authorization
- Show request/response flows
- Document rate limiting and caching
Security Architecture Pattern
- Define security layers and boundaries
- Show authentication and authorization flows
- Identify threat vectors and mitigations
- Document encryption and data protection
Mermaid Diagram Types
Graph/Flowchart Diagrams
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2]
Sequence Diagrams
sequenceDiagram
Client->>API: Request
API->>Database: Query
Database-->>API: Result
API-->>Client: Response
Class Diagrams
classDiagram
class User {
+String name
+login()
}
Entity Relationship Diagrams
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ ITEM : contains
State Diagrams
stateDiagram-v2
[*] --> Idle
Idle --> Processing
Processing --> Complete
Output Standards
- Use mermaid for all diagrams (ensures renderability)
- Include diagram titles and descriptions
- Add comments explaining key components
- Follow consistent naming conventions
- Use proper markdown heading hierarchy
- Include cross-references between documents
Validation Checks
Scripts perform these validations:
- Mermaid syntax correctness
- Node and edge definitions
- Diagram type compatibility
- Character escaping in labels
- Proper code block formatting
- Complete relationship definitions
Integration
This skill is used by:
planning:architecture command - Generate project files (README, roadmap/*.json, specs/)
architecture-designer agent - Create system designs
- Documentation tools - Include architecture diagrams
- Code generation - Architecture-aware scaffolding
Best Practices
- Start with high-level overview diagram
- Create separate diagrams for each architectural concern
- Use consistent component naming across diagrams
- Include legends for symbols and colors
- Keep diagrams focused and readable (max 15-20 nodes)
- Document assumptions and constraints
- Version architecture documents
- Update diagrams when system changes
Common Diagram Patterns
Layered Architecture
graph TB
UI[Presentation Layer]
BL[Business Logic Layer]
DA[Data Access Layer]
DB[(Database)]
UI --> BL
BL --> DA
DA --> DB
Event-Driven Architecture
graph LR
P[Producer] -->|Event| Q[Event Queue]
Q -->|Event| C1[Consumer 1]
Q -->|Event| C2[Consumer 2]
Microservices Architecture
graph TB
AG[API Gateway]
AG --> MS1[Service 1]
AG --> MS2[Service 2]
AG --> MS3[Service 3]
MS1 --> DB1[(DB 1)]
MS2 --> DB2[(DB 2)]
Purpose: Comprehensive architecture design and documentation
Used by: Architecture designers, system planners, documentation tools
1---2name: architecture-patterns3description: Architecture design templates, mermaid diagrams, documentation patterns, and validation tools. Use when designing system architecture, creating architecture documentation, generating mermaid diagrams, documenting component relationships, designing data flows, planning deployments, creating API architectures, or when user mentions architecture diagrams, system design, mermaid, architecture documentation, or component design.4---56# Architecture Patterns Skill78**CRITICAL: The description field above controls when Claude auto-loads this skill.**910## Overview1112Provides comprehensive architecture design capabilities including mermaid diagram generation, architecture documentation templates, diagram validation, and pattern libraries for common architectural styles (microservices, RAG systems, full-stack applications).1314## Instructions1516### Create Architecture Documentation17181. Use `bash scripts/create-architecture.sh <project-path> <architecture-type>` to scaffold project files (README, roadmap/*.json, specs/)192. Architecture types: `nextjs`, `fastapi`, `fullstack`, `microservices`, `rag`, `generic`203. Generates complete architecture overview with mermaid diagrams214. Creates directory structure: `docs/architecture/` with overview, components, data-flow, deployment225. Includes table of contents and cross-references2324### Validate Mermaid Diagrams25261. Use `bash scripts/validate-mermaid.sh <markdown-file>` to check mermaid syntax272. Validates diagram types: graph, flowchart, sequenceDiagram, classDiagram, erDiagram, stateDiagram283. Checks for syntax errors, invalid node definitions, broken connections294. Reports line numbers of errors305. Provides suggestions for common fixes3132### Generate Diagram Placeholders33341. Use `bash scripts/generate-diagrams.sh <output-dir> <diagram-types>` to create diagram templates352. Diagram types: `component`, `data-flow`, `deployment`, `api`, `security`, `all`363. Creates markdown files with properly formatted mermaid code blocks374. Includes comments explaining diagram sections385. Provides example nodes and relationships3940### Update Existing Architecture41421. Use `bash scripts/update-architecture.sh <architecture-file> <section>` to add new sections432. Sections: `component`, `api`, `security`, `deployment`, `data-flow`443. Inserts section with proper heading hierarchy454. Adds mermaid diagram placeholder465. Preserves existing content and formatting4748### Export Diagrams to Files49501. Use `bash scripts/export-diagrams.sh <markdown-file> <output-dir>` to extract diagrams512. Extracts all mermaid code blocks from documentation523. Creates individual `.mmd` files for each diagram534. Names files based on diagram titles or section headings545. Generates index.md listing all exported diagrams5556## Available Scripts5758- **create-architecture.sh**: Scaffold complete architecture documentation with diagrams59- **validate-mermaid.sh**: Validate mermaid diagram syntax and structure60- **generate-diagrams.sh**: Create diagram template placeholders61- **update-architecture.sh**: Add new sections to existing project files (README, roadmap/*.json, specs/)62- **export-diagrams.sh**: Extract mermaid diagrams to separate files6364## Templates6566- **architecture-overview.md**: Master architecture document template with TOC67- **component-diagram.md**: Component architecture with relationships68- **data-flow-diagram.md**: Data flow and processing pipelines69- **deployment-diagram.md**: Infrastructure and deployment architecture70- **api-architecture.md**: API design, endpoints, and authentication71- **security-architecture.md**: Security patterns, auth flows, data protection7273## Examples7475See `examples/` directory for detailed usage examples:76- `example-nextjs-architecture.md` - Next.js 15 App Router architecture77- `example-fastapi-architecture.md` - FastAPI backend with PostgreSQL78- `example-fullstack-architecture.md` - Full stack Next.js + FastAPI79- `example-ai-rag-architecture.md` - RAG system with vector database80- `example-microservices-architecture.md` - Microservices pattern with API gateway8182## Architecture Patterns8384### Component Architecture Pattern85- Define system components and boundaries86- Show component relationships and dependencies87- Identify shared services and libraries88- Document component responsibilities8990### Data Flow Pattern91- Map data movement through system92- Show transformation and processing stages93- Identify data sources and destinations94- Document data formats and protocols9596### Deployment Pattern97- Define infrastructure components98- Show service deployment topology99- Identify scaling and redundancy strategies100- Document environment configurations101102### API Architecture Pattern103- Design API structure and endpoints104- Define authentication and authorization105- Show request/response flows106- Document rate limiting and caching107108### Security Architecture Pattern109- Define security layers and boundaries110- Show authentication and authorization flows111- Identify threat vectors and mitigations112- Document encryption and data protection113114## Mermaid Diagram Types115116### Graph/Flowchart Diagrams117```mermaid118graph TD119 A[Start] --> B{Decision}120 B -->|Yes| C[Action 1]121 B -->|No| D[Action 2]122```123124### Sequence Diagrams125```mermaid126sequenceDiagram127 Client->>API: Request128 API->>Database: Query129 Database-->>API: Result130 API-->>Client: Response131```132133### Class Diagrams134```mermaid135classDiagram136 class User {137 +String name138 +login()139 }140```141142### Entity Relationship Diagrams143```mermaid144erDiagram145 USER ||--o{ ORDER : places146 ORDER ||--|{ ITEM : contains147```148149### State Diagrams150```mermaid151stateDiagram-v2152 [*] --> Idle153 Idle --> Processing154 Processing --> Complete155```156157## Output Standards158159- Use mermaid for all diagrams (ensures renderability)160- Include diagram titles and descriptions161- Add comments explaining key components162- Follow consistent naming conventions163- Use proper markdown heading hierarchy164- Include cross-references between documents165166## Validation Checks167168Scripts perform these validations:169- Mermaid syntax correctness170- Node and edge definitions171- Diagram type compatibility172- Character escaping in labels173- Proper code block formatting174- Complete relationship definitions175176## Integration177178This skill is used by:179- `planning:architecture` command - Generate project files (README, roadmap/*.json, specs/)180- `architecture-designer` agent - Create system designs181- Documentation tools - Include architecture diagrams182- Code generation - Architecture-aware scaffolding183184## Best Practices1851861. Start with high-level overview diagram1872. Create separate diagrams for each architectural concern1883. Use consistent component naming across diagrams1894. Include legends for symbols and colors1905. Keep diagrams focused and readable (max 15-20 nodes)1916. Document assumptions and constraints1927. Version architecture documents1938. Update diagrams when system changes194195## Common Diagram Patterns196197### Layered Architecture198```mermaid199graph TB200 UI[Presentation Layer]201 BL[Business Logic Layer]202 DA[Data Access Layer]203 DB[(Database)]204 UI --> BL205 BL --> DA206 DA --> DB207```208209### Event-Driven Architecture210```mermaid211graph LR212 P[Producer] -->|Event| Q[Event Queue]213 Q -->|Event| C1[Consumer 1]214 Q -->|Event| C2[Consumer 2]215```216217### Microservices Architecture218```mermaid219graph TB220 AG[API Gateway]221 AG --> MS1[Service 1]222 AG --> MS2[Service 2]223 AG --> MS3[Service 3]224 MS1 --> DB1[(DB 1)]225 MS2 --> DB2[(DB 2)]226```227228---229230**Purpose**: Comprehensive architecture design and documentation231**Used by**: Architecture designers, system planners, documentation tools