xiaohongshu
xiaohongshu
architecture-guardian
Review architecture decisions and code changes against documented architecture principles. Use this skill before implementing new features or refactoring existing code to ensure compliance with layer boundaries, separation of concerns, and design patterns. Should be invoked when user requests "ar...
Full skill instructions
Act as the architect in the engineer-architect review process. Before writing code, review the proposed changes against the documented architecture in docs/ARCHITECTURE.md to ensure:
Ask clarifying questions:
Read relevant sections:
docs/ARCHITECTURE.md - Core principles and layer descriptionsdocs/ARCHITECTURE.md sections 6-7 - Service Layer and Middleware patternsdocs/ARCHITECTURE.md "Architecture Evolution" - Recent refactorings and rationaledocs/DESIGN_PATTERNS.md - Comprehensive catalog of all design patterns used in codebase.claude/CLAUDE.md - Development standardsIdentify applicable patterns (see docs/DESIGN_PATTERNS.md for details):
Check against architectural rules:
❌ VIOLATIONS:
- UI layer contains game logic (combat resolution, dice rolling, AI decisions)
- Game engine imports from UI layer
- Service layer contains presentation logic
- Data layer contains business logic
✅ CORRECT:
- UI → Service → Engine → Data (dependency flow)
- Each layer only depends on layers below it
- No circular dependencies
❌ VIOLATIONS:
- Direct validation in action handlers (if not in_combat, if not is_turn)
- Manual resource refunding on failure
- Inconsistent action consumption
- Missing logging
✅ CORRECT:
- All combat actions use CombatActionExecutor
- Middleware handles validation, logging, cleanup
- Action handlers focus only on action logic
- Resources auto-refund on failure
❌ VIOLATIONS:
- CLI queries data_loader directly (items_data, monsters_data, races_data)
- Manual assembly of attack/spell context (60+ lines)
- Repeated data queries across handlers
✅ CORRECT:
- Use CombatContextService.get_attack_parameters()
- Use CombatContextService.get_combatant_context()
- Use CombatContextService.build_attack_context()
- Context assembly in one reusable place
❌ VIOLATIONS:
- AI decisions in CLI (target selection, condition removal)
- Combat history stored in CLI
- Enemy numbering in CLI instance variables
- Battlefield state built in UI layer
✅ CORRECT:
- AI decisions in systems/ai/
- Combat history in GameState
- Enemy numbering in InitiativeTracker/CombatEngine
- Battlefield state from CombatEngine.get_battlefield_state()
✅ RESPONSIBILITIES BY LAYER:
- UI Layer: Display, input, formatting
- Service Layer: Data assembly, context building
- Middleware Layer: Validation, cross-cutting concerns
- Game Engine: Mechanics, state, deterministic rules
- Data Layer: JSON content, no logic
Output format:
# Architecture Review: [Feature/Change Name]
## Intent
[What the user wants to accomplish]
## Proposed Approach
[High-level description of the planned implementation]
## Architecture Analysis
### ✅ Compliant Aspects
- [What follows architecture correctly]
- [Existing patterns being used properly]
### ⚠️ Concerns
- [Potential violations or anti-patterns]
- [Areas that need adjustment]
### ❌ Violations
- [Clear architecture violations]
- [Specific rules being broken]
## Recommendations
### 1. [Recommendation Title]
**Issue**: [What's wrong with current approach]
**Fix**: [How to align with architecture]
**Pattern**: [Which documented pattern to use]
**Example**: [Code snippet or reference]
### 2. [Next Recommendation]
[Same structure]
## Decision
**APPROVED** ✅ - Proceed with implementation (may have minor suggestions)
**APPROVED WITH CHANGES** ⚠️ - Proceed after addressing concerns
**REJECTED** ❌ - Requires redesign to meet architecture principles
## Next Steps
1. [Action item]
2. [Action item]
If invoked after code is written:
Anti-pattern detection:
# Search for these in wrong places:
- "resolve_attack" in ui/ files → Game logic in UI
- "data_loader.load" in cli.py (not in service) → Direct data access
- "if not in_combat" in handle_* methods → Validation bypass
- "pool.current += 1" after failures → Manual resource refund
- "min(living_party, key=lambda" in ui/ → AI in UI
User: "I want to add a 'Dash' action that lets characters move twice"
Guardian Response:
# Architecture Review: Dash Action
## Intent
Add Dash action (use action to double movement speed until end of turn)
## Proposed Approach
Add handle_dash() method to CLI that consumes an action and sets movement buff
## Architecture Analysis
### ✅ Compliant Aspects
- Adding to existing CLI command structure
- Will use action economy system
### ⚠️ Concerns
- Need to ensure middleware pattern is used
- Movement buff should be in game state, not CLI variable
### ❌ Violations
None identified yet
## Recommendations
### 1. Use Combat Middleware Pattern
**Issue**: New combat actions must go through validation pipeline
**Fix**: Use CombatActionExecutor with ActionType.ACTION
**Pattern**: See ARCHITECTURE.md Section 7 - Middleware Layer
**Example**:
```python
def handle_dash(self):
context = self.action_executor.execute(
actor=current_character,
action_type=ActionType.ACTION,
action_name="dash",
action_handler=lambda ctx: self._execute_dash(ctx)
)
Issue: Movement modifiers are game state, not UI state Fix: Add movement buff to Character or create timed effect Pattern: Use TimeManager for temporary effects Example: Similar to concentration spells
APPROVED WITH CHANGES ⚠️
Follow middleware pattern and store state in game engine.
### Example 2: Context Assembly
**User**: "I need to show weapon details in the attack display"
**Guardian Response**:
Show weapon properties (damage type, properties) in combat output
Issue: Don't add data queries to CLI Fix: Add weapon properties to AttackParameters dataclass Pattern: Service layer handles all data assembly Example:
# In services/combat_context.py
@dataclass
class AttackParameters:
# ... existing fields ...
weapon_properties: List[str] # NEW: ["finesse", "versatile"]
# Update get_attack_parameters() to populate this field
APPROVED ✅
Extend service layer, don't add queries to UI.
## Key Architectural Principles to Enforce
From `docs/ARCHITECTURE.md` and `docs/DESIGN_PATTERNS.md`:
1. **Separation of Concerns**: Game rules, content, narrative, and UI are completely separated
2. **Data-Driven Design**: All content in JSON, not hardcoded (Registry pattern via DataLoader)
3. **Event-Driven Architecture**: Components communicate via event bus (Observer pattern)
4. **Extensibility**: Easy to add content, features, systems (Strategy, Factory patterns)
5. **Deterministic Core + Creative Enhancement**: Game engine is deterministic; LLM only enhances narrative
6. **Dependency Injection**: Make dependencies explicit and testable (constructor injection)
7. **Inversion of Control**: Systems don't control each other; control flows through events
## Common Violations to Watch For
1. **Game logic creeping into UI**
- Combat resolution in CLI
- AI decisions in UI layer
- Dice rolling in presentation code
2. **Bypassing established patterns**
- Combat actions without middleware
- Context assembly without service layer
- Direct data queries in UI
3. **State management confusion**
- Game state in UI layer
- Combat history in CLI
- Display logic in game engine
4. **Breaking layer boundaries**
- UI importing from UI (circular)
- Engine importing from UI (upward dependency)
- Service importing from UI (wrong direction)
## Success Criteria
A successful architecture review should:
- ✅ Identify layer boundary violations before implementation
- ✅ Guide engineer to correct pattern/layer
- ✅ Reference specific sections of ARCHITECTURE.md
- ✅ Provide concrete code examples
- ✅ Make a clear approve/reject decision
- ✅ Prevent technical debt from accumulating
The goal is **prevention, not just detection** - catch issues at design time, not commit time.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience