SuperAPI AI Directory

ddd-architect

General & other

View repository

Updated 10-16 09:56

About this skill

DDD Architecture Assistant Skill

Description

Ensure code follows DDD architecture and DAL separation principles.

Trigger Conditions

  • "Create new feature" "Add new module"
  • "Architecture check"
  • Automatically check when creating new files

Regulatory Basis

  • Constitution: CONSTITUTION.md Articles 1, 2
  • Sub-law: .github/bylaws/ddd-architecture.md

Features

1. New Feature Scaffolding

When creating a new feature, automatically generate the DDD structure:

「新增 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. Architecture Violation Check

Detect and warn:

  • ❌ Domain layer imports Infrastructure
  • ❌ Directly operating the database in Domain
  • ❌ Application layer directly operating the database
  • ❌ Repository implementation placed in the Domain layer

3. Dependency Direction Verification

✅ Presentation → Application → Domain
✅ Infrastructure → Domain (實作介面)
❌ Domain → Infrastructure
❌ Domain → Application

Output Format

🏗️ DDD 架構檢查

✅ 依賴方向正確
✅ DAL 正確分離
⚠️ 警告:
  - src/Domain/Services/UserService.py:15
    導入了 Infrastructure 模組

建議:
  將資料庫操作移至 Repository