ddd-architect
Ensure code follows DDD architecture and DAL separation principles.LOAD THIS SKILL WHEN: Creating new feature/module | User says "新功能", "新模組", "架構", "DDD", "scaffold" | checking architecture compliance | reviewing domain design.CAPABILITIES: Generate DDD folder structure, check dependency direction, validate DAL separation, scaffold Entities/ValueObjects/Repositories.
When & Why to Use This Skill
The DDD Architect skill streamlines the implementation of Domain-Driven Design (DDD) and Data Access Layer (DAL) separation. It automates the creation of standardized project structures, enforces strict dependency rules, and provides real-time architectural validation to ensure long-term code maintainability and scalability.
Use Cases
- New Feature Scaffolding: Automatically generate complex DDD folder structures including Entities, Value Objects, and Repositories when starting a new module to ensure consistency.
- Architectural Compliance: Detect and prevent illegal imports, such as Domain layer dependencies on Infrastructure or direct database access from the Application layer.
- Dependency Direction Validation: Ensure the project follows the 'Dependency Inversion' principle, keeping the core business logic isolated from external frameworks and databases.
- Automated Code Review: Provide instant feedback on architectural violations during the development phase to reduce technical debt and maintain clean code standards.
| name | ddd-architect |
|---|---|
| description | | |
| LOAD THIS SKILL WHEN | Creating new feature/module | User says "新功能", "新模組", "架構", "DDD", "scaffold" | checking architecture compliance | reviewing domain design. |
| CAPABILITIES | Generate DDD folder structure, check dependency direction, validate DAL separation, scaffold Entities/ValueObjects/Repositories. |
DDD 架構輔助技能
描述
確保程式碼遵循 DDD 架構與 DAL 分離原則。
觸發條件
- 「建立新功能」「新增模組」
- 「架構檢查」
- 建立新檔案時自動檢查
法規依據
- 憲法:CONSTITUTION.md 第 1、2 條
- 子法:.github/bylaws/ddd-architecture.md
功能
1. 新功能腳手架
當建立新功能時,自動生成 DDD 結構:
「新增 Order 領域」
生成:
src/
├── Domain/
│ ├── Entities/Order.py
│ ├── ValueObjects/OrderId.py
│ ├── Aggregates/OrderAggregate.py
│ └── Repositories/IOrderRepository.py
├── Application/
│ ├── UseCases/CreateOrder.py
│ └── DTOs/OrderDTO.py
└── Infrastructure/
└── Persistence/Repositories/OrderRepository.py
2. 架構違規檢查
偵測並警告:
- ❌ Domain 層導入 Infrastructure
- ❌ 直接在 Domain 操作資料庫
- ❌ Application 層直接操作資料庫
- ❌ Repository 實作放在 Domain 層
3. 依賴方向驗證
✅ Presentation → Application → Domain
✅ Infrastructure → Domain (實作介面)
❌ Domain → Infrastructure
❌ Domain → Application
輸出格式
🏗️ DDD 架構檢查
✅ 依賴方向正確
✅ DAL 正確分離
⚠️ 警告:
- src/Domain/Services/UserService.py:15
導入了 Infrastructure 模組
建議:
將資料庫操作移至 Repository