DDD Compliance Check
Two-mode DDD compliance validation for Java projects. Auto-detects mode from user's trigger phrase.
Mode Detection
| Trigger Phrases |
Mode |
Scope |
| "check my changes", "pre-commit", "review this code", "validate my code" |
Incremental |
git diff only |
| "full audit", "architecture review", "DDD compliance report", "check entire project", "pre-release" |
Full |
All Java files |
Incremental Mode
Workflow
- Find changed files:
git diff --cached --name-only --diff-filter=ACMR | grep '\.java$' (also check unstaged and HEAD diff)
- Classify by layer: Map package path to layer using layer rule files in
references/.
- Load relevant rules: Only load rule files matching changed layers. Always load
references/anti-patterns.md.
- Check each file: Validate structural rules (base class, package, naming), dependency rules (no forbidden imports), anti-patterns.
- Report: Per-file violations with severity and fix. Skip "looks good" for clean files.
If no Java files changed: "No Java files changed — nothing to check."
Full Mode
Workflow
- Discover:
find . -name "*.java" -not -path "*/target/*" -not -path "*/test/*" | sort
- Load all rules: Read every layer rule file in
references/. Load references/base-classes-reference.md and references/exception-handling.md as needed.
- Layer-by-layer audit: Group by layer, check package, base class, naming, dependencies, structure, exception mode.
- Cross-layer: Verify dependency direction (
grep -r "import org\.bookiosk\.ddd\."), detect anemic models, check exception boundaries.
- Report: Executive summary with compliance score, per-layer breakdown, anti-patterns section, dependency graph, ranked recommendations.
See examples/violation-report.md for sample output.
Layer Checklists
See references/shared-checks.md for the complete severity table (CRITICAL/HIGH/MEDIUM/LOW) and per-layer checklists.
Red Flags
These thoughts mean STOP — you're about to make a mistake:
| Thought |
Reality |
| "This import looks wrong but the code compiles" |
Compilation ≠ architecture compliance. Check the layer dependency rules. |
| "It's just one setter, what's the harm?" |
Public setId on aggregates breaks identity protection. Every violation matters. |
| "I'll skip the cross-layer check, the file looks fine" |
Domain→infrastructure imports are invisible without explicit grep. |
| "This exception pattern is different but it works" |
Wrong exception mode breaks the entire error handling contract. |
| "The design pattern makes the code cleaner" |
Design patterns in domain layer are FORBIDDEN — no exceptions. |
| "I'll report 'looks good' for files with no issues" |
Only report problems. Silence means clean. |
| "A perfect score isn't possible, so I'll be lenient" |
Architectural decay accelerates. Flag every real violation. |
Common Mistakes
- Flagging intentional violations as CRITICAL — verify with author before escalating
- Skipping cross-layer dependency check — domain→infrastructure is the #1 architecture decay vector
- Ignoring exception mode mismatch — 阻断型 layer throwing to 分支型 caller breaks error handling contract
- Incremental mode checking unchanged files — only touch
git diff output
Quality Checklist
Before finalizing:
1---
2name: ddd-check
3description: DDD compliance check for Java projects with auto mode detection. Use when user mentions "DDD check", "DDD audit", "check my changes", "architecture review", "pre-commit check", "DDD compliance", "review this code", or "check entire project".
4license: Apache-2.0
5metadata: {"version": "2.0", "skill-author": "bookiosk"}
6model: claude-sonnet-4-20250514
7allowed-tools: Read, Grep, Glob, Bash
8user-invocable: true
9---
10
11# DDD Compliance Check
12
13Two-mode DDD compliance validation for Java projects. Auto-detects mode from user's trigger phrase.
14
15## Mode Detection
16
17| Trigger Phrases | Mode | Scope |
18|---|---|---|
19| "check my changes", "pre-commit", "review this code", "validate my code" | **Incremental** | `git diff` only |
20| "full audit", "architecture review", "DDD compliance report", "check entire project", "pre-release" | **Full** | All Java files |
21
22## Incremental Mode
23
24### Workflow
25
261. **Find changed files**: `git diff --cached --name-only --diff-filter=ACMR | grep '\.java$'` (also check unstaged and HEAD diff)
272. **Classify by layer**: Map package path to layer using layer rule files in `references/`.
283. **Load relevant rules**: Only load rule files matching changed layers. Always load `references/anti-patterns.md`.
294. **Check each file**: Validate structural rules (base class, package, naming), dependency rules (no forbidden imports), anti-patterns.
305. **Report**: Per-file violations with severity and fix. Skip "looks good" for clean files.
31
32If no Java files changed: "No Java files changed — nothing to check."
33
34## Full Mode
35
36### Workflow
37
381. **Discover**: `find . -name "*.java" -not -path "*/target/*" -not -path "*/test/*" | sort`
392. **Load all rules**: Read every layer rule file in `references/`. Load `references/base-classes-reference.md` and `references/exception-handling.md` as needed.
403. **Layer-by-layer audit**: Group by layer, check package, base class, naming, dependencies, structure, exception mode.
414. **Cross-layer**: Verify dependency direction (`grep -r "import org\.bookiosk\.ddd\."`), detect anemic models, check exception boundaries.
425. **Report**: Executive summary with compliance score, per-layer breakdown, anti-patterns section, dependency graph, ranked recommendations.
43
44See `examples/violation-report.md` for sample output.
45
46## Layer Checklists
47
48See `references/shared-checks.md` for the complete severity table (CRITICAL/HIGH/MEDIUM/LOW) and per-layer checklists.
49
50## Red Flags
51
52These thoughts mean STOP — you're about to make a mistake:
53
54| Thought | Reality |
55|---|---|
56| "This import looks wrong but the code compiles" | Compilation ≠ architecture compliance. Check the layer dependency rules. |
57| "It's just one setter, what's the harm?" | Public setId on aggregates breaks identity protection. Every violation matters. |
58| "I'll skip the cross-layer check, the file looks fine" | Domain→infrastructure imports are invisible without explicit grep. |
59| "This exception pattern is different but it works" | Wrong exception mode breaks the entire error handling contract. |
60| "The design pattern makes the code cleaner" | Design patterns in domain layer are FORBIDDEN — no exceptions. |
61| "I'll report 'looks good' for files with no issues" | Only report problems. Silence means clean. |
62| "A perfect score isn't possible, so I'll be lenient" | Architectural decay accelerates. Flag every real violation. |
63
64## Common Mistakes
65
66- **Flagging intentional violations as CRITICAL** — verify with author before escalating
67- **Skipping cross-layer dependency check** — domain→infrastructure is the #1 architecture decay vector
68- **Ignoring exception mode mismatch** — 阻断型 layer throwing to 分支型 caller breaks error handling contract
69- **Incremental mode checking unchanged files** — only touch `git diff` output
70
71## Quality Checklist
72
73Before finalizing:
74- [ ] Mode correctly detected from user's trigger phrase
75- [ ] Only relevant rule files loaded (incremental) or all layers covered (full)
76- [ ] Every violation references the specific rule file and section heading
77- [ ] Each violation includes the exact fix, not just the problem
78- [ ] CRITICAL issues listed first, prioritized by blast radius
79- [ ] Anti-patterns cross-checked against `references/anti-patterns.md`