|
| 1 | +--- |
| 2 | +name: assert_architecture |
| 3 | +description: Verify code conforms to architecture diagrams, ADRs, and project structure. |
| 4 | +argument-hint: [Optional scope to verify (module, service, or layer name)] |
| 5 | +model: sonnet |
| 6 | +--- |
| 7 | + |
| 8 | +# Assert Architecture Prompt |
| 9 | + |
| 10 | +## Goal |
| 11 | + |
| 12 | +Verify that the codebase (or a specific scope) conforms to the documented architecture: C4 diagrams, ADRs, and project tree structure. |
| 13 | + |
| 14 | +## Context |
| 15 | + |
| 16 | +### Architecture diagrams (micro) |
| 17 | + |
| 18 | +```shell |
| 19 | +! ls -1tr {{DOCS}}/memory/internal/ |
| 20 | +``` |
| 21 | + |
| 22 | +### Architecture decisions |
| 23 | + |
| 24 | +```shell |
| 25 | +! ls -1tr {{DOCS}}/internal/decisions/ |
| 26 | +``` |
| 27 | + |
| 28 | +### Scope |
| 29 | + |
| 30 | +```text |
| 31 | +$ARGUMENTS |
| 32 | +``` |
| 33 | + |
| 34 | +## Rules |
| 35 | + |
| 36 | +- Read ALL architecture sources before checking code |
| 37 | +- Report violations with file path, line, and which constraint is violated |
| 38 | +- Distinguish macro violations (service boundaries, tree structure) from micro violations (layer imports, patterns) |
| 39 | +- Do not fix violations — only report them |
| 40 | +- If no scope is provided, check the entire project |
| 41 | +- Use `!` backtick pattern to inspect project structure and imports |
| 42 | + |
| 43 | +## Steps |
| 44 | + |
| 45 | +1. Load architecture context: |
| 46 | + - Remember architecture diagrams from `{{DOCS}}/memory/architecture.md` |
| 47 | + - Read micro diagrams from `{{DOCS}}/memory/internal/` (if scope targets a specific module) |
| 48 | + - Read ADRs from `{{DOCS}}/internal/decisions/` |
| 49 | + - Extract the expected project tree structure from diagrams |
| 50 | + |
| 51 | +2. Verify macro architecture (service boundaries): |
| 52 | + - Read the expected tree structure from `{{DOCS}}/memory/architecture.md` |
| 53 | + - Compare actual code structure against the documented tree |
| 54 | + - Check for files outside expected boundaries |
| 55 | + - Check for direct imports between independent services |
| 56 | + |
| 57 | +3. Verify micro architecture (internal layers): |
| 58 | + - For each module in scope, check import directions match layer constraints |
| 59 | + - Verify domain layer has zero external imports |
| 60 | + - Verify application layer only depends on domain (via ports) |
| 61 | + - Check for circular dependencies between modules |
| 62 | + - Verify patterns: use cases have ports, adapters implement interfaces |
| 63 | + |
| 64 | +4. Generate violation report: |
| 65 | + - List each violation with: severity (critical/warning), file path, constraint violated, suggested fix |
| 66 | + - Group by macro vs micro |
| 67 | + - If zero violations, confirm conformity |
| 68 | + |
| 69 | +5. Summarize: total violations, critical count, and recommended next actions. |
0 commit comments