Software Patterns - Unified Knowledge Router
A comprehensive software engineering knowledge base spanning 147 documentation files across 7 focused skills. This router intelligently directs queries to the appropriate underlying skill(s) and orchestrates cross-skill solutions when needed.
When This Skill Activates
This skill automatically activates when you:
- Need to choose between design patterns or algorithms
- Design system architecture or data models
- Discuss code quality, refactoring, or best practices
- Select data structures for specific requirements
- Design distributed systems or databases
- Model complex business domains
- Apply fundamental programming concepts
Quick Reference: What Each Skill Covers
| Skill |
Files |
Coverage |
Use For |
| gof-patterns |
25 |
23 GoF design patterns + selection guides |
Object creation, composition, behavior |
| clrs-algorithms |
40 |
Data structures & algorithms |
Performance optimization, algorithm selection |
| clean-code |
14 |
SOLID principles + 8 practices |
Code quality, refactoring, maintainability |
| ddia |
21 |
Distributed systems concepts |
Scalability, consistency, availability |
| pragmatic-programmer |
19 |
7 principles + 11 practices |
Software craftsmanship, debugging, tooling |
| ddd |
15 |
4 strategic + 5 tactical patterns |
Domain modeling, bounded contexts |
| sicp |
13 |
12 fundamental CS concepts |
Abstraction, recursion, interpreters |
Total: 147 documentation files
Query Commands
Pattern Queries
/pattern <problem>
Find design patterns for a specific problem.
Examples:
/pattern create objects without knowing exact type → Factory Method
/pattern add behavior dynamically → Decorator
/pattern notify multiple objects of changes → Observer
/pattern simplify complex subsystem → Facade
Routes to: gof-patterns skill with pattern-selection.md
Data Structure Queries
/ds <requirement>
Find data structures for specific requirements.
Examples:
/ds fast lookup by key → Hash Table
/ds maintain sorted order → Tree Set or Heap
/ds fast insert/delete at ends → Deque
/ds priority queue → Binary Heap
Routes to: clrs-algorithms skill with data-structure-selection.md
Architecture Queries
/architecture <scenario>
Get multi-skill solution stacks combining patterns, data structures, and distributed systems concepts.
Examples:
/architecture e-commerce checkout → State pattern + Command + Observer + distributed transactions
/architecture real-time leaderboard → Sorted Set + Redis + Pub/Sub
/architecture multi-tenant SaaS → Abstract Factory + Bounded Contexts + Partitioning
Routes to: Orchestrates across gof-patterns, clrs-algorithms, ddia, and ddd
Implementation Queries
/implement <pattern> [language]
Generate implementation code for a pattern in a specific language.
Examples:
/implement factory method typescript
/implement observer python
/implement heap java
Routes to: Appropriate skill with language-specific translation
Comparison Queries
/compare <a> vs <b>
Trade-off analysis between two approaches.
Examples:
/compare factory method vs abstract factory
/compare array vs linked list
/compare postgres vs mongodb
/compare event sourcing vs crud
Routes to: Relevant skill(s) with comparison tables
How the Router Works
1. Query Parsing
The router analyzes queries for problem indicators:
patterns:
- "create", "instantiate", "build" → Creational patterns
- "structure", "compose", "organize" → Structural patterns
- "behavior", "algorithm", "interact" → Behavioral patterns
data_structures:
- "fast lookup", "search", "find" → Hash or Tree
- "sorted", "ordered" → Tree or Heap
- "insert", "delete", "add", "remove" → List or Tree
- "queue", "stack", "priority" → Specialized structures
distributed_systems:
- "scale", "partition", "shard" → ddia/partitioning
- "replicate", "consistency" → ddia/replication
- "distributed", "consensus" → ddia/consensus
domain_modeling:
- "entity", "value object", "aggregate" → ddd/tactical
- "bounded context", "ubiquitous language" → ddd/strategic
2. Skill Routing
Based on query type, routes to one or more skills:
| Query Type |
Primary Skill |
Supporting Skills |
| Design pattern |
gof-patterns |
clean-code (SOLID), ddd (patterns) |
| Data structure |
clrs-algorithms |
ddia (storage engines) |
| Code quality |
clean-code |
pragmatic-programmer |
| Distributed systems |
ddia |
clrs-algorithms (graphs), ddd (contexts) |
| Domain modeling |
ddd |
gof-patterns (tactical patterns) |
| Fundamentals |
sicp |
pragmatic-programmer |
| Architecture |
ALL |
Orchestrated solution |
3. Cross-Skill Orchestration
For complex problems, the router orchestrates multiple skills:
Example: "Design a caching layer for a distributed system"
1. clrs-algorithms → LRU cache data structure (Hash Table + Doubly Linked List)
2. gof-patterns → Proxy pattern (control access), Flyweight (share state)
3. ddia → Replication strategies, consistency models
4. clean-code → Interface design, SOLID principles
Example: "Build an e-commerce order processing system"
1. ddd → Order aggregate, bounded contexts (order, payment, shipping)
2. gof-patterns → State (order states), Command (payment actions), Observer (notifications)
3. clrs-algorithms → Priority Queue (order processing), Hash Table (inventory lookup)
4. ddia → Event sourcing, CQRS, distributed transactions
5. clean-code → SRP (one class per concern), DIP (depend on abstractions)
Auto-Trigger Rules
This skill activates automatically when queries contain these indicators:
Pattern/Design Indicators
- "which pattern", "design pattern", "should I use"
- "factory", "singleton", "observer", "decorator", "adapter"
- "create objects", "add behavior", "simplify interface"
Data Structure Indicators
- "which data structure", "fast lookup", "sorted order"
- "array", "list", "tree", "hash", "graph", "heap"
- "O(1)", "O(log n)", "complexity", "time/space"
Architecture Indicators
- "design", "architecture", "how should I structure"
- "scalable", "distributed", "high availability"
- "microservices", "event-driven", "domain model"
Code Quality Indicators
- "refactor", "code smell", "clean up", "improve"
- "SOLID", "DRY", "naming", "function size"
- "test", "maintainable", "readable"
Skill Coverage Details
GoF Patterns (gof-patterns)
Creational (5 patterns):
- Abstract Factory, Builder, Factory Method, Prototype, Singleton
Structural (7 patterns):
- Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
Behavioral (11 patterns):
- Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor
Decision Guides:
- pattern-selection.md - Comprehensive selection guide
- Problem → Pattern mapping
- Common combinations
- Anti-patterns to avoid
CLRS Algorithms (clrs-algorithms)
Linear Structures (6):
- Array, Dynamic Array, Linked List, Stack, Queue, Deque
Trees (12):
- Binary Tree, BST, AVL, Red-Black, B-Tree, Trie, Heap, Splay Tree, Treap, Interval Tree, Order-Statistic Tree, K-D Tree
Hash-Based (3):
- Hash Table, Hash Set, Bloom Filter
Graphs (5):
- Adjacency List/Matrix, Network Flow, Strongly Connected Components, plus algorithms (BFS, DFS, Dijkstra, etc.)
Advanced (7):
- Skip List, Disjoint Set, Segment Tree, Fenwick Tree, Fibonacci Heap, Binomial Heap, van Emde Boas Tree
Strings (3):
- String Algorithms (KMP, Rabin-Karp), Suffix Array, Suffix Tree
Algorithms:
- Sorting (QuickSort, MergeSort, HeapSort, RadixSort)
Decision Guides:
Clean Code (clean-code)
SOLID Principles (5):
- Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
Practices (8):
- Meaningful Names, Functions, Comments, Formatting, Error Handling, Unit Testing, Code Smells, Boy Scout Rule
DDIA (ddia)
Data Models (3):
- Relational, Document, Graph
Storage (3):
- B-Trees, LSM-Trees, Column Storage
Replication (3):
- Leader-Follower, Multi-Leader, Leaderless
Partitioning (2):
Transactions (3):
- ACID, Isolation Levels, Distributed Transactions
Consistency (2):
Consensus (1):
Processing (3):
- Batch, Stream, Event Sourcing/CQRS
Pragmatic Programmer (pragmatic-programmer)
Principles (7):
- DRY, Orthogonality, Reversibility, Tracer Bullets, Prototypes, Domain Languages, Estimating
Practices (11):
- Plain Text, Shell Games, Debugging, Text Manipulation, Code Generators, Design by Contract, Assertive Programming, Decoupling, Refactoring, Testing, Automation
Domain-Driven Design (ddd)
Strategic Patterns (4):
- Ubiquitous Language, Bounded Contexts, Context Mapping, Anti-Corruption Layer
Tactical Patterns (5):
- Entities, Value Objects, Aggregates, Domain Services, Domain Events
Supporting Patterns (3):
- Repositories, Factories, Specifications
Practices (2):
- Event Storming, Model Exploration
SICP (sicp)
Procedures (3):
- Abstraction, Higher-Order Functions, Recursion Patterns (linear, tail, tree, mutual)
Data (3):
- Data Abstraction, Hierarchical Data, Symbolic Data
Modularity (3):
- Assignment and State, Environment Model, Streams
Metalinguistic (3):
- Interpreters, Lazy Evaluation, Register Machines
Cross-Skill Solution Stacks
Common Architecture Patterns
1. The Cache Stack
Pattern: Caching layer with eviction policy
Skills Used:
- clrs-algorithms: Hash Table + Doubly Linked List (LRU)
- gof-patterns: Proxy (control access), Flyweight (share state)
- ddia: Replication (distributed cache), Consistency (cache coherence)
- clean-code: SRP (separate concerns), DIP (interface-based)
Implementation Guide:
1. Use Hash Table for O(1) key lookup
2. Use Doubly Linked List for O(1) LRU eviction
3. Apply Proxy pattern to control access and logging
4. Apply Flyweight to share immutable state
5. Consider replication strategy for distributed scenarios
2. The Event Pipeline
Pattern: Event-driven system with processing pipeline
Skills Used:
- gof-patterns: Observer (event notification), Command (encapsulate actions)
- clrs-algorithms: Queue (FIFO processing), Priority Queue (prioritized events)
- ddia: Stream Processing (Kafka/Flink), Event Sourcing
- ddd: Domain Events, Aggregates (event producers)
- clean-code: SRP (one handler per event type)
Implementation Guide:
1. Use Observer for event subscription
2. Use Queue or Priority Queue for event buffer
3. Use Command pattern for event handlers
4. Apply Event Sourcing for audit trail
5. Define Domain Events in Ubiquitous Language
3. The Multi-Tenant SaaS
Pattern: Isolated tenants with shared infrastructure
Skills Used:
- ddd: Bounded Contexts (per tenant or shared), Context Mapping
- gof-patterns: Abstract Factory (tenant-specific objects), Strategy (tenant policies)
- clrs-algorithms: Hash Table (tenant lookup), B-Tree (tenant data indexing)
- ddia: Partitioning (tenant sharding), Isolation Levels
- clean-code: OCP (extend without modifying), ISP (tenant-specific interfaces)
Implementation Guide:
1. Define Bounded Context boundaries (shared kernel vs separate)
2. Use Abstract Factory for tenant-specific object creation
3. Use Strategy for tenant-specific policies (pricing, limits)
4. Partition data by tenant ID for isolation
5. Choose appropriate isolation level (row-level, schema-level, database-level)
4. The E-Commerce Order System
Pattern: Order processing with inventory, payment, shipping
Skills Used:
- ddd: Aggregates (Order, Inventory, Payment), Bounded Contexts
- gof-patterns: State (order lifecycle), Command (payment operations), Observer (notifications)
- clrs-algorithms: Priority Queue (order processing), Hash Table (inventory lookup)
- ddia: Distributed Transactions (Saga pattern), Event Sourcing
- clean-code: SRP (separate concerns), DIP (depend on repositories)
Implementation Guide:
1. Define Order Aggregate with invariants
2. Use State pattern for order states (cart → payment → processing → shipped)
3. Use Command for payment operations (process, refund, cancel)
4. Use Observer for notifications (customer, warehouse, shipping)
5. Apply Saga pattern for distributed transaction coordination
6. Use Event Sourcing for order history and replay
5. The Real-Time Leaderboard
Pattern: Sorted rankings with fast updates
Skills Used:
- clrs-algorithms: Red-Black Tree or Skip List (sorted rankings), Hash Table (user lookup)
- gof-patterns: Observer (rank change notifications), Memento (snapshot rankings)
- ddia: Replication (read scaling), Partitioning (range-based)
- clean-code: Functions (small, focused), DRY (ranking logic)
Implementation Guide:
1. Use Sorted Set (Red-Black Tree) for O(log n) insert/delete/rank
2. Use Hash Table for O(1) user score lookup
3. Apply Observer for real-time rank change notifications
4. Use Read Replicas for scaling leaderboard queries
5. Partition by rank ranges for very large leaderboards
Usage Examples
Example 1: Pattern Selection
Query: "I need to create objects without specifying their concrete classes"
Router Response:
Primary Match: Creational Patterns (gof-patterns)
Recommendation: Factory Method Pattern
Routing to: gof-patterns/gof-creational/factory-method.md
Additional Considerations:
- If creating families of related objects → Abstract Factory
- If construction is complex → Builder
- See: gof-patterns/pattern-selection.md for decision tree
Example 2: Data Structure Selection
Query: "What's the best data structure for fast lookup and maintaining sorted order?"
Router Response:
Primary Match: Data Structure Selection (clrs-algorithms)
Recommendation: Tree Map (Red-Black Tree or AVL Tree)
Comparison:
- Hash Table: O(1) lookup, NO sorted order
- Tree Map: O(log n) lookup, YES sorted order ✓
- Sorted Array: O(log n) search, O(n) insert ✗
Routing to: clrs-algorithms/data-structures/trees/red-black-tree.md
See also: clrs-algorithms/data-structure-selection.md
Example 3: Architecture Design
Query: "Design a notification system that supports email, SMS, and push notifications"
Router Response:
Multi-Skill Solution:
1. Pattern Selection (gof-patterns):
- Observer Pattern: Subscribe to events
- Strategy Pattern: Switch between notification methods
- Command Pattern: Queue notification actions
2. Data Structures (clrs-algorithms):
- Priority Queue: Prioritize urgent notifications
- Hash Table: User preference lookup
3. Distributed Systems (ddia):
- Queue (Kafka/RabbitMQ): Async processing
- Retry mechanisms: Handle failures
4. Code Quality (clean-code):
- SRP: One class per notification channel
- OCP: Add new channels without modifying existing
Implementation Stack:
Observer → Command → Priority Queue → Strategy → DIP
Example 4: Code Quality Review
Query: "This function is 200 lines long and does too many things. How do I improve it?"
Router Response:
Primary Match: Code Quality (clean-code)
Violations Detected:
1. Single Responsibility Principle (SRP) - function does too many things
2. Function size - should be 5-20 lines
Refactoring Steps:
1. Extract methods for each responsibility (clean-code/practices/functions.md)
2. Apply SRP (clean-code/solid/single-responsibility.md)
3. Use meaningful names (clean-code/practices/meaningful-names.md)
Supporting Guidance:
- pragmatic-programmer/practices/refactoring.md: When and how to refactor
- gof-patterns: Consider Template Method or Strategy if algorithm varies
Tools:
- Extract Method refactoring
- Compose Method pattern
- Replace Temp with Query
Language Translation Notes
All examples use language-agnostic pseudocode with these conventions:
class for type definitions
function for methods/functions
-> for method calls on objects
// for comments
- Type hints shown as
name: Type
Translation Guide
| Language |
Class |
Method |
Call |
Comment |
Types |
| PHP |
class |
function |
-> |
// |
Docblocks or PHP 8+ |
| JavaScript |
class |
function / arrow |
. |
// |
JSDoc or TypeScript |
| TypeScript |
class |
method / arrow |
. |
// |
Native types |
| Python |
class |
def |
. |
# |
Type hints |
| Java |
class |
method |
. |
// |
Native types |
| C# |
class |
method |
. |
// |
Native types |
| Go |
type / struct |
func |
. |
// |
Native types |
| Rust |
struct / trait |
fn |
. |
// |
Native types |
Advanced Usage
Combining Multiple Skills
For complex problems, explicitly request multi-skill analysis:
"I need a comprehensive solution for [problem] covering patterns, data structures, and distributed systems"
The router will orchestrate across all relevant skills and provide:
- Pattern recommendations (gof-patterns)
- Data structure choices (clrs-algorithms)
- Scalability considerations (ddia)
- Domain modeling (ddd if applicable)
- Code quality guidelines (clean-code)
- Implementation best practices (pragmatic-programmer)
Deep Dives
Request detailed documentation from specific skills:
"Show me the full Observer pattern documentation"
→ Routes to: gof-patterns/gof-behavioral/observer.md
"Explain Red-Black Tree implementation with examples"
→ Routes to: clrs-algorithms/data-structures/trees/red-black-tree.md
"What are all SOLID principles?"
→ Routes to: clean-code/solid/ (all 5 principles)
Comparison Queries
Request trade-off analysis:
"/compare singleton vs dependency injection"
→ Multi-skill analysis from gof-patterns + clean-code
"/compare b-tree vs lsm-tree"
→ Multi-skill analysis from clrs-algorithms + ddia
"/compare entity vs value object"
→ Analysis from ddd/tactical/
Tips for Effective Use
1. Start with Problem, Not Solution
❌ "Show me the Singleton pattern"
✅ "I need exactly one instance of a configuration manager"
The router will recommend the right pattern and warn about potential issues.
2. Provide Context
❌ "Which data structure should I use?"
✅ "I need fast lookup by key and sorted iteration over 10,000 items"
Context enables better routing and recommendations.
3. Ask About Trade-offs
✅ "What are the trade-offs between Factory Method and Abstract Factory?"
✅ "When should I use Array vs Linked List?"
✅ "Compare event sourcing vs traditional CRUD"
Trade-off queries trigger comparison mode with tables and decision guides.
4. Request Implementation Guidance
✅ "How do I implement LRU cache in TypeScript?"
✅ "Show me Observer pattern in Python"
✅ "Implement Repository pattern in PHP"
Includes language-specific code generation with best practices.
5. Explore Related Concepts
After getting a recommendation, ask:
- "What patterns work well with [pattern]?"
- "What are common combinations with [data structure]?"
- "How does [concept] relate to [other concept]?"
Contributing
To add new patterns, algorithms, or concepts to any skill:
- Follow the established format in existing documentation
- Include definition, when to use, implementation, examples, trade-offs
- Update the relevant SKILL.md quick reference tables
- Add decision guide entries if applicable
Acknowledgments
This unified knowledge base is built on the shoulders of giants:
- Gang of Four (Gamma, Helm, Johnson, Vlissides): Design Patterns
- CLRS (Cormen, Leiserson, Rivest, Stein): Introduction to Algorithms
- Robert C. Martin (Uncle Bob): Clean Code
- Martin Kleppmann: Designing Data-Intensive Applications
- Eric Evans: Domain-Driven Design
- Andrew Hunt & David Thomas: The Pragmatic Programmer
- Harold Abelson & Gerald Jay Sussman: Structure and Interpretation of Computer Programs
Made with Claude Code
Total: 147 documentation files across 7 focused skills
1---2name: software-patterns3description: Unified router for 7 canonical software engineering knowledge bases. Routes queries to appropriate underlying skills: gof-patterns (23 design patterns), clrs-algorithms (40 data structures), clean-code (SOLID + practices), ddia (distributed systems), pragmatic-programmer (craftsmanship), ddd (domain modeling), sicp (CS fundamentals). Auto-activates for architecture decisions, pattern selection, algorithm choice, and system design.4---5
6# Software Patterns - Unified Knowledge Router
7
8A comprehensive software engineering knowledge base spanning 147 documentation files across 7 focused skills. This router intelligently directs queries to the appropriate underlying skill(s) and orchestrates cross-skill solutions when needed.
9
10## When This Skill Activates
11
12This skill automatically activates when you:
13- Need to choose between design patterns or algorithms
14- Design system architecture or data models
15- Discuss code quality, refactoring, or best practices
16- Select data structures for specific requirements
17- Design distributed systems or databases
18- Model complex business domains
19- Apply fundamental programming concepts
20
21## Quick Reference: What Each Skill Covers
22
23| Skill | Files | Coverage | Use For |
24|-------|-------|----------|---------|
25| **gof-patterns** | 25 | 23 GoF design patterns + selection guides | Object creation, composition, behavior |
26| **clrs-algorithms** | 40 | Data structures & algorithms | Performance optimization, algorithm selection |
27| **clean-code** | 14 | SOLID principles + 8 practices | Code quality, refactoring, maintainability |
28| **ddia** | 21 | Distributed systems concepts | Scalability, consistency, availability |
29| **pragmatic-programmer** | 19 | 7 principles + 11 practices | Software craftsmanship, debugging, tooling |
30| **ddd** | 15 | 4 strategic + 5 tactical patterns | Domain modeling, bounded contexts |
31| **sicp** | 13 | 12 fundamental CS concepts | Abstraction, recursion, interpreters |
32
33**Total: 147 documentation files**
34
35## Query Commands
36
37### Pattern Queries
38
39```
40/pattern <problem>
41```
42
43Find design patterns for a specific problem.
44
45**Examples:**
46- `/pattern create objects without knowing exact type` → Factory Method
47- `/pattern add behavior dynamically` → Decorator
48- `/pattern notify multiple objects of changes` → Observer
49- `/pattern simplify complex subsystem` → Facade
50
51**Routes to:** `gof-patterns` skill with pattern-selection.md
52
53### Data Structure Queries
54
55```
56/ds <requirement>
57```
58
59Find data structures for specific requirements.
60
61**Examples:**
62- `/ds fast lookup by key` → Hash Table
63- `/ds maintain sorted order` → Tree Set or Heap
64- `/ds fast insert/delete at ends` → Deque
65- `/ds priority queue` → Binary Heap
66
67**Routes to:** `clrs-algorithms` skill with data-structure-selection.md
68
69### Architecture Queries
70
71```
72/architecture <scenario>
73```
74
75Get multi-skill solution stacks combining patterns, data structures, and distributed systems concepts.
76
77**Examples:**
78- `/architecture e-commerce checkout` → State pattern + Command + Observer + distributed transactions
79- `/architecture real-time leaderboard` → Sorted Set + Redis + Pub/Sub
80- `/architecture multi-tenant SaaS` → Abstract Factory + Bounded Contexts + Partitioning
81
82**Routes to:** Orchestrates across `gof-patterns`, `clrs-algorithms`, `ddia`, and `ddd`
83
84### Implementation Queries
85
86```
87/implement <pattern> [language]
88```
89
90Generate implementation code for a pattern in a specific language.
91
92**Examples:**
93- `/implement factory method typescript`
94- `/implement observer python`
95- `/implement heap java`
96
97**Routes to:** Appropriate skill with language-specific translation
98
99### Comparison Queries
100
101```
102/compare <a> vs <b>
103```
104
105Trade-off analysis between two approaches.
106
107**Examples:**
108- `/compare factory method vs abstract factory`
109- `/compare array vs linked list`
110- `/compare postgres vs mongodb`
111- `/compare event sourcing vs crud`
112
113**Routes to:** Relevant skill(s) with comparison tables
114
115## How the Router Works
116
117### 1. Query Parsing
118
119The router analyzes queries for problem indicators:
120
121```yaml
122patterns:
123 - "create", "instantiate", "build" → Creational patterns
124 - "structure", "compose", "organize" → Structural patterns
125 - "behavior", "algorithm", "interact" → Behavioral patterns
126
127data_structures:
128 - "fast lookup", "search", "find" → Hash or Tree
129 - "sorted", "ordered" → Tree or Heap
130 - "insert", "delete", "add", "remove" → List or Tree
131 - "queue", "stack", "priority" → Specialized structures
132
133distributed_systems:
134 - "scale", "partition", "shard" → ddia/partitioning
135 - "replicate", "consistency" → ddia/replication
136 - "distributed", "consensus" → ddia/consensus
137
138domain_modeling:
139 - "entity", "value object", "aggregate" → ddd/tactical
140 - "bounded context", "ubiquitous language" → ddd/strategic
141```
142
143### 2. Skill Routing
144
145Based on query type, routes to one or more skills:
146
147| Query Type | Primary Skill | Supporting Skills |
148|------------|--------------|-------------------|
149| Design pattern | `gof-patterns` | `clean-code` (SOLID), `ddd` (patterns) |
150| Data structure | `clrs-algorithms` | `ddia` (storage engines) |
151| Code quality | `clean-code` | `pragmatic-programmer` |
152| Distributed systems | `ddia` | `clrs-algorithms` (graphs), `ddd` (contexts) |
153| Domain modeling | `ddd` | `gof-patterns` (tactical patterns) |
154| Fundamentals | `sicp` | `pragmatic-programmer` |
155| Architecture | ALL | Orchestrated solution |
156
157### 3. Cross-Skill Orchestration
158
159For complex problems, the router orchestrates multiple skills:
160
161**Example: "Design a caching layer for a distributed system"**
162
163```
1641. clrs-algorithms → LRU cache data structure (Hash Table + Doubly Linked List)
1652. gof-patterns → Proxy pattern (control access), Flyweight (share state)
1663. ddia → Replication strategies, consistency models
1674. clean-code → Interface design, SOLID principles
168```
169
170**Example: "Build an e-commerce order processing system"**
171
172```
1731. ddd → Order aggregate, bounded contexts (order, payment, shipping)
1742. gof-patterns → State (order states), Command (payment actions), Observer (notifications)
1753. clrs-algorithms → Priority Queue (order processing), Hash Table (inventory lookup)
1764. ddia → Event sourcing, CQRS, distributed transactions
1775. clean-code → SRP (one class per concern), DIP (depend on abstractions)
178```
179
180## Auto-Trigger Rules
181
182This skill activates automatically when queries contain these indicators:
183
184### Pattern/Design Indicators
185- "which pattern", "design pattern", "should I use"
186- "factory", "singleton", "observer", "decorator", "adapter"
187- "create objects", "add behavior", "simplify interface"
188
189### Data Structure Indicators
190- "which data structure", "fast lookup", "sorted order"
191- "array", "list", "tree", "hash", "graph", "heap"
192- "O(1)", "O(log n)", "complexity", "time/space"
193
194### Architecture Indicators
195- "design", "architecture", "how should I structure"
196- "scalable", "distributed", "high availability"
197- "microservices", "event-driven", "domain model"
198
199### Code Quality Indicators
200- "refactor", "code smell", "clean up", "improve"
201- "SOLID", "DRY", "naming", "function size"
202- "test", "maintainable", "readable"
203
204## Skill Coverage Details
205
206### GoF Patterns (gof-patterns)
207
208**Creational (5 patterns):**
209- Abstract Factory, Builder, Factory Method, Prototype, Singleton
210
211**Structural (7 patterns):**
212- Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
213
214**Behavioral (11 patterns):**
215- Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor
216
217**Decision Guides:**
218- [pattern-selection.md](../gof-patterns/pattern-selection.md) - Comprehensive selection guide
219- Problem → Pattern mapping
220- Common combinations
221- Anti-patterns to avoid
222
223### CLRS Algorithms (clrs-algorithms)
224
225**Linear Structures (6):**
226- Array, Dynamic Array, Linked List, Stack, Queue, Deque
227
228**Trees (12):**
229- Binary Tree, BST, AVL, Red-Black, B-Tree, Trie, Heap, Splay Tree, Treap, Interval Tree, Order-Statistic Tree, K-D Tree
230
231**Hash-Based (3):**
232- Hash Table, Hash Set, Bloom Filter
233
234**Graphs (5):**
235- Adjacency List/Matrix, Network Flow, Strongly Connected Components, plus algorithms (BFS, DFS, Dijkstra, etc.)
236
237**Advanced (7):**
238- Skip List, Disjoint Set, Segment Tree, Fenwick Tree, Fibonacci Heap, Binomial Heap, van Emde Boas Tree
239
240**Strings (3):**
241- String Algorithms (KMP, Rabin-Karp), Suffix Array, Suffix Tree
242
243**Algorithms:**
244- Sorting (QuickSort, MergeSort, HeapSort, RadixSort)
245
246**Decision Guides:**
247- [data-structure-selection.md](../clrs-algorithms/data-structure-selection.md) - "I need fast..." scenarios
248- [complexity-cheat-sheet.md](../clrs-algorithms/complexity-cheat-sheet.md) - Big-O reference
249
250### Clean Code (clean-code)
251
252**SOLID Principles (5):**
253- Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
254
255**Practices (8):**
256- Meaningful Names, Functions, Comments, Formatting, Error Handling, Unit Testing, Code Smells, Boy Scout Rule
257
258### DDIA (ddia)
259
260**Data Models (3):**
261- Relational, Document, Graph
262
263**Storage (3):**
264- B-Trees, LSM-Trees, Column Storage
265
266**Replication (3):**
267- Leader-Follower, Multi-Leader, Leaderless
268
269**Partitioning (2):**
270- Strategies, Rebalancing
271
272**Transactions (3):**
273- ACID, Isolation Levels, Distributed Transactions
274
275**Consistency (2):**
276- Models, Linearizability
277
278**Consensus (1):**
279- Algorithms (Paxos, Raft)
280
281**Processing (3):**
282- Batch, Stream, Event Sourcing/CQRS
283
284### Pragmatic Programmer (pragmatic-programmer)
285
286**Principles (7):**
287- DRY, Orthogonality, Reversibility, Tracer Bullets, Prototypes, Domain Languages, Estimating
288
289**Practices (11):**
290- Plain Text, Shell Games, Debugging, Text Manipulation, Code Generators, Design by Contract, Assertive Programming, Decoupling, Refactoring, Testing, Automation
291
292### Domain-Driven Design (ddd)
293
294**Strategic Patterns (4):**
295- Ubiquitous Language, Bounded Contexts, Context Mapping, Anti-Corruption Layer
296
297**Tactical Patterns (5):**
298- Entities, Value Objects, Aggregates, Domain Services, Domain Events
299
300**Supporting Patterns (3):**
301- Repositories, Factories, Specifications
302
303**Practices (2):**
304- Event Storming, Model Exploration
305
306### SICP (sicp)
307
308**Procedures (3):**
309- Abstraction, Higher-Order Functions, Recursion Patterns (linear, tail, tree, mutual)
310
311**Data (3):**
312- Data Abstraction, Hierarchical Data, Symbolic Data
313
314**Modularity (3):**
315- Assignment and State, Environment Model, Streams
316
317**Metalinguistic (3):**
318- Interpreters, Lazy Evaluation, Register Machines
319
320## Cross-Skill Solution Stacks
321
322### Common Architecture Patterns
323
324#### 1. The Cache Stack
325```
326Pattern: Caching layer with eviction policy
327
328Skills Used:
329- clrs-algorithms: Hash Table + Doubly Linked List (LRU)
330- gof-patterns: Proxy (control access), Flyweight (share state)
331- ddia: Replication (distributed cache), Consistency (cache coherence)
332- clean-code: SRP (separate concerns), DIP (interface-based)
333
334Implementation Guide:
3351. Use Hash Table for O(1) key lookup
3362. Use Doubly Linked List for O(1) LRU eviction
3373. Apply Proxy pattern to control access and logging
3384. Apply Flyweight to share immutable state
3395. Consider replication strategy for distributed scenarios
340```
341
342#### 2. The Event Pipeline
343```
344Pattern: Event-driven system with processing pipeline
345
346Skills Used:
347- gof-patterns: Observer (event notification), Command (encapsulate actions)
348- clrs-algorithms: Queue (FIFO processing), Priority Queue (prioritized events)
349- ddia: Stream Processing (Kafka/Flink), Event Sourcing
350- ddd: Domain Events, Aggregates (event producers)
351- clean-code: SRP (one handler per event type)
352
353Implementation Guide:
3541. Use Observer for event subscription
3552. Use Queue or Priority Queue for event buffer
3563. Use Command pattern for event handlers
3574. Apply Event Sourcing for audit trail
3585. Define Domain Events in Ubiquitous Language
359```
360
361#### 3. The Multi-Tenant SaaS
362```
363Pattern: Isolated tenants with shared infrastructure
364
365Skills Used:
366- ddd: Bounded Contexts (per tenant or shared), Context Mapping
367- gof-patterns: Abstract Factory (tenant-specific objects), Strategy (tenant policies)
368- clrs-algorithms: Hash Table (tenant lookup), B-Tree (tenant data indexing)
369- ddia: Partitioning (tenant sharding), Isolation Levels
370- clean-code: OCP (extend without modifying), ISP (tenant-specific interfaces)
371
372Implementation Guide:
3731. Define Bounded Context boundaries (shared kernel vs separate)
3742. Use Abstract Factory for tenant-specific object creation
3753. Use Strategy for tenant-specific policies (pricing, limits)
3764. Partition data by tenant ID for isolation
3775. Choose appropriate isolation level (row-level, schema-level, database-level)
378```
379
380#### 4. The E-Commerce Order System
381```
382Pattern: Order processing with inventory, payment, shipping
383
384Skills Used:
385- ddd: Aggregates (Order, Inventory, Payment), Bounded Contexts
386- gof-patterns: State (order lifecycle), Command (payment operations), Observer (notifications)
387- clrs-algorithms: Priority Queue (order processing), Hash Table (inventory lookup)
388- ddia: Distributed Transactions (Saga pattern), Event Sourcing
389- clean-code: SRP (separate concerns), DIP (depend on repositories)
390
391Implementation Guide:
3921. Define Order Aggregate with invariants
3932. Use State pattern for order states (cart → payment → processing → shipped)
3943. Use Command for payment operations (process, refund, cancel)
3954. Use Observer for notifications (customer, warehouse, shipping)
3965. Apply Saga pattern for distributed transaction coordination
3976. Use Event Sourcing for order history and replay
398```
399
400#### 5. The Real-Time Leaderboard
401```
402Pattern: Sorted rankings with fast updates
403
404Skills Used:
405- clrs-algorithms: Red-Black Tree or Skip List (sorted rankings), Hash Table (user lookup)
406- gof-patterns: Observer (rank change notifications), Memento (snapshot rankings)
407- ddia: Replication (read scaling), Partitioning (range-based)
408- clean-code: Functions (small, focused), DRY (ranking logic)
409
410Implementation Guide:
4111. Use Sorted Set (Red-Black Tree) for O(log n) insert/delete/rank
4122. Use Hash Table for O(1) user score lookup
4133. Apply Observer for real-time rank change notifications
4144. Use Read Replicas for scaling leaderboard queries
4155. Partition by rank ranges for very large leaderboards
416```
417
418## Usage Examples
419
420### Example 1: Pattern Selection
421
422**Query:** "I need to create objects without specifying their concrete classes"
423
424**Router Response:**
425```
426Primary Match: Creational Patterns (gof-patterns)
427
428Recommendation: Factory Method Pattern
429
430Routing to: gof-patterns/gof-creational/factory-method.md
431
432Additional Considerations:
433- If creating families of related objects → Abstract Factory
434- If construction is complex → Builder
435- See: gof-patterns/pattern-selection.md for decision tree
436```
437
438### Example 2: Data Structure Selection
439
440**Query:** "What's the best data structure for fast lookup and maintaining sorted order?"
441
442**Router Response:**
443```
444Primary Match: Data Structure Selection (clrs-algorithms)
445
446Recommendation: Tree Map (Red-Black Tree or AVL Tree)
447
448Comparison:
449- Hash Table: O(1) lookup, NO sorted order
450- Tree Map: O(log n) lookup, YES sorted order ✓
451- Sorted Array: O(log n) search, O(n) insert ✗
452
453Routing to: clrs-algorithms/data-structures/trees/red-black-tree.md
454
455See also: clrs-algorithms/data-structure-selection.md
456```
457
458### Example 3: Architecture Design
459
460**Query:** "Design a notification system that supports email, SMS, and push notifications"
461
462**Router Response:**
463```
464Multi-Skill Solution:
465
4661. Pattern Selection (gof-patterns):
467 - Observer Pattern: Subscribe to events
468 - Strategy Pattern: Switch between notification methods
469 - Command Pattern: Queue notification actions
470
4712. Data Structures (clrs-algorithms):
472 - Priority Queue: Prioritize urgent notifications
473 - Hash Table: User preference lookup
474
4753. Distributed Systems (ddia):
476 - Queue (Kafka/RabbitMQ): Async processing
477 - Retry mechanisms: Handle failures
478
4794. Code Quality (clean-code):
480 - SRP: One class per notification channel
481 - OCP: Add new channels without modifying existing
482
483Implementation Stack:
484Observer → Command → Priority Queue → Strategy → DIP
485```
486
487### Example 4: Code Quality Review
488
489**Query:** "This function is 200 lines long and does too many things. How do I improve it?"
490
491**Router Response:**
492```
493Primary Match: Code Quality (clean-code)
494
495Violations Detected:
4961. Single Responsibility Principle (SRP) - function does too many things
4972. Function size - should be 5-20 lines
498
499Refactoring Steps:
5001. Extract methods for each responsibility (clean-code/practices/functions.md)
5012. Apply SRP (clean-code/solid/single-responsibility.md)
5023. Use meaningful names (clean-code/practices/meaningful-names.md)
503
504Supporting Guidance:
505- pragmatic-programmer/practices/refactoring.md: When and how to refactor
506- gof-patterns: Consider Template Method or Strategy if algorithm varies
507
508Tools:
509- Extract Method refactoring
510- Compose Method pattern
511- Replace Temp with Query
512```
513
514## Language Translation Notes
515
516All examples use language-agnostic pseudocode with these conventions:
517- `class` for type definitions
518- `function` for methods/functions
519- `->` for method calls on objects
520- `//` for comments
521- Type hints shown as `name: Type`
522
523### Translation Guide
524
525| Language | Class | Method | Call | Comment | Types |
526|----------|-------|--------|------|---------|-------|
527| **PHP** | `class` | `function` | `->` | `//` | Docblocks or PHP 8+ |
528| **JavaScript** | `class` | `function` / arrow | `.` | `//` | JSDoc or TypeScript |
529| **TypeScript** | `class` | method / arrow | `.` | `//` | Native types |
530| **Python** | `class` | `def` | `.` | `#` | Type hints |
531| **Java** | `class` | method | `.` | `//` | Native types |
532| **C#** | `class` | method | `.` | `//` | Native types |
533| **Go** | `type` / `struct` | `func` | `.` | `//` | Native types |
534| **Rust** | `struct` / `trait` | `fn` | `.` | `//` | Native types |
535
536## Advanced Usage
537
538### Combining Multiple Skills
539
540For complex problems, explicitly request multi-skill analysis:
541
542```
543"I need a comprehensive solution for [problem] covering patterns, data structures, and distributed systems"
544```
545
546The router will orchestrate across all relevant skills and provide:
5471. Pattern recommendations (gof-patterns)
5482. Data structure choices (clrs-algorithms)
5493. Scalability considerations (ddia)
5504. Domain modeling (ddd if applicable)
5515. Code quality guidelines (clean-code)
5526. Implementation best practices (pragmatic-programmer)
553
554### Deep Dives
555
556Request detailed documentation from specific skills:
557
558```
559"Show me the full Observer pattern documentation"
560→ Routes to: gof-patterns/gof-behavioral/observer.md
561
562"Explain Red-Black Tree implementation with examples"
563→ Routes to: clrs-algorithms/data-structures/trees/red-black-tree.md
564
565"What are all SOLID principles?"
566→ Routes to: clean-code/solid/ (all 5 principles)
567```
568
569### Comparison Queries
570
571Request trade-off analysis:
572
573```
574"/compare singleton vs dependency injection"
575→ Multi-skill analysis from gof-patterns + clean-code
576
577"/compare b-tree vs lsm-tree"
578→ Multi-skill analysis from clrs-algorithms + ddia
579
580"/compare entity vs value object"
581→ Analysis from ddd/tactical/
582```
583
584## Tips for Effective Use
585
586### 1. Start with Problem, Not Solution
587
588❌ "Show me the Singleton pattern"
589✅ "I need exactly one instance of a configuration manager"
590
591The router will recommend the right pattern and warn about potential issues.
592
593### 2. Provide Context
594
595❌ "Which data structure should I use?"
596✅ "I need fast lookup by key and sorted iteration over 10,000 items"
597
598Context enables better routing and recommendations.
599
600### 3. Ask About Trade-offs
601
602✅ "What are the trade-offs between Factory Method and Abstract Factory?"
603✅ "When should I use Array vs Linked List?"
604✅ "Compare event sourcing vs traditional CRUD"
605
606Trade-off queries trigger comparison mode with tables and decision guides.
607
608### 4. Request Implementation Guidance
609
610✅ "How do I implement LRU cache in TypeScript?"
611✅ "Show me Observer pattern in Python"
612✅ "Implement Repository pattern in PHP"
613
614Includes language-specific code generation with best practices.
615
616### 5. Explore Related Concepts
617
618After getting a recommendation, ask:
619- "What patterns work well with [pattern]?"
620- "What are common combinations with [data structure]?"
621- "How does [concept] relate to [other concept]?"
622
623## Contributing
624
625To add new patterns, algorithms, or concepts to any skill:
6261. Follow the established format in existing documentation
6272. Include definition, when to use, implementation, examples, trade-offs
6283. Update the relevant SKILL.md quick reference tables
6294. Add decision guide entries if applicable
630
631## Acknowledgments
632
633This unified knowledge base is built on the shoulders of giants:
634
635- **Gang of Four** (Gamma, Helm, Johnson, Vlissides): Design Patterns
636- **CLRS** (Cormen, Leiserson, Rivest, Stein): Introduction to Algorithms
637- **Robert C. Martin** (Uncle Bob): Clean Code
638- **Martin Kleppmann**: Designing Data-Intensive Applications
639- **Eric Evans**: Domain-Driven Design
640- **Andrew Hunt & David Thomas**: The Pragmatic Programmer
641- **Harold Abelson & Gerald Jay Sussman**: Structure and Interpretation of Computer Programs
642
643---
644
645**Made with Claude Code**
646
647*Total: 147 documentation files across 7 focused skills*