Design Pattern Recognition
Auto-Skill’s Design Pattern Detector identifies 18 different patterns across three categories: architectural patterns, coding patterns, and workflow patterns. This helps generate skills with rich contextual understanding.Pattern Categories
- Architectural (8)
- Coding (6)
- Workflow (4)
Structural organization patterns for codebases:
- MVC — Model-View-Controller separation
- Repository — Data access abstraction
- Factory — Object creation pattern
- Singleton — Single-instance classes
- Strategy — Interchangeable algorithms
- Observer — Event handling pattern
- Adapter — Interface compatibility
- Dependency-Injection — DI pattern
Pattern Detection Methods
File Path Analysis
Detect architectural patterns from directory structure
models/, views/, controllers/ → MVCCode Content Search
Scan file contents for pattern indicators
async, await → Async-PatternTool Sequence Matching
Recognize workflows from tool usage
Write → Bash → Edit → Bash → TDDConfidence Scoring
Calculate match confidence from indicator countMore indicators = higher confidence
DesignPattern Type
Detected patterns include rich metadata:Architectural Patterns
Detected from file paths and code structure:MVC Example
MVC Example
Detected when:
- Directory structure has
models/,views/,controllers/ - File paths contain “model”, “view”, or “controller”
- Code contains MVC-related keywords
Coding Patterns
Detected from code content:Async-Pattern Example
Async-Pattern Example
Detected when:Confidence increases with more indicators found.
- Code contains
async,await,asyncio, orconcurrent
Workflow Patterns
Detected from tool usage sequences:Workflow Detection Algorithm
Pattern Context
Predefined context provides guidance on when to use each pattern:PatternContext Type
File-Based Detection
Architectural and coding patterns are detected from file analysis:Confidence Calculation
Code Example Extraction
Code snippets are extracted around matching indicators:Code examples include ±3 lines of context around the indicator match, truncated to 200 characters.
Pattern Suggestions
Suggest relevant patterns based on intent and domain:Intent-to-Pattern Map
Domain-to-Pattern Map
Usage Example
API Reference
Detect workflow pattern from tool sequenceParameters:
toolSequence: string[]— Ordered tool namessessionContext?: Record<string, unknown>— Optional session context
DesignPattern | nullDetect architectural and coding patterns from filesParameters:
filePaths: string[]— File paths to analyzefileContents: Map<string, string>— File path → content map
DesignPattern[] — Sorted by confidence descendingGet contextual information about a patternParameters:
patternName: string— e.g. “MVC”, “TDD”, “Repository”
PatternContext | nullSuggest relevant patterns for intent and domainParameters:
intent: string— User intent (implement, refactor, debug, test)problemDomain: string— Technical domain (api, database, async, web)
Array<{ pattern: string; relevance: number }> — Sorted by relevancePattern Summary Table
| Pattern | Type | Min Confidence | Key Indicators |
|---|---|---|---|
| MVC | Architectural | 0.6 | models/, views/, controllers/ |
| Repository | Architectural | 0.5 | repository, repo, data_access |
| Factory | Architectural | 0.5 | factory, create_, builder |
| Singleton | Architectural | 0.6 | singleton, _instance |
| Strategy | Architectural | 0.5 | strategy, algorithm, policy |
| Observer | Architectural | 0.5 | observer, subscriber, event |
| Adapter | Architectural | 0.5 | adapter, wrapper, facade |
| Dependency-Injection | Architectural | 0.6 | inject, container, provider |
| Error-First-Handling | Coding | 0.4 | try, except, raise, error |
| REST-API-Design | Coding | 0.5 | @app.route, GET, POST |
| Async-Pattern | Coding | 0.5 | async, await, asyncio |
| Decorator-Pattern | Coding | 0.4 | @decorator, @property |
| Context-Manager | Coding | 0.5 | enter, exit, with |
| Builder-Pattern | Coding | 0.5 | builder, build(), with_ |
| TDD | Workflow | 0.7 | Write → Bash → Edit → Bash |
| Refactor-Safe | Workflow | 0.7 | Read → Edit → Bash |
| Debug-Systematic | Workflow | 0.7 | Read → Grep → Bash → Edit |
| Explore-Then-Implement | Workflow | 0.7 | Grep → Read → Read → Write |
Next Steps
Pattern Detection
See how design patterns integrate with pattern detection
Skill Generation
Learn how patterns enrich generated skills
Session Analysis
Understand workflow type detection
Pattern Detection
Explore pattern detection details