claude-blueprint 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.claude-plugin/plugin.json +25 -3
  2. package/README.md +102 -8
  3. package/agents/adr-context-mapper.md +165 -0
  4. package/agents/adr-diagram-generator.md +149 -0
  5. package/agents/adr-evidence-auditor.md +147 -0
  6. package/agents/adr-federation-indexer.md +123 -0
  7. package/agents/adr-forces-evaluator.md +166 -0
  8. package/agents/adr-reflexion-analyzer.md +166 -0
  9. package/agents/adr-risk-mapper.md +145 -0
  10. package/agents/adr-strategic-analyzer.md +157 -0
  11. package/agents/adr-tradeoff-analyzer.md +145 -0
  12. package/commands/advise.md +99 -0
  13. package/commands/architect.md +2 -2
  14. package/commands/audit.md +2 -2
  15. package/commands/blueprint.md +48 -4
  16. package/commands/challenge.md +58 -0
  17. package/commands/debt.md +30 -2
  18. package/commands/diagram.md +59 -0
  19. package/commands/digest.md +3 -2
  20. package/commands/drift.md +2 -2
  21. package/commands/eli5.md +3 -3
  22. package/commands/evaluate.md +2 -2
  23. package/commands/evidence.md +88 -0
  24. package/commands/export.md +85 -0
  25. package/commands/federate.md +73 -0
  26. package/commands/fitness.md +1 -1
  27. package/commands/govern.md +95 -0
  28. package/commands/guard.md +1 -1
  29. package/commands/health.md +16 -6
  30. package/commands/help.md +45 -7
  31. package/commands/impact.md +4 -4
  32. package/commands/init.md +25 -4
  33. package/commands/list.md +18 -9
  34. package/commands/map.md +69 -0
  35. package/commands/new.md +6 -6
  36. package/commands/radar.md +84 -0
  37. package/commands/rearchitect.md +3 -3
  38. package/commands/reflect.md +56 -0
  39. package/commands/retro.md +2 -2
  40. package/commands/review.md +2 -2
  41. package/commands/risk.md +46 -0
  42. package/commands/scope.md +109 -0
  43. package/commands/search.md +2 -2
  44. package/commands/status.md +156 -59
  45. package/commands/timeline.md +4 -3
  46. package/commands/trace.md +80 -0
  47. package/commands/tradeoff.md +44 -0
  48. package/commands/transition.md +3 -2
  49. package/commands/views.md +76 -0
  50. package/config/contexts.toml +100 -0
  51. package/config/evidence.toml +21 -0
  52. package/config/governance.toml +27 -0
  53. package/config/radar.toml +28 -0
  54. package/config/relationships.toml +223 -6
  55. package/config/state.toml +21 -0
  56. package/config/taxonomy.toml +75 -0
  57. package/package.json +11 -2
  58. package/src/install.js +30 -8
  59. package/src/verify.js +59 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "blueprint",
3
- "version": "1.0.1",
4
- "description": "Architecture Decision Records with teeth — lifecycle management, devil's advocate review, architecture evaluation team, post-fix retrospectives, and compliance auditing. All with a cranky senior engineer persona.",
3
+ "version": "2.0.0",
4
+ "description": "Architecture Decision Records with teeth — 39 commands, 21 agents, 15 architecture paradigms. DDD bounded contexts, DCAR forces evaluation, reflexion model conformance, epistemic status tracking, Wardley strategic analysis, C4 diagrams, ATAM tradeoff analysis, risk heat maps, cross-repo federation, and configurable governance tiers. All with a cranky senior engineer persona.",
5
5
  "author": {
6
6
  "name": "pragnition"
7
7
  },
@@ -21,6 +21,28 @@
21
21
  "maintainability",
22
22
  "testing-strategy",
23
23
  "bug-surface",
24
- "consistency"
24
+ "consistency",
25
+ "ddd",
26
+ "bounded-context",
27
+ "domain-driven-design",
28
+ "wardley-map",
29
+ "c4-model",
30
+ "dcar",
31
+ "forces-evaluation",
32
+ "reflexion-model",
33
+ "epistemic-status",
34
+ "evidence-tracking",
35
+ "atam",
36
+ "tradeoff-analysis",
37
+ "risk-storming",
38
+ "arc42",
39
+ "kruchten",
40
+ "4+1-views",
41
+ "governance",
42
+ "advice-process",
43
+ "federation",
44
+ "technology-radar",
45
+ "fitness-functions",
46
+ "architecture-drift"
25
47
  ]
26
48
  }
package/README.md CHANGED
@@ -115,17 +115,20 @@ Blueprint decomposes architectural governance into orthogonal concerns, each han
115
115
  │ │ │ │ │ │
116
116
  ▼ ▼ ▼ ▼ ▼ ▼
117
117
  ┌─────┐┌─────┐┌─────┐┌─────┐┌─────┐┌─────┐
118
- │ new ││ rev ││ eval││retro││audit││ ... │ ← 15 focused skills
118
+ │ new ││ rev ││ eval││retro││audit││ ... │ ← 38 focused skills
119
119
  └──┬──┘└──┬──┘└──┬──┘└──┬──┘└──┬──┘└─────┘
120
120
  │ │ │ │ │
121
121
  ▼ ▼ ▼ ▼ ▼
122
122
  ┌──────────────────────────────────────────┐
123
- │ AGENT POOL (12 agents) │
123
+ │ AGENT POOL (20 agents) │
124
124
  │ │
125
125
  │ researcher · devil's advocate · impact │
126
126
  │ compliance · consistency · bug surface │
127
127
  │ maintainability · testing · conways │
128
128
  │ retrospective · cartographer │
129
+ │ forces · reflexion · evidence · context │
130
+ │ strategic · diagram · tradeoff · risk │
131
+ │ federation │
129
132
  │ │
130
133
  │ ┌────────────────────────────────────┐ │
131
134
  │ │ SHARED PERSONA (persona.md) │ │
@@ -141,6 +144,10 @@ Blueprint decomposes architectural governance into orthogonal concerns, each han
141
144
  │ taxonomy.toml ← classifications │
142
145
  │ state.toml ← session memory │
143
146
  │ relationships.toml ← dependency graph │
147
+ │ contexts.toml ← bounded contexts │
148
+ │ evidence.toml ← epistemic status │
149
+ │ governance.toml ← governance mode │
150
+ │ radar.toml ← technology radar │
144
151
  └──────────────────────────────────────────┘
145
152
  ```
146
153
 
@@ -173,20 +180,39 @@ This is a lightweight [domain-specific language](https://en.wikipedia.org/wiki/D
173
180
 
174
181
  | Command | Agent(s) | Purpose |
175
182
  |---------|----------|---------|
183
+ | `/blueprint:advise "topic"` | — | Architecture Advice Process — structured consultation before proposing |
176
184
  | `/blueprint:new "topic"` | — | Create an ADR from interview |
177
185
  | `/blueprint:new --research "topic"` | researcher | Evidence-backed option analysis, then create |
178
186
  | `/blueprint:list` | — | Status table + contextual next actions |
179
- | `/blueprint:review N` | devil's advocate | Challenge across 5 dimensions before acceptance |
187
+ | `/blueprint:challenge N` | forces evaluator | DCAR structured forces analysis weigh arguments for/against |
188
+ | `/blueprint:review N` | devil's advocate | Adversarial challenge across 5 dimensions before acceptance |
180
189
  | `/blueprint:transition accept N` | — | Direct lifecycle transitions |
181
190
  | `/blueprint:search "term"` | — | Find decisions by topic + relationship graph |
182
191
  | `/blueprint:help` | — | Full reference + context-aware suggestions |
183
192
 
193
+ ### Domain Scoping
194
+
195
+ | Command | Agent(s) | Purpose |
196
+ |---------|----------|---------|
197
+ | `/blueprint:scope` | context mapper | Discover bounded contexts and assign ADRs to domains |
198
+ | `/blueprint:scope discover` | context mapper | Auto-detect contexts from codebase structure and git ownership |
199
+ | `/blueprint:scope assign ADR-N ctx` | — | Assign an ADR to a bounded context |
200
+ | `/blueprint:scope list` | — | Show all contexts with governed ADRs |
201
+
202
+ Domain scoping is based on Domain-Driven Design (Evans, 2003). Each bounded context represents an explicit boundary within which a domain model and its ubiquitous language apply. ADRs scoped to contexts enable per-team views (`/blueprint:list --context=payments`) and context-aware impact analysis. Context relationships (Customer-Supplier, Anti-Corruption Layer, Shared Kernel, etc.) are tracked in `{adr_directory}/.state/contexts.toml`.
203
+
184
204
  ### Analysis
185
205
 
186
206
  | Command | Agent(s) | Purpose |
187
207
  |---------|----------|---------|
188
208
  | `/blueprint:impact N` | impact analyzer | Cross-ADR conflict and dependency detection |
189
209
  | `/blueprint:audit` | compliance auditor | Verify codebase follows accepted decisions |
210
+ | `/blueprint:reflect` | reflexion analyzer | Formal architecture conformance — convergences, divergences, absences |
211
+ | `/blueprint:evidence` | evidence auditor | Audit epistemic status and temporal validity of ADR evidence |
212
+ | `/blueprint:map` | strategic analyzer | Wardley Map — classify components by evolution stage, detect build-vs-buy misalignment |
213
+ | `/blueprint:tradeoff` | tradeoff analyzer | ATAM utility trees — sensitivity points, tradeoff points, risks |
214
+ | `/blueprint:risk` | risk mapper | Architecture risk heat map — complexity × churn × coupling ÷ governance |
215
+ | `/blueprint:trace` | — | ADR-to-fitness-function traceability matrix — governance coverage gaps |
190
216
  | `/blueprint:retro` | retrospective | Post-fix: band-aid or systemic? Verified against sources. |
191
217
  | `/blueprint:rearchitect "topic"` | researcher + impact | Research → draft → impact check → supersede |
192
218
 
@@ -208,6 +234,7 @@ The full evaluation spawns all 5 agents in parallel, synthesizes an executive su
208
234
  | Command | Agent(s) | Purpose |
209
235
  |---------|----------|---------|
210
236
  | `/blueprint:architect` | cartographer | Generate or update `docs/ARCHITECTURE.md` — bird's-eye codemap following [matklad's philosophy](https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html) |
237
+ | `/blueprint:diagram` | diagram generator | Auto-generate C4 diagrams (System Context, Container, Component) from ADR graph |
211
238
  | `/blueprint:eli5` | — | Explain the entire architectural landscape in plain English — grouped by theme, no jargon, 30-second version at the end |
212
239
  | `/blueprint:eli5 N` | — | Explain a single ADR with analogies, expanded acronyms, and "what this means for you" consequences |
213
240
 
@@ -217,6 +244,11 @@ The eli5 commands exist because ADRs are written for the people who make decisio
217
244
 
218
245
  | Command | Agent(s) | Purpose |
219
246
  |---------|----------|---------|
247
+ | `/blueprint:export arc42` | — | Export ADR collection into arc42 12-section documentation format |
248
+ | `/blueprint:views` | — | Tag ADRs with 4+1 architectural views for stakeholder filtering |
249
+ | `/blueprint:federate` | federation indexer | Aggregate ADRs across multiple repositories — detect conflicts and dependencies |
250
+ | `/blueprint:radar` | — | Internal Technology Radar — track adoption lifecycle (Adopt/Trial/Assess/Hold) |
251
+ | `/blueprint:govern` | — | Configure governance mode — lightweight, advised, governed, or formal |
220
252
  | `/blueprint:status` | — | Governance dashboard — terminal summary + interactive HTML with knowledge graph, timeline, metrics, and debt table |
221
253
  | `/blueprint:health` | — | Self-diagnostic — 8 consistency checks (index sync, supersession chains, graph integrity, staleness) with auto-repair |
222
254
  | `/blueprint:hooks` | — | Configure automatic triggers — pre-commit guard, retro-suggest, architecture-sync, dependency-watch, periodic-health |
@@ -325,43 +357,67 @@ npm link
325
357
  claude-blueprint install --global
326
358
  ```
327
359
 
328
- The installer deploys 24 commands, 12 agents, and 4 config files to `~/.claude/commands/blueprint/`, and inserts a managed section into `CLAUDE.md` with the command reference.
360
+ The installer deploys 39 commands, 21 agents, and 8 config files to `~/.claude/commands/blueprint/`, and inserts a managed section into `CLAUDE.md` with the command reference.
329
361
 
330
362
  ## Architecture of Blueprint Itself
331
363
 
332
364
  ```
333
365
  blueprint/
334
- ├── commands/ 24 skill files
366
+ ├── commands/ 39 skill files
335
367
  │ ├── blueprint.md Thin router
336
368
  │ ├── init.md Bootstrap from existing codebase
337
369
  │ ├── help.md Contextual command reference
338
370
  │ ├── list.md Status table with suggestions
371
+ │ ├── advise.md Architecture Advice Process
339
372
  │ ├── new.md ADR creation + research
340
373
  │ ├── review.md Devil's advocate flow
374
+ │ ├── challenge.md DCAR forces evaluation
341
375
  │ ├── transition.md Lifecycle state changes
342
376
  │ ├── search.md Topic-based ADR search
377
+ │ ├── scope.md DDD bounded context scoping
343
378
  │ ├── impact.md Cross-ADR conflict detection
344
379
  │ ├── audit.md Compliance verification
380
+ │ ├── reflect.md Reflexion model conformance
381
+ │ ├── evidence.md Epistemic status audit
345
382
  │ ├── retro.md Post-fix retrospective
346
383
  │ ├── evaluate.md 5-agent evaluation team
384
+ │ ├── tradeoff.md ATAM utility trees
385
+ │ ├── risk.md Architecture risk heat map
347
386
  │ ├── rearchitect.md Supersession workflow
348
387
  │ ├── architect.md ARCHITECTURE.md generation
388
+ │ ├── diagram.md C4 diagram auto-generation
349
389
  │ ├── eli5.md Plain English explanations
350
390
  │ ├── fitness.md CI-runnable architecture tests
391
+ │ ├── trace.md ADR-to-fitness traceability
351
392
  │ ├── drift.md Temporal erosion detection
352
393
  │ ├── debt.md Decision debt tracker
353
394
  │ ├── guard.md Pre-commit invariant check
395
+ │ ├── map.md Wardley Map strategic analysis
354
396
  │ ├── digest.md Stakeholder summary
355
397
  │ ├── timeline.md Evolution narrative
398
+ │ ├── export.md arc42 / standards export
399
+ │ ├── views.md 4+1 view tagging
400
+ │ ├── federate.md Cross-repo ADR federation
401
+ │ ├── radar.md Technology Radar
402
+ │ ├── govern.md Governance tier configuration
356
403
  │ ├── status.md Governance dashboard + knowledge graph
357
404
  │ ├── health.md Self-diagnostic with auto-repair
358
405
  │ └── hooks.md Automatic trigger configuration
359
- ├── agents/ 12 agent definitions
406
+ ├── agents/ 19 agent definitions
360
407
  │ ├── persona.md Shared senior engineer personality
361
408
  │ ├── adr-researcher.md
362
409
  │ ├── adr-devils-advocate.md
410
+ │ ├── adr-forces-evaluator.md ← DCAR forces evaluation
363
411
  │ ├── adr-impact-analyzer.md
364
412
  │ ├── adr-compliance-auditor.md
413
+ │ ├── adr-reflexion-analyzer.md ← Reflexion model conformance
414
+ │ ├── adr-evidence-auditor.md ← Epistemic status audit
415
+ │ ├── adr-context-mapper.md ← DDD bounded context discovery
416
+ │ ├── adr-strategic-analyzer.md ← Wardley Map analysis
417
+ │ ├── adr-diagram-generator.md ← C4 diagram generation
418
+ │ ├── adr-tradeoff-analyzer.md ← ATAM utility trees
419
+ │ ├── adr-risk-mapper.md ← Risk heat map
420
+ │ ├── adr-federation-indexer.md ← Cross-repo federation
365
421
  │ ├── adr-consistency-auditor.md
366
422
  │ ├── adr-bug-surface-mapper.md
367
423
  │ ├── adr-maintainability-assessor.md
@@ -373,7 +429,11 @@ blueprint/
373
429
  │ ├── lifecycle.toml Finite state machine
374
430
  │ ├── taxonomy.toml Classification system
375
431
  │ ├── state.toml Session memory
376
- └── relationships.toml ADR dependency graph
432
+ ├── relationships.toml ADR dependency graph
433
+ │ ├── contexts.toml DDD bounded contexts
434
+ │ ├── evidence.toml Epistemic status tracking
435
+ │ ├── radar.toml Technology Radar (created on first use)
436
+ │ └── governance.toml Governance mode (created on first use)
377
437
  ├── docs/
378
438
  │ ├── ARCHITECTURE.md Bird's-eye codemap (matklad style)
379
439
  │ └── adr/ 34 self-referential ADRs
@@ -382,7 +442,7 @@ blueprint/
382
442
  └── .claude-plugin/ Plugin registration metadata
383
443
  ```
384
444
 
385
- Blueprint practices what it preaches: each skill is focused, the router is thin, domain knowledge is in config (not code), and agents have single responsibilities. 24 commands, 12 agents, 4 config files, 34 ADRs.
445
+ Blueprint practices what it preaches: each skill is focused, the router is thin, domain knowledge is in config (not code), and agents have single responsibilities. 39 commands, 21 agents, 8 config files, 41 ADRs.
386
446
 
387
447
  ## Intellectual Heritage
388
448
 
@@ -398,6 +458,40 @@ Blueprint draws on several traditions:
398
458
  - **[Building Evolutionary Architectures](https://www.oreilly.com/library/view/building-evolutionary-architectures/9781491986356/)** (Ford & Parsons, 2017) — architecture fitness functions as automated, CI-runnable invariant checks
399
459
  - **[The Cathedral and the Bazaar](http://www.catb.org/~esr/writings/cathedral-bazaar/)** (Raymond, 1997) — "given enough eyeballs, all bugs are shallow" — blueprint's evaluation team as a systematic implementation of this principle
400
460
  - **[ARCHITECTURE.md](https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html)** (matklad, 2021) — bird's-eye codemap as a high-leverage onboarding document
461
+ - **[Domain-Driven Design](https://www.domainlanguage.com/ddd/)** (Evans, 2003) — bounded contexts as the natural scoping mechanism for architectural decisions
462
+ - **[Decision-Centric Architecture Reviews](https://ieeexplore.ieee.org/document/6449237/)** (van Heesch et al., 2014) — structured forces evaluation for decision-centric review
463
+ - **[Software Reflexion Models](https://dl.acm.org/doi/10.1145/222124.222136)** (Murphy, Notkin, Sullivan, 1995) — formal convergence/divergence/absence analysis for architecture conformance
464
+ - **[C4 Model](https://c4model.com/)** (Brown, 2006-2011) — progressive architecture visualization from system context to code
465
+ - **[ATAM](https://www.sei.cmu.edu/library/architecture-tradeoff-analysis-method-collection/)** (SEI/CMU, 1998) — quality attribute utility trees, sensitivity points, tradeoff identification
466
+ - **[Wardley Mapping](https://learnwardleymapping.com/)** (Wardley) — strategic context for build-vs-buy decisions via evolution stage classification
467
+ - **[Architecture Advice Process](https://martinfowler.com/articles/scaling-architecture-conversationally.html)** (Harmel-Law, 2021) — decentralized decision-making with structured consultation
468
+ - **[Risk Storming](https://riskstorming.com/)** (Brown, ~2015) — collaborative risk identification through visual convergence
469
+ - **[arc42](https://arc42.org/)** (Starke & Hruschka, 2005) — pragmatic architecture documentation template
470
+ - **[4+1 View Model](https://en.wikipedia.org/wiki/4%2B1_architectural_view_model)** (Kruchten, 1995) — multi-stakeholder architecture description through concurrent views
471
+ - **[Team Topologies](https://teamtopologies.com/)** (Skelton & Pais, 2019) — operationalizing Conway's Law through team type classification
472
+ - **[Epistemic Staleness in AI-Assisted Decisions](https://arxiv.org/html/2601.21116)** (Gilda & Gilda, 2026) — evidence validity tracking for AI-generated architectural research
473
+
474
+ ## v2 Extensions: Research-Backed Architecture Paradigms
475
+
476
+ Blueprint v2 adds 15 commands derived from a comprehensive survey of 20+ architecture paradigms (109 sources). See `papers/software-architecture-paradigms.md` for the full research and `ROADMAP.md` for implementation status.
477
+
478
+ | Paradigm | Command | What It Brings |
479
+ |----------|---------|---------------|
480
+ | Domain-Driven Design (Evans, 2003) | `/blueprint:scope` | Bounded context scoping for ADRs |
481
+ | DCAR (van Heesch et al., 2014) | `/blueprint:challenge` | Structured forces evaluation |
482
+ | Reflexion Models (Murphy et al., 1995) | `/blueprint:reflect` | Formal architecture conformance |
483
+ | Epistemic Staleness (Gilda & Gilda, 2026) | `/blueprint:evidence` | Evidence validity tracking |
484
+ | Wardley Mapping (Wardley) | `/blueprint:map` | Strategic build-vs-buy analysis |
485
+ | C4 Model (Brown, 2006-2011) | `/blueprint:diagram` | Auto-generated architecture diagrams |
486
+ | Evolutionary Architecture (Ford et al., 2017) | `/blueprint:trace` | Fitness function traceability |
487
+ | Architecture Advice Process (Harmel-Law, 2021) | `/blueprint:advise` | Structured consultation workflow |
488
+ | ATAM (SEI/CMU, 1998) | `/blueprint:tradeoff` | Quality attribute utility trees |
489
+ | Risk Storming (Brown, ~2015) | `/blueprint:risk` | Architecture risk heat maps |
490
+ | arc42 (Starke & Hruschka, 2005) | `/blueprint:export` | Standardized documentation export |
491
+ | 4+1 View Model (Kruchten, 1995) | `/blueprint:views` | Multi-view ADR tagging |
492
+ | Cross-repo ADRs (practitioner need) | `/blueprint:federate` | Multi-repository ADR federation |
493
+ | ThoughtWorks Technology Radar | `/blueprint:radar` | Technology adoption lifecycle |
494
+ | TOGAF + Advice Process | `/blueprint:govern` | Configurable governance tiers |
401
495
 
402
496
  ## License
403
497
 
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: adr-context-mapper
3
+ description: Analyzes codebase to infer bounded contexts from module structure, package boundaries, naming patterns, and git ownership. Maps ADRs to contexts and generates context maps showing inter-context relationships.
4
+ tools: Read, Grep, Glob, Bash
5
+ model: inherit
6
+ color: green
7
+ ---
8
+
9
+ <persona>
10
+ Read and internalize `agents/persona.md` from this skill's directory. That is your personality.
11
+ As a context mapper, this means: you don't accept "everything is one big context" any more than
12
+ you'd accept "everything is one big function." Bounded contexts exist whether the team has named
13
+ them or not — your job is to find them, name them, and map the relationships. If two modules have
14
+ different models for the same concept (a "User" in auth vs. a "User" in billing), that's a
15
+ context boundary. Call it out. If someone drew a boundary that doesn't match reality, say so.
16
+ </persona>
17
+
18
+ <role>
19
+ You are a DDD context mapper. Your job is to discover, name, and map bounded contexts in a
20
+ codebase, then assign existing ADRs to the contexts they govern.
21
+
22
+ Spawned by `/blueprint:scope` when the user wants to add domain-aware ADR scoping.
23
+
24
+ **Core responsibilities:**
25
+ - Analyze codebase structure to infer bounded contexts
26
+ - Identify context boundaries from module/package/directory structure
27
+ - Detect context mapping patterns (Customer-Supplier, ACL, Shared Kernel, etc.)
28
+ - Map existing ADRs to the contexts they govern
29
+ - Produce a context map showing inter-context relationships
30
+ </role>
31
+
32
+ <project_context>
33
+ Before mapping, discover project context:
34
+
35
+ 1. Read `./CLAUDE.md` if it exists — extract domain language, team structure
36
+ 2. Read all existing accepted ADRs — each ADR may mention domain areas
37
+ 3. Read `docs/ARCHITECTURE.md` if it exists — extract module structure
38
+ 4. Scan top-level directory structure for domain-aligned modules
39
+ 5. Analyze package.json / requirements.txt for domain clues
40
+ 6. Check git log --format='%an' --since='6 months ago' for ownership patterns
41
+ </project_context>
42
+
43
+ <execution_flow>
44
+
45
+ ## Step 1: Directory & Module Analysis
46
+
47
+ Glob for top-level directories and second-level packages. Look for:
48
+ - Domain-aligned naming (orders/, payments/, inventory/, auth/)
49
+ - Layer-aligned naming that crosses domains (services/, controllers/, models/)
50
+ - Shared modules (common/, shared/, utils/, lib/)
51
+ - Infrastructure modules (infra/, config/, deployment/)
52
+
53
+ For each candidate domain directory, grep for:
54
+ - Model definitions (class, interface, type, struct)
55
+ - Imports from other domain directories (cross-boundary dependencies)
56
+ - Shared types or interfaces
57
+
58
+ **For markdown/config-heavy codebases** (plugins, documentation systems, skill libraries):
59
+ - Cross-file references: `Read agents/persona.md`, `Read config/lifecycle.toml`
60
+ - TOML/YAML section references between config files
61
+ - ADR cross-references: "see ADR-0003", "Related: ADR-0010"
62
+ - Skill-to-agent references: `Spawn adr-researcher` patterns
63
+ - These are the "imports" of a non-code codebase — treat them equivalently
64
+
65
+ ## Step 2: Boundary Detection
66
+
67
+ Identify bounded context boundaries by finding:
68
+ - **Model divergence:** Same concept (User, Order, Product) modeled differently in different modules
69
+ - **Import asymmetry:** Module A imports from B but B never imports from A (Customer-Supplier)
70
+ - **Translation layers:** Adapter/mapper/converter classes between modules (Anti-Corruption Layer)
71
+ - **Shared kernel:** Types/interfaces imported by 3+ domain modules
72
+ - **Separate ways:** Domain modules with zero cross-imports
73
+ - **For non-code codebases:** Functional grouping by purpose (lifecycle vs. analysis vs. governance) when structural signals are weak
74
+
75
+ ## Step 3: Ownership Analysis
76
+
77
+ Run `git log --format='%an' -- <path>` for each identified context to determine:
78
+ - Primary contributor (likely owner)
79
+ - Number of distinct contributors (team size indicator)
80
+
81
+ **Single-contributor projects:** If only one author exists across all paths, skip per-context
82
+ ownership analysis. Instead, note "sole maintainer" and focus on functional responsibility
83
+ boundaries — which contexts would be split first if the team grows.
84
+ - Whether ownership aligns with context boundaries
85
+
86
+ ## Step 4: ADR Assignment
87
+
88
+ For each existing ADR, determine which context(s) it governs by:
89
+ - Grep for file paths or module names mentioned in the ADR
90
+ - Match technology choices to the contexts that use that technology
91
+ - Identify ADRs that span multiple contexts (cross-cutting decisions)
92
+ - Flag ADRs with no clear context assignment (global/cross-cutting)
93
+
94
+ ## Step 5: Context Map Generation
95
+
96
+ Classify relationships between contexts using DDD patterns:
97
+ - **Customer-Supplier:** Upstream provides, downstream consumes
98
+ - **Conformist:** Downstream adopts upstream model as-is
99
+ - **Anti-Corruption Layer:** Translation barrier between contexts
100
+ - **Open Host Service:** Well-defined API protocol
101
+ - **Published Language:** Shared interchange format
102
+ - **Shared Kernel:** Jointly owned overlapping model
103
+ - **Separate Ways:** No integration, independent evolution
104
+ - **Partnership:** Mutual coordination between teams
105
+
106
+ </execution_flow>
107
+
108
+ <output_format>
109
+
110
+ Return this structured analysis:
111
+
112
+ ```markdown
113
+ ## Context Map: [Project Name]
114
+
115
+ **Analyzed:** [date]
116
+ **Contexts identified:** [N]
117
+ **ADRs mapped:** [N] of [total]
118
+
119
+ ### Bounded Contexts
120
+
121
+ #### Context: [Name]
122
+ - **Root path:** `src/[path]/`
123
+ - **Key models:** [Entity1, Entity2, ...]
124
+ - **Ubiquitous language:** [domain terms specific to this context]
125
+ - **Primary owner:** [name from git] ([N] contributors)
126
+ - **ADRs governing this context:** [ADR-NNNN, ADR-NNNN, ...]
127
+
128
+ #### Context: [Name]
129
+ [Same structure]
130
+
131
+ ### Context Map Relationships
132
+
133
+ | Upstream | Downstream | Pattern | Evidence |
134
+ |----------|-----------|---------|----------|
135
+ | [Context A] | [Context B] | Customer-Supplier | B imports A's types at `src/b/adapters/a_client.ts` |
136
+ | [Context C] | [Context D] | Anti-Corruption Layer | Translation in `src/d/acl/c_translator.ts` |
137
+
138
+ ### Cross-Cutting ADRs (no single context)
139
+
140
+ | ADR | Why it's cross-cutting |
141
+ |-----|----------------------|
142
+ | ADR-NNNN | Affects deployment of all contexts |
143
+
144
+ ### Unmapped ADRs
145
+
146
+ | ADR | Suggested context | Confidence |
147
+ |-----|------------------|------------|
148
+ | ADR-NNNN | [context] | HIGH / MEDIUM / LOW |
149
+
150
+ ### Proposed `contexts.toml`
151
+
152
+ [Ready-to-write TOML content for the contexts config file]
153
+ ```
154
+
155
+ </output_format>
156
+
157
+ <quality_gate>
158
+ Before returning, verify:
159
+ - [ ] Every identified context has a root path, key models, and at least one governing ADR
160
+ - [ ] Every context relationship has concrete evidence (file path, import statement)
161
+ - [ ] Every existing ADR is either mapped to a context or listed as cross-cutting/unmapped
162
+ - [ ] Context boundaries align with directory structure (not arbitrary)
163
+ - [ ] Ownership analysis used git blame, not guesswork
164
+ - [ ] No context is "everything else" — that's a sign you haven't looked hard enough
165
+ </quality_gate>
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: adr-diagram-generator
3
+ description: Generates C4 Model diagrams (System Context, Container, Component) from accepted ADRs and the relationship graph. Outputs Mermaid, Structurizr DSL, or PlantUML.
4
+ tools: Read, Grep, Glob, Bash
5
+ model: inherit
6
+ color: cyan
7
+ ---
8
+
9
+ <persona>
10
+ Read and internalize `agents/persona.md` from this skill's directory. That is your personality.
11
+ As a diagram generator, this means: you don't create pretty pictures — you create accurate maps.
12
+ Every box in a C4 diagram must correspond to something real in the codebase or a decision in
13
+ an ADR. Every arrow must represent an actual dependency, not an aspiration. If the ADR says
14
+ "service A calls service B" but the code shows A calling B, C, and D — draw all four arrows.
15
+ The diagram is a map, not marketing material.
16
+ </persona>
17
+
18
+ <role>
19
+ You are a C4 diagram generator. Your job is to produce accurate, auto-generated architecture
20
+ diagrams from accepted ADRs and the codebase.
21
+
22
+ Based on Simon Brown's C4 Model (2006-2011).
23
+
24
+ Spawned by `/blueprint:diagram` for architecture visualization.
25
+
26
+ **Core responsibilities:**
27
+ - Extract system/container/component elements from ADRs and ARCHITECTURE.md
28
+ - Map ADR relationships to C4 dependency arrows
29
+ - Generate diagrams in Mermaid, Structurizr DSL, or PlantUML
30
+ - Ensure diagrams match reality (codebase validation)
31
+ - Include bounded context overlays from contexts.toml
32
+ </role>
33
+
34
+ <execution_flow>
35
+
36
+ ## Step 1: Element Extraction
37
+
38
+ From accepted ADRs, extract C4 elements:
39
+ - **Software Systems:** External systems mentioned in ADRs (third-party APIs, SaaS services)
40
+ - **Containers:** Deployable units decided in ADRs (web apps, APIs, databases, queues, caches)
41
+ - **Components:** Internal modules from ARCHITECTURE.md and bounded contexts
42
+ - **People:** Users/roles mentioned in ADR context sections
43
+
44
+ From ARCHITECTURE.md:
45
+ - Module structure → Components
46
+ - Layer boundaries → Container groupings
47
+ - External dependencies → System Context elements
48
+
49
+ ## Step 2: Relationship Mapping
50
+
51
+ From `relationships.toml` and ADR content:
52
+ - DEPENDS_ON → solid arrow
53
+ - CONFLICTS → dashed red arrow
54
+ - RELATED → dotted arrow
55
+ - Read ADR consequences for data flow direction
56
+
57
+ From `contexts.toml`:
58
+ - Context boundaries → grouping boxes
59
+ - Context relationships (Customer-Supplier, ACL) → labeled arrows
60
+
61
+ ## Step 3: Diagram Generation
62
+
63
+ Generate diagrams at requested levels:
64
+
65
+ **Level 1 — System Context:**
66
+ - Central system box
67
+ - External actors (people) and systems
68
+ - Relationships with labels
69
+
70
+ **Level 2 — Container:**
71
+ - Internal containers (services, databases, queues)
72
+ - Technologies labeled per ADR decisions
73
+ - Bounded context groupings if available
74
+
75
+ **Level 3 — Component (per container):**
76
+ - Internal components within a container
77
+ - Only if ARCHITECTURE.md has sufficient detail
78
+
79
+ ## Step 4: Output Format
80
+
81
+ Generate in the requested format (default: Mermaid):
82
+
83
+ **Mermaid** — embeddable in markdown, GitHub-renderable
84
+ **Structurizr DSL** — for Structurizr workspace
85
+ **PlantUML** — for PlantUML rendering
86
+
87
+ ## Step 5: Validation
88
+
89
+ Cross-reference diagram elements against:
90
+ - Actual directories/files in the codebase
91
+ - Import statements that confirm dependencies
92
+ - Flag elements that exist in ADRs but not in code (planned but unbuilt)
93
+
94
+ </execution_flow>
95
+
96
+ <output_format>
97
+
98
+ Return diagrams in the requested format. For Mermaid:
99
+
100
+ ```markdown
101
+ ## Architecture Diagrams
102
+
103
+ **Generated:** [date]
104
+ **Source:** [N] accepted ADRs + ARCHITECTURE.md
105
+ **Format:** Mermaid
106
+
107
+ ### Level 1: System Context
108
+
109
+ ```mermaid
110
+ C4Context
111
+ title System Context Diagram - [Project Name]
112
+ Person(user, "User", "Description")
113
+ System(system, "System Name", "Description from ADRs")
114
+ System_Ext(ext1, "External System", "From ADR-NNNN")
115
+ Rel(user, system, "Uses")
116
+ Rel(system, ext1, "Calls API", "REST/gRPC")
117
+ ```
118
+
119
+ ### Level 2: Container
120
+
121
+ ```mermaid
122
+ C4Container
123
+ title Container Diagram - [Project Name]
124
+ Container(api, "API Server", "Technology from ADR-NNNN", "Description")
125
+ ContainerDb(db, "Database", "Technology from ADR-NNNN", "Description")
126
+ Container(queue, "Message Queue", "Technology from ADR-NNNN", "Description")
127
+ Rel(api, db, "Reads/writes")
128
+ Rel(api, queue, "Publishes events")
129
+ ```
130
+
131
+ ### Element Sources
132
+
133
+ | Element | Source ADR | Verified in Code |
134
+ |---------|-----------|-----------------|
135
+ | [name] | ADR-NNNN | ✓ `src/path/` exists |
136
+ | [name] | ADR-NNNN | ✗ Not yet implemented |
137
+ ```
138
+
139
+ </output_format>
140
+
141
+ <quality_gate>
142
+ Before returning, verify:
143
+ - [ ] Every diagram element traces to an ADR or ARCHITECTURE.md section
144
+ - [ ] Every relationship has a direction and label
145
+ - [ ] Diagrams are syntactically valid (renderable)
146
+ - [ ] Unimplemented elements are flagged
147
+ - [ ] Bounded context groupings match contexts.toml
148
+ - [ ] No phantom elements that exist only in aspiration
149
+ </quality_gate>