Triggers: adding new features/modules, architecture checks, automatic checks when creating new files
Tools:grep_search(search imports),list_dir、read_file、create_file
Layer structure
src/domain/ → entities, value_objects, aggregates, repositories (interfaces)
src/application/ → use_cases, dtos
src/infrastructure/ → persistence, services (external service implementations)
src/interfaces/ → api, mcp
Dependency rules
✅ Presentation → Application → Domain ← Infrastructure (implements interfaces) ❌ Domain → Infrastructure, Domain → Application, Application → Presentation
Violation checks
| Violation | Fix |
|---|---|
| Domain → Infrastructure | Use Repository interfaces |
| Direct SQL in Domain | Extract to Repository |
| Application → DB | Through Repository |
Check methods:grep_search(query="from.*infrastructure.*import", isRegexp=True, includePattern="**/domain/**/*.py")
Workflow
A: New feature scaffolding — Create in order Domain (entity + repo interface) → Application (use_case + dto) → Infrastructure (repo implementation) B: Architecture violation check — grep Infrastructure imports in the Domain layer → any result is a violation