assets/skills/architect-review/SKILL.md
DDD architecture compliance review with automated checks and review loop. Use when user says "architect-review", "architecture review", "review architecture", "check architecture", "review ddd", "ddd review".
npx skillsauth add phuthuycoding/moicle architect-reviewInstall 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.
Review codebase against DDD architecture guidelines with automated checks and a review loop that keeps fixing until all checks pass.
/architect-review go-backend wallet
/architect-review react-frontend
/architect-review
Check for architecture files in these locations (in order):
.claude/architecture/~/.claude/architecture/| Name | File | Aliases |
|------|------|---------|
| ddd-architecture | ddd-architecture.md | ddd, core |
| go-backend | go-backend.md | go |
| react-frontend | react-frontend.md | react |
| flutter-mobile | flutter-mobile.md | flutter |
| laravel-backend | laravel-backend.md | laravel |
| remix-fullstack | remix-fullstack.md | remix |
| monorepo | monorepo.md | mono |
.claude/architecture/{name}.md → ~/.claude/architecture/{name}.mdgo.mod → go-backendpackage.json + vite.config → react-frontendpubspec.yaml → flutter-mobilecomposer.json → laravel-backendremix.config → remix-fullstackRead the architecture file completely. Also read ddd-architecture.md (core DDD spec) as the base reference.
Run the check scripts from the architecture doc. These vary per stack but follow this pattern:
echo "=== R1: Build ==="
{stack_build_command} && echo "PASS" || echo "FAIL"
echo "=== R2: Lint/Vet ==="
{stack_lint_command} && echo "PASS" || echo "FAIL"
echo "=== R3: Domain Purity (no framework imports) ==="
{grep_forbidden_imports_in_domain} && echo "FAIL" || echo "PASS"
echo "=== R4: No Cross-Domain Imports ==="
{check_domain_A_not_importing_domain_B} && echo "FAIL" || echo "PASS"
echo "=== R5: No Circular Imports ==="
{build_and_check_cycles} && echo "FAIL" || echo "PASS"
echo "=== R6: Tests Exist ==="
{find_test_files_in_domain} | wc -l
echo "=== R7: Tests Pass ==="
{stack_test_command} && echo "PASS" || echo "FAIL"
echo "=== R8: Wiring Registered ==="
{check_routes_or_providers_registered}
echo "=== R9: Event Names Match Registry ==="
{check_event_names_consistency}
echo "=== R10: Async Context Safety ==="
{check_no_request_context_in_goroutines}
Read the Check Scripts section from the loaded architecture doc and run those exact commands.
Record PASS/FAIL for each check. Continue to Phase 3 regardless — manual review catches what automated checks miss.
Read files and check DDD compliance. Focus on architecture structure, NOT business logic correctness.
| # | Check | What to look for |
|---|-------|-----------------|
| D1 | Domain dir exists | domain/{domain}/ with proper subdirs |
| D2 | Required subdirs | entities/, ports/, usecases/ at minimum |
| D3 | Value objects separate | valueobjects/ dir, NOT mixed in entities/ |
| D4 | Events separate | events/ dir with 1 file per event |
| D5 | Application layer | application/ports/{transport}/, services/, listeners/ |
| D6 | Infrastructure layer | Implements port interfaces |
| D7 | No legacy dirs | No modules/, pkg/ (for Go), or flat structure |
| # | Check | What to look for |
|---|-------|-----------------|
| E1 | Has constructor | Factory function/method: New{Entity}(), create(), etc. |
| E2 | Has behavior methods | State transitions, calculations, guard checks — NOT anemic |
| E3 | Raises domain events | Collects/emits events on state changes |
| E4 | No framework imports | Only stdlib + domain/shared + valueobjects |
| E5 | Has mappers (if applicable) | ToModel/FromModel or equivalent for persistence mapping |
| # | Check | What to look for |
|---|-------|-----------------|
| VO1 | Separate directory | In valueobjects/, NOT in entities/ |
| VO2 | Only stdlib imports | No external packages, no domain/shared |
| VO3 | Immutable with behavior | Typed values with query methods (IsPending, CanTransitionTo) |
| VO4 | Used by entities/ports | Entities and ports reference VO types, not raw strings |
| # | Check | What to look for |
|---|-------|-----------------|
| P1 | ports/ folder exists | MUST have ports/ — inline interfaces in usecases is a violation |
| P2 | One file per port | {store_name}.go/.ts/.dart/.php — not all in one file |
| P3 | Interface + related DTOs | Each file has interface + its param/result types |
| P4 | Domain types in signatures | Return entities/VOs, not primitives for typed values |
| P5 | Platform-agnostic naming | URLParser, NOT ShopeeURLParser |
| P6 | No infrastructure imports | Only stdlib + entities + valueobjects + shared |
| # | Check | What to look for |
|---|-------|-----------------|
| EV1 | One file per event | {event_name} naming, not multiple events in one file |
| EV2 | Extends base event | Embeds/extends shared BaseEvent |
| EV3 | Carries data for listeners | UserID, amounts, names — enough for side-effects |
| EV4 | Name matches registry | Event name string matches event bus registration |
| # | Check | What to look for |
|---|-------|-----------------|
| U1 | Uses port interfaces | From ports/ package, NOT inline interface definitions |
| U2 | Split by concern | One file per action group, max ~200 lines per file |
| U3 | Business logic lives here | Not in controller, not in store, not in service |
| U4 | No infrastructure imports | No ORM, no HTTP framework, no cache client |
| U5 | Dispatches domain events | After successful persistence, dispatches collected events |
| U6 | No deps.go or similar | Interfaces MUST be in ports/, not inline |
| # | Check | What to look for | |---|-------|-----------------| | SVC1 | Thin wrapper | Delegates to usecases, no business logic | | SVC2 | No infrastructure imports | No ORM, no HTTP framework |
| # | Check | What to look for |
|---|-------|-----------------|
| H1 | Registration function | Register{Module}Routes or equivalent wiring |
| H2 | Thin handlers | Parse input -> call service -> return output |
| H3 | No business logic | Logic is in usecases, not here |
| H4 | DTOs separate | Request/Response types in separate file |
| # | Check | What to look for |
|---|-------|-----------------|
| L1 | One per event | on_{event_name} naming |
| L2 | Side-effects only | Notifications, SSE, analytics — no business logic |
| L3 | Registered in event bus | Listed in registry/event bus setup |
| L4 | Background context | Async work uses background context, not request context |
| # | Check | What to look for | |---|-------|-----------------| | I1 | Implements port interface | All methods from the port interface | | I2 | Has mappers | Converts between domain entities and persistence models | | I3 | No business logic | Pure persistence — queries, saves, deletes | | I4 | Compile-time check | Interface compliance verified at compile time (where possible) |
| Level | Meaning | Examples | |-------|---------|---------| | CRITICAL | Architecture broken | Build fails, circular imports, domain imports framework | | HIGH | DDD violation | Cross-domain import, business logic in wrong layer, no ports dir, inline interfaces | | MEDIUM | Structure issue | Anemic entity, fat controller, missing events, missing tests, missing json tags | | LOW | Convention issue | File naming, redundant code, DTOs in wrong package |
ALL levels must be fixed.
## Architecture Review: {architecture} / {domain}
### Automated Checks
| # | Check | Status |
|---|-------|--------|
| R1 | Build | PASS/FAIL |
| R2 | Lint/Vet | PASS/FAIL |
| R3 | Domain purity | PASS/FAIL |
| R4 | No cross-domain imports | PASS/FAIL |
| R5 | No circular imports | PASS/FAIL |
| R6 | Tests exist | PASS/WARN |
| R7 | Tests pass | PASS/FAIL |
| R8 | Wiring registered | PASS/FAIL |
| R9 | Event names consistent | PASS/N/A |
| R10 | Async context safety | PASS/N/A |
### Architecture Review
| Area | Status | Violations |
|------|--------|------------|
| Directory Structure (D1-D7) | OK/ISSUE | ... |
| Entities (E1-E5) | OK/ISSUE | ... |
| Value Objects (VO1-VO4) | OK/ISSUE | ... |
| Ports (P1-P6) | OK/ISSUE | ... |
| Events (EV1-EV4) | OK/N/A | ... |
| UseCases (U1-U6) | OK/ISSUE | ... |
| Services (SVC1-SVC2) | OK/ISSUE | ... |
| Handlers (H1-H4) | OK/ISSUE | ... |
| Listeners (L1-L4) | OK/N/A | ... |
| Infrastructure (I1-I4) | OK/ISSUE | ... |
### Violations Found
1. [SEVERITY] Code — file:line — description
2. ...
### Recommended Fixes
1. Fix description
2. ...
### Overall Score: {A/B/C/D/F}
| Score | Criteria | |-------|----------| | A | 0 violations, all automated checks PASS | | B | 0 CRITICAL/HIGH, max 3 MEDIUM | | C | 0 CRITICAL, max 2 HIGH | | D | Has CRITICAL or 3+ HIGH | | F | Multiple CRITICAL, architecture fundamentally broken |
Keep looping until ALL checks pass and score is A or B.
LOOP:
1. Fix all violations found in report
2. Run automated checks (Phase 2)
3. Run architecture review (Phase 3)
4. Collect violations
5. IF violations with severity >= MEDIUM:
a. Fix violations
b. GOTO 1
6. IF only LOW violations or none:
BREAK → Report final status
# Verify build still works
{stack_build_command}
# Verify tests still pass
{stack_test_command}
# Re-check domain purity
{grep_forbidden_imports_in_domain}
This skill is designed to be called by new-feature and refactor skills at the end of their workflows:
# From new-feature skill, after Phase 5 (registration):
→ Run /architect-review {detected_stack} {domain}
→ Review loop until score >= B
# From refactor skill, after Phase 4 (cleanup):
→ Run /architect-review {detected_stack} {domain}
→ Review loop until score >= B
When called from another skill:
.claude/architecture/{name}.md # Project-specific (priority)
~/.claude/architecture/{name}.md # Global
ddd → ddd-architecture
go → go-backend
react → react-frontend
flutter → flutter-mobile
laravel → laravel-backend
remix → remix-fullstack
mono → monorepo
D: Directory Structure E: Entities VO: Value Objects
P: Ports EV: Events U: UseCases
SVC: Services H: Handlers L: Listeners
I: Infrastructure
development
Test-Driven Development workflow. Use when doing TDD, writing tests first, or when user says "tdd", "test first", "test driven", "red green refactor".
development
Thorough pull request review workflow with architecture compliance checks. Use when reviewing pull requests, checking code changes, or when user says "review pr", "check pr", "review code", "pr review", "review pull request".
development
Review local branch changes for architecture compliance, conventions, and code quality before pushing/PR. Stack-aware — detects the project stack and applies the matching rules. Use when user says "review changes", "review branch", "check branch", "check changes", "review my code", "review before pr".
testing
DDD architecture compliance review with automated checks and review loop. Use when user says "architect-review", "architecture review", "review architecture", "check architecture", "review ddd", "ddd review".