specwright/templates/skills/dev-team/architect/pattern-enforcement/SKILL.md
# Pattern Enforcement Skill > Skill: Pattern Enforcement > Role: Architect > Created: 2026-01-09 > Version: 1.0.0 ## Purpose Ensures architectural patterns, design principles, and code organization standards are consistently followed across the codebase. Acts as the guardian of architectural integrity. ## When to Activate This Skill **Trigger Conditions:** - Code review requests - Feature implementation reviews - Refactoring proposals - Architecture violation detection - New component/modul
npx skillsauth add michsindlinger/specwright specwright/templates/skills/dev-team/architect/pattern-enforcementInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Skill: Pattern Enforcement Role: Architect Created: 2026-01-09 Version: 1.0.0
Ensures architectural patterns, design principles, and code organization standards are consistently followed across the codebase. Acts as the guardian of architectural integrity.
Trigger Conditions:
Context Signals:
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[TECH_STACK_SPECIFIC]
[MCP_TOOLS]
<!-- Populated during skill creation based on: 1. User's installed MCP servers 2. User's selection for this skill Recommended for this skill (examples): - filesystem - Read and analyze code structure - git - Review commit history and changes - [TECH_STACK_SPECIFIC] - Framework-specific analysis tools Note: Skills work without MCP servers, but functionality may be limited -->Scenario: Review a controller with business logic
Analysis:
ISSUE: Business logic in controller
PATTERN: MVC - Controllers should be thin
VIOLATION:
[TECH_STACK_SPECIFIC]
```python
# Bad: Business logic in controller
def create_user(request):
user = User(email=request.POST['email'])
if User.objects.filter(email=user.email).exists():
return error("Email exists")
user.save()
send_welcome_email(user)
create_default_settings(user)
return success(user)
RECOMMENDATION: [TECH_STACK_SPECIFIC]
# Good: Thin controller, logic in service
def create_user(request):
result = UserService.create(request.POST['email'])
return result
Justification: Controllers should orchestrate, not implement business logic.
Scenario: Complex business operation spanning multiple models
Pattern Application:
PATTERN: Service Object for complex operations
IMPLEMENTATION:
[TECH_STACK_SPECIFIC]
```ruby
# Service object pattern
class OrderFulfillmentService
def initialize(order)
@order = order
end
def fulfill
ActiveRecord::Base.transaction do
process_payment
update_inventory
send_notifications
create_shipment
end
end
private
# Implementation details...
end
BENEFITS:
### Example 3: Dependency Direction Validation
**Scenario:** Feature module depends on infrastructure
**Analysis:**
ISSUE: Dependency violation PATTERN: Clean Architecture - Inner layers should not depend on outer layers
VIOLATION: Domain Layer -> Infrastructure Layer (WRONG)
RECOMMENDATION: Domain Layer -> Abstraction (Interface/Protocol) Infrastructure Layer -> Implements Abstraction (CORRECT)
REFACTORING: [TECH_STACK_SPECIFIC]
### Example 4: Pattern Documentation
**Scenario:** New pattern introduced in project
**Documentation Template:**
```markdown
# [Pattern Name]
## Purpose
[Why this pattern exists in our codebase]
## When to Use
[Specific scenarios where this pattern applies]
## Implementation
[TECH_STACK_SPECIFIC]
[Code example showing the pattern]
## Related Patterns
[Other patterns this works with or replaces]
## Decision Reference
See: specwright/product/architecture-decision.md#DEC-XXX
1. RECEIVE: Code/design to review
2. IDENTIFY: Applicable architectural patterns
3. ANALYZE: Compliance with patterns
4. DETECT: Violations or anti-patterns
5. EVALUATE: Severity and impact
6. RECOMMEND: Fixes or justifications
7. DOCUMENT: Findings and decisions
8. EDUCATE: Explain pattern rationale
tools
Session Handoff: Erstellt eine vollständige Zusammenfassung der aktuellen Session für einen sauberen Kontextwechsel. NUR bei explizitem Aufruf (/session-handoff). NICHT automatisch auslösen. Geeignet wenn der User die Session resetten will, den Kontext aufräumen will, oder bei ~120k Tokens angelangt ist.
development
Pre-Mortem Risk Analysis: Strukturierte Prospective-Hindsight-Übung um launch-blocking Risiken vor Commitment aufzudecken. Team stellt sich vor, das Produkt sei 14 Tage nach Launch gefloppt, und arbeitet rückwärts. Klassifiziert Risiken in Tigers (echt), Paper Tigers (hypothetisch), Elephants (unausgesprochen). Nutze diesen Skill vor Build-Commitment, bei zu hoher Stakeholder-Confidence, vor Major-Releases, oder wenn das Team vage Sorgen nicht artikulieren kann. Trigger: /pre-mortem, 'pre-mortem', 'risk analysis', 'was könnte schiefgehen', 'risiken vor launch'.
testing
Six-Sigma Atomicity Validator for create-spec stories
tools
UX pattern definition guidance for navigation, user flows, interactions, and accessibility