dev-playbooks 1.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 (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/bin/devbooks.js +986 -0
  4. package/package.json +41 -0
  5. package/skills/Skill-Development-Guide.md +249 -0
  6. package/skills/Skills-Usage-Guide.md +447 -0
  7. package/skills/_shared/context-detection-template.md +315 -0
  8. package/skills/_shared/mcp-enhancement-template.md +144 -0
  9. package/skills/_shared/references/universal-gating-protocol.md +114 -0
  10. package/skills/_template/config-discovery-template.md +126 -0
  11. package/skills/devbooks-brownfield-bootstrap/SKILL.md +168 -0
  12. package/skills/devbooks-brownfield-bootstrap/references/10-glossary-template.md +42 -0
  13. package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap-prompt.md +115 -0
  14. package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap.md +96 -0
  15. package/skills/devbooks-brownfield-bootstrap/references/code-navigation-strategy.md +203 -0
  16. package/skills/devbooks-brownfield-bootstrap/scripts/cod-update.sh +357 -0
  17. package/skills/devbooks-brownfield-bootstrap/templates/project-profile-template.md +172 -0
  18. package/skills/devbooks-c4-map/SKILL.md +151 -0
  19. package/skills/devbooks-c4-map/references/c4-architecture-map-prompt.md +33 -0
  20. package/skills/devbooks-c4-map/references/layered-constraint-checklist.md +185 -0
  21. package/skills/devbooks-code-review/SKILL.md +175 -0
  22. package/skills/devbooks-code-review/references/code-review-prompt.md +100 -0
  23. package/skills/devbooks-code-review/references/code-smell-cheatsheet.md +498 -0
  24. package/skills/devbooks-code-review/references/pr-template-and-guidelines.md +321 -0
  25. package/skills/devbooks-code-review/references/resource-management-review-checklist.md +311 -0
  26. package/skills/devbooks-coder/SKILL.md +219 -0
  27. package/skills/devbooks-coder/references/code-implementation-prompt.md +74 -0
  28. package/skills/devbooks-coder/references/coding-style-guidelines.md +351 -0
  29. package/skills/devbooks-coder/references/error-code-standard.md +463 -0
  30. package/skills/devbooks-coder/references/logging-standard.md +329 -0
  31. package/skills/devbooks-coder/references/low-risk-modification-techniques.md +275 -0
  32. package/skills/devbooks-delivery-workflow/SKILL.md +217 -0
  33. package/skills/devbooks-delivery-workflow/references/9-change-verification-traceability-template.md +133 -0
  34. package/skills/devbooks-delivery-workflow/references/delivery-acceptance-workflow.md +177 -0
  35. package/skills/devbooks-delivery-workflow/references/prototype-production-dual-track.md +169 -0
  36. package/skills/devbooks-delivery-workflow/scripts/ac-trace-check.sh +330 -0
  37. package/skills/devbooks-delivery-workflow/scripts/audit-scope.sh +262 -0
  38. package/skills/devbooks-delivery-workflow/scripts/change-check.sh +1039 -0
  39. package/skills/devbooks-delivery-workflow/scripts/change-codemod-scaffold.sh +135 -0
  40. package/skills/devbooks-delivery-workflow/scripts/change-evidence.sh +152 -0
  41. package/skills/devbooks-delivery-workflow/scripts/change-scaffold.sh +467 -0
  42. package/skills/devbooks-delivery-workflow/scripts/change-spec-delta-scaffold.sh +135 -0
  43. package/skills/devbooks-delivery-workflow/scripts/constitution-check.sh +237 -0
  44. package/skills/devbooks-delivery-workflow/scripts/env-match-check.sh +128 -0
  45. package/skills/devbooks-delivery-workflow/scripts/fitness-check.sh +365 -0
  46. package/skills/devbooks-delivery-workflow/scripts/guardrail-check.sh +516 -0
  47. package/skills/devbooks-delivery-workflow/scripts/handoff-check.sh +141 -0
  48. package/skills/devbooks-delivery-workflow/scripts/hygiene-check.sh +340 -0
  49. package/skills/devbooks-delivery-workflow/scripts/migrate-from-openspec.sh +385 -0
  50. package/skills/devbooks-delivery-workflow/scripts/migrate-to-v2-gates.sh +202 -0
  51. package/skills/devbooks-delivery-workflow/scripts/progress-dashboard.sh +319 -0
  52. package/skills/devbooks-delivery-workflow/scripts/prototype-promote.sh +341 -0
  53. package/skills/devbooks-delivery-workflow/scripts/spec-preview.sh +203 -0
  54. package/skills/devbooks-delivery-workflow/scripts/spec-promote.sh +118 -0
  55. package/skills/devbooks-delivery-workflow/scripts/spec-rollback.sh +124 -0
  56. package/skills/devbooks-delivery-workflow/scripts/spec-stage.sh +117 -0
  57. package/skills/devbooks-delivery-workflow/scripts/verify-all.sh +78 -0
  58. package/skills/devbooks-delivery-workflow/scripts/verify-npm-package.sh +123 -0
  59. package/skills/devbooks-delivery-workflow/scripts/verify-openspec-free.sh +81 -0
  60. package/skills/devbooks-delivery-workflow/scripts/verify-slash-commands.sh +146 -0
  61. package/skills/devbooks-delivery-workflow/templates/handoff.md +50 -0
  62. package/skills/devbooks-design-backport/SKILL.md +73 -0
  63. package/skills/devbooks-design-backport/references/design-backport-prompt.md +132 -0
  64. package/skills/devbooks-design-doc/SKILL.md +121 -0
  65. package/skills/devbooks-design-doc/references/design-doc-prompt.md +188 -0
  66. package/skills/devbooks-design-doc/references/microservice-design-checklist.md +149 -0
  67. package/skills/devbooks-design-doc/references/privacy-compliance-checklist.md +240 -0
  68. package/skills/devbooks-entropy-monitor/SKILL.md +188 -0
  69. package/skills/devbooks-entropy-monitor/references/entropy-metrics-methodology.md +218 -0
  70. package/skills/devbooks-entropy-monitor/scripts/entropy-measure.sh +449 -0
  71. package/skills/devbooks-entropy-monitor/scripts/entropy-report.sh +303 -0
  72. package/skills/devbooks-entropy-monitor/templates/thresholds.json +99 -0
  73. package/skills/devbooks-federation/SKILL.md +264 -0
  74. package/skills/devbooks-federation/scripts/federation-check.sh +144 -0
  75. package/skills/devbooks-federation/templates/federation.yaml +89 -0
  76. package/skills/devbooks-impact-analysis/SKILL.md +135 -0
  77. package/skills/devbooks-impact-analysis/references/impact-analysis-prompt.md +82 -0
  78. package/skills/devbooks-impact-analysis/scripts/graph-cache.sh +214 -0
  79. package/skills/devbooks-implementation-plan/SKILL.md +83 -0
  80. package/skills/devbooks-implementation-plan/references/implementation-plan-prompt.md +95 -0
  81. package/skills/devbooks-index-bootstrap/SKILL.md +240 -0
  82. package/skills/devbooks-proposal-author/SKILL.md +83 -0
  83. package/skills/devbooks-proposal-author/references/proposal-authoring-prompt.md +66 -0
  84. package/skills/devbooks-proposal-challenger/SKILL.md +86 -0
  85. package/skills/devbooks-proposal-challenger/references/ethics-and-compliance-checklist.md +176 -0
  86. package/skills/devbooks-proposal-challenger/references/proposal-challenge-prompt.md +57 -0
  87. package/skills/devbooks-proposal-debate-workflow/SKILL.md +78 -0
  88. package/skills/devbooks-proposal-debate-workflow/references/11-proposal-debate-template.md +35 -0
  89. package/skills/devbooks-proposal-debate-workflow/references/proposal-debate-workflow.md +24 -0
  90. package/skills/devbooks-proposal-debate-workflow/scripts/proposal-debate-check.sh +102 -0
  91. package/skills/devbooks-proposal-judge/SKILL.md +78 -0
  92. package/skills/devbooks-proposal-judge/references/proposal-judge-prompt.md +37 -0
  93. package/skills/devbooks-router/SKILL.md +346 -0
  94. package/skills/devbooks-spec-contract/SKILL.md +191 -0
  95. package/skills/devbooks-spec-contract/references/api-design-guide.md +349 -0
  96. package/skills/devbooks-spec-contract/references/contract-and-data-definition-prompt.md +85 -0
  97. package/skills/devbooks-spec-contract/references/implicit-change-detection-prompt.md +183 -0
  98. package/skills/devbooks-spec-contract/references/spec-change-prompt.md +63 -0
  99. package/skills/devbooks-spec-contract/scripts/implicit-change-detect.sh +378 -0
  100. package/skills/devbooks-spec-gardener/SKILL.md +73 -0
  101. package/skills/devbooks-spec-gardener/references/spec-gardener-prompt.md +41 -0
  102. package/skills/devbooks-test-owner/SKILL.md +173 -0
  103. package/skills/devbooks-test-owner/references/9-change-verification-traceability-template.md +133 -0
  104. package/skills/devbooks-test-owner/references/async-system-test-strategy.md +316 -0
  105. package/skills/devbooks-test-owner/references/decoupling-techniques-cheatsheet.md +269 -0
  106. package/skills/devbooks-test-owner/references/test-code-prompt.md +171 -0
  107. package/skills/devbooks-test-owner/references/test-driven-development.md +351 -0
  108. package/skills/devbooks-test-owner/references/test-layering-strategy.md +281 -0
  109. package/skills/devbooks-test-reviewer/SKILL.md +189 -0
  110. package/templates/.devbooks/config.yaml +88 -0
  111. package/templates/claude-commands/devbooks/apply.md +38 -0
  112. package/templates/claude-commands/devbooks/archive.md +33 -0
  113. package/templates/claude-commands/devbooks/backport.md +19 -0
  114. package/templates/claude-commands/devbooks/bootstrap.md +20 -0
  115. package/templates/claude-commands/devbooks/c4.md +20 -0
  116. package/templates/claude-commands/devbooks/challenger.md +19 -0
  117. package/templates/claude-commands/devbooks/code.md +20 -0
  118. package/templates/claude-commands/devbooks/debate.md +20 -0
  119. package/templates/claude-commands/devbooks/delivery.md +20 -0
  120. package/templates/claude-commands/devbooks/design.md +20 -0
  121. package/templates/claude-commands/devbooks/entropy.md +19 -0
  122. package/templates/claude-commands/devbooks/federation.md +19 -0
  123. package/templates/claude-commands/devbooks/gardener.md +19 -0
  124. package/templates/claude-commands/devbooks/impact.md +19 -0
  125. package/templates/claude-commands/devbooks/index.md +19 -0
  126. package/templates/claude-commands/devbooks/judge.md +19 -0
  127. package/templates/claude-commands/devbooks/plan.md +20 -0
  128. package/templates/claude-commands/devbooks/proposal.md +20 -0
  129. package/templates/claude-commands/devbooks/quick.md +43 -0
  130. package/templates/claude-commands/devbooks/review.md +20 -0
  131. package/templates/claude-commands/devbooks/router.md +19 -0
  132. package/templates/claude-commands/devbooks/spec.md +20 -0
  133. package/templates/claude-commands/devbooks/test-review.md +19 -0
  134. package/templates/claude-commands/devbooks/test.md +20 -0
  135. package/templates/dev-playbooks/changes/.gitkeep +1 -0
  136. package/templates/dev-playbooks/constitution.md +116 -0
  137. package/templates/dev-playbooks/project.md +96 -0
  138. package/templates/dev-playbooks/scripts/.gitkeep +1 -0
  139. package/templates/dev-playbooks/specs/_meta/anti-patterns/.gitkeep +2 -0
  140. package/templates/dev-playbooks/specs/_meta/glossary.md +48 -0
  141. package/templates/dev-playbooks/specs/_meta/project-profile.md +79 -0
  142. package/templates/dev-playbooks/specs/architecture/fitness-rules.md +95 -0
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: devbooks-design-doc
3
+ description: devbooks-design-doc: Produce design documents (design.md) for change packages, focusing only on What/Constraints and AC-xxx, without implementation steps. Use when user says "write design doc/Design Doc/architecture design/constraints/acceptance criteria/AC/C4 Delta" etc.
4
+ tools:
5
+ - Glob
6
+ - Grep
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ ---
11
+
12
+ # DevBooks: Design Document (Design Doc)
13
+
14
+ ## Prerequisites: Configuration Discovery (Protocol Agnostic)
15
+
16
+ - `<truth-root>`: Current truth directory root
17
+ - `<change-root>`: Change package directory root
18
+
19
+ Before execution, **must** search for configuration in the following order (stop when found):
20
+ 1. `.devbooks/config.yaml` (if exists) → Parse and use its mappings
21
+ 2. `dev-playbooks/project.md` (if exists) → DevBooks 2.0 protocol, use default mappings
22
+ 4. `project.md` (if exists) → Template protocol, use default mappings
23
+ 5. If still unable to determine → **Stop and ask user**
24
+
25
+ **Key Constraints**:
26
+ - If configuration specifies `agents_doc` (rules document), **must read that document first** before executing any operations
27
+ - Do not guess directory roots
28
+ - Do not skip reading rules document
29
+
30
+ ## Artifact Location
31
+
32
+ - Design document: `<change-root>/<change-id>/design.md`
33
+
34
+ ## Documentation Impact Statement (Required)
35
+
36
+ Design documents **must** include a "Documentation Impact" section declaring the impact of this change on user documentation. This is a key mechanism to ensure documentation stays in sync with code.
37
+
38
+ ### Template
39
+
40
+ ```markdown
41
+ ## Documentation Impact
42
+
43
+ ### Documents Requiring Updates
44
+
45
+ | Document | Update Reason | Priority |
46
+ |----------|---------------|----------|
47
+ | README.md | New feature X requires usage instructions | P0 |
48
+ | docs/user-guide.md | New script Y requires usage documentation | P0 |
49
+ | CHANGELOG.md | Record this change | P1 |
50
+
51
+ ### Documents Not Requiring Updates
52
+
53
+ - [ ] This change is internal refactoring, does not affect user-visible functionality
54
+ - [ ] This change only fixes bugs, does not introduce new features or change usage patterns
55
+
56
+ ### Documentation Update Checklist
57
+
58
+ - [ ] New scripts/commands are documented in usage documentation
59
+ - [ ] New configuration options are documented in configuration documentation
60
+ - [ ] New workflows/processes are documented in guides
61
+ - [ ] API/interface changes are updated in relevant documentation
62
+ ```
63
+
64
+ ### Trigger Rules
65
+
66
+ The following change types **require** updating corresponding documentation:
67
+
68
+ | Change Type | Documents to Update |
69
+ |-------------|---------------------|
70
+ | New script (*.sh) | User guide, README |
71
+ | New Skill | README, Skills list |
72
+ | Workflow changes | Related guide documentation |
73
+ | New configuration options | Configuration documentation |
74
+ | New commands/CLI parameters | User guide |
75
+ | External API changes | API documentation |
76
+
77
+ ## Execution Method
78
+
79
+ 1) First read and follow: `_shared/references/universal-gating-protocol.md` (verifiability + structural quality gates).
80
+ 2) Strictly follow complete prompt output: `references/design-doc-prompt.md`.
81
+
82
+ ---
83
+
84
+ ## Context Awareness
85
+
86
+ This Skill automatically detects context before execution and selects the appropriate running mode.
87
+
88
+ Detection rules reference: `skills/_shared/context-detection-template.md`
89
+
90
+ ### Detection Process
91
+
92
+ 1. Detect if `proposal.md` exists (input for design document)
93
+ 2. Detect if `design.md` already exists
94
+ 3. If exists, check completeness (whether it has AC-xxx, whether it has `[TODO]`)
95
+
96
+ ### Modes Supported by This Skill
97
+
98
+ | Mode | Trigger Condition | Behavior |
99
+ |------|-------------------|----------|
100
+ | **Create Design** | `design.md` does not exist | Create complete design document |
101
+ | **Supplement Design** | `design.md` exists but has `[TODO]` | Fill in missing sections |
102
+ | **Add AC** | Design exists but AC is incomplete | Add acceptance criteria |
103
+
104
+ ### Detection Output Example
105
+
106
+ ```
107
+ Detection Results:
108
+ - proposal.md: Exists
109
+ - design.md: Exists, has 5 [TODO]s
110
+ - AC count: 8
111
+ - Running mode: Supplement Design
112
+ ```
113
+
114
+ ---
115
+
116
+ ## MCP Enhancement
117
+
118
+ This Skill does not depend on MCP services, no runtime detection required.
119
+
120
+ MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
121
+
@@ -0,0 +1,188 @@
1
+ # Design Doc Prompt
2
+
3
+ > **Role**: You are the strongest “software architecture brain” — combining Eric Evans (DDD), Martin Fowler (enterprise patterns), and Gregor Hohpe (integration patterns). Your design must meet that expert level.
4
+
5
+ Highest-priority instruction:
6
+ - Before executing this prompt, read `_shared/references/universal-gating-protocol.md` and follow all protocols in it.
7
+
8
+ You are the **Design Owner**. Your goal is to produce an acceptable, traceable, evolvable **Design Doc** that serves as the golden truth for downstream implementation planning and acceptance testing.
9
+
10
+ Artifact location (directory convention, protocol-agnostic):
11
+ - This design doc is typically part of a single change package and is recommended at: `<change-root>/<change-id>/design.md`
12
+ - The “Current Truth” lives in `<truth-root>/`; this design doc describes what the change should achieve (and is merged into the truth root when archived)
13
+ - Requirements/Scenarios are not expanded here; use the “spec change prompt” to produce a spec delta (avoid mixing What with Requirements)
14
+
15
+ Inputs (provided by me):
16
+ - Business/problem background
17
+ - Current state and constraints (if any)
18
+ - Chat history
19
+ - Glossary / ubiquitous language (if present): `<truth-root>/_meta/glossary.md`
20
+
21
+ Tasks:
22
+ 1) Output a design doc (not an implementation plan, not code).
23
+ 2) The doc must be concrete enough to drive acceptance and task decomposition: clear boundaries, contracts, red lines, and acceptance.
24
+ 3) To avoid same-source fallacy: define only What/Constraints; do not write How/implementation steps.
25
+
26
+ Output format (recommended to follow strictly):
27
+
28
+ > **Lost-in-the-middle optimization**: put key information at the start and end; recall for the beginning/end (~90%) is far higher than the middle (~50–60%).
29
+
30
+ ### Part 1: Key Info Up Front (High Attention Zone)
31
+
32
+ 1) Title + metadata (version/status/last updated/scope/owner/last_verified/freshness_check)
33
+
34
+ 2) **⚡ Acceptance Criteria (front-load!)**:
35
+ - Number each as `AC-xxx`
36
+ - Each must be observable and testable with explicit Pass/Fail criteria
37
+ - Must specify validation method: A (machine judge) / B (tool evidence + human sign-off) / C (manual)
38
+ - **This is the most important part and must come first**
39
+
40
+ 3) **⚡ Goals / Non-goals + Red Lines (front-load core constraints!)**:
41
+ - Goals: what the change must accomplish
42
+ - Non-goals: what is explicitly out of scope
43
+ - Red Lines: non-negotiable constraints (e.g., must not break backward compatibility)
44
+
45
+ 4) Executive summary (2–3 sentences: goal + core tension)
46
+
47
+ ### Part 2: Background and Design Details (Lower Attention Zone)
48
+
49
+ 5) **Problem Context**:
50
+ - Why solve this? (business driver / tech debt / user pain)
51
+ - Where does the current system create friction or bottlenecks?
52
+ - What happens if we do nothing?
53
+
54
+ 6) Value-chain mapping (Goal → blockers/levers → minimal solution; ask clarifying questions if goals are unclear)
55
+
56
+ 7) Current-state assessment (existing assets / key risks)
57
+
58
+ 8) Design principles (including variation-point identification)
59
+ - **Variation points are mandatory**: what is most likely to change, and how will it be encapsulated?
60
+
61
+ 9) Target architecture (bounded contexts, dependency direction, key extension points)
62
+ - **Testability & Seams** (optional but recommended):
63
+ - **Seams**: list intentional test entry points
64
+ - Dependency injection points (e.g., constructor args, factory methods)
65
+ - Replaceable components (e.g., external adapters implementing interfaces)
66
+ - Observation points (e.g., event publishing, log hooks)
67
+ - **Pinch points**: high-value test locations
68
+ - Which modules/classes aggregate multiple call paths?
69
+ - What downstream paths can tests at those points cover?
70
+ - **Dependency isolation strategy**:
71
+ - How are external dependencies (DB/API/third-party) isolated?
72
+ - Do we need an Anti-Corruption Layer (ACL)?
73
+ - **Example format**:
74
+ ```
75
+ Seams:
76
+ - OrderService constructor accepts PaymentGatewayInterface (injectable mock)
77
+ - EventBus.publish() can be observed by test subscribers
78
+
79
+ Pinch Points:
80
+ - OrderService.processOrder() - aggregates 3 paths
81
+ - PaymentGateway.execute() - aggregates 2 paths
82
+
83
+ Dependency isolation:
84
+ - PaymentGateway → isolated via interface; tests use MockGateway
85
+ - InventoryDB → isolated via Repository interface
86
+ ```
87
+
88
+ 10) **Domain Model**:
89
+ - **Data Model**: list core data objects and tag their type:
90
+ - `@Entity`: has identity, mutable state, lifecycle tracked (e.g., Order, Customer)
91
+ - `@ValueObject`: no identity, immutable, descriptive (e.g., Address, Money, DateRange)
92
+ - **Business Rules**: list business rules separately (do not bury in ACs or code comments)
93
+ - Each rule has a unique ID (e.g., BR-001)
94
+ - Specify trigger conditions, constraints, and behavior on violation
95
+ - **Invariants**: explicitly list invariants (avoid scattering implicitly in code)
96
+ - Tag them with `[Invariant]` (for downstream acceptance tests and guardrails)
97
+ - **Context boundaries / integration boundaries**: if external systems/APIs are involved, define an ACL (Anti-Corruption Layer)
98
+ - Describe transformation points between external and internal models
99
+ - Note which external changes are isolated by the ACL
100
+
101
+ 11) Core data and event contracts (artifacts, event envelope, `schema_version`, `idempotency_key`, compatibility strategy)
102
+
103
+ 12) Key mechanisms (quality gates, budgeting, isolation, replay, auditing, etc.)
104
+
105
+ 13) Observability and acceptance (Metrics/KPI/SLO)
106
+
107
+ 14) Security, compliance, and multi-tenant isolation
108
+
109
+ 15) Milestones (phased delivery at the design level)
110
+
111
+ 16) Deprecation plan (if replacing/deprecating, specify marking/warnings/removal window)
112
+
113
+ 17) **Design rationale** (optional; recommended for large refactors/architecture changes):
114
+ - Why this approach vs alternatives?
115
+ - Key alternatives and why they were rejected
116
+ - Key technical decisions and justification (e.g., Redis vs PostgreSQL LISTEN/NOTIFY)
117
+
118
+ 18) **Trade-offs**:
119
+ - What does this design give up? (e.g., strong consistency for high availability)
120
+ - What known imperfections are accepted?
121
+ - In which scenarios might this design be unsuitable?
122
+
123
+ 19) **Technical debt** (optional):
124
+ - **Known debt** introduced or left unresolved
125
+ - Each item has a unique ID (e.g., TD-001)
126
+ - Specify type (architecture/code/test/docs)
127
+ - Cause (time pressure/technical limits/expediency)
128
+ - Impact and severity (High/Medium/Low)
129
+ - **Paydown plan**: when and how to repay
130
+ - Short-term acceptable threshold
131
+ - Trigger conditions (e.g., user count > X, performance < Y)
132
+ - **Example format**:
133
+ ```
134
+ Technical Debt:
135
+ - TD-001 [Code] Order service hard-codes payment timeout to 30s
136
+ - Cause: phase-1 rapid validation; config not extracted
137
+ - Impact: Medium - requires code changes to adjust timeout
138
+ - Paydown: move to config before Phase 2
139
+ - TD-002 [Test] Payment callback lacks integration tests
140
+ - Cause: mocking third-party payment gateway is complex
141
+ - Impact: High - callback changes are risky
142
+ - Paydown: add tests after sandbox environment is available
143
+ ```
144
+
145
+ 20) Risks and degradation strategy (failure modes + degrade paths)
146
+
147
+ ### Part 3: Strong Ending (High Attention Zone)
148
+
149
+ 21) **⚡ Definition of Done (strong ending!)**:
150
+ - When is the design considered “done”?
151
+ - Required gates to pass (tests / lint / build / review)
152
+ - Required evidence artifacts (what must exist under `evidence/`)
153
+ - Cross-reference to the ACs at the top
154
+
155
+ 22) Open questions (≤ 3)
156
+
157
+ Acceptance Criteria writing rules:
158
+ - Each starts with `AC-xxx`
159
+ - Each is observable/testable with explicit Pass/Fail criteria
160
+ - **Non-functional requirements (NFR) must be concrete**:
161
+ - **No vague adjectives** (e.g., “high performance”, “high availability”, “user-friendly”, “fast”).
162
+ - **Convert into measurable thresholds** (ranges allowed, e.g., `p99 < 200ms`) or **a clear reference anchor** (e.g., “error component reuses auth module’s UI/UX behavior”).
163
+ - **Percentiles**:
164
+ - `p50` (median): 50% requests finish within this time; “typical user” experience
165
+ - `p95`: 95% requests finish within this time; “most users”
166
+ - `p99`: 99% requests finish within this time; “almost all users” and exposes tail latency
167
+ - `p999`: 99.9% requests finish within this time; for high-SLA scenarios
168
+ - **Why percentiles vs averages**: averages are skewed by outliers and can hide real user experience (e.g., avg 100ms could mean 99% at 50ms and 1% at 5000ms).
169
+ - **Selection guidance**:
170
+ - UX metrics: use p95 or p99
171
+ - SLA/contract constraints: use p99 or p999
172
+ - Internal monitoring/alerting: monitor p50, p95, and p99 together
173
+ - Must specify validation method:
174
+ - A: machine judge (tests/static checks/build/smoke)
175
+ - B: tool evidence + human sign-off (dashboards/reports/log evidence)
176
+ - C: manual acceptance (UX/product walkthrough)
177
+ - If it cannot be automated: state why and specify what evidence must be retained
178
+
179
+ Limits:
180
+ - Do not output implementation steps, PR slicing advice, or concrete production code file paths and function bodies.
181
+ - Do not output runnable pseudocode; if you must describe an algorithm, write only Inputs/Outputs/Invariants/complexity bound/degradation strategy.
182
+
183
+ Additional requirements (for traceability in large projects):
184
+ - Explicitly list affected capabilities/modules/external contracts (names and boundaries only; no implementation)
185
+ - If external interfaces/APIs/events/data structures are involved: specify versioning strategy in the “Core data and event contracts” section (`schema_version`, compatibility window, migration/replay principles)
186
+ - If architecture boundaries change: add an optional **C4 Delta** subsection under “Target architecture” describing what C1/C2/C3 elements were added/modified/removed (full maps are maintained by the C4 map maintainer)
187
+
188
+ Now output the Design Doc in Markdown. Do not output extra explanations.
@@ -0,0 +1,149 @@
1
+ # Microservice Design Checklist
2
+
3
+ > Use this checklist when the design involves microservices or distributed architecture.
4
+ >
5
+ > This document is **optional guidance**; use it only when the project truly involves microservices/distributed systems.
6
+
7
+ ---
8
+
9
+ ## 1) RPC Location Transparency Trap (must check)
10
+
11
+ **Core principle**: a remote call is not a local function call—do not hide the complexity.
12
+
13
+ ### 1.1 The design doc must declare
14
+
15
+ - [ ] **Timeout policy**: timeout per RPC call (recommended 1–5 seconds)
16
+ - [ ] **Retry policy**: max retries, backoff interval, exponential backoff
17
+ - [ ] **Degradation strategy**: behavior when a dependency is unavailable (defaults/cache/error codes)
18
+ - [ ] **Circuit breaker threshold**: failure rate that triggers breaking (recommended 50%)
19
+
20
+ ### 1.2 Anti-pattern checks
21
+
22
+ | Anti-pattern | Problem | Correct approach |
23
+ |--------|------|----------|
24
+ | RPC without timeouts | One slow service drags down the whole chain | set explicit timeouts (1–5s) |
25
+ | Infinite retries | retry storms overwhelm downstream | max 3 retries with exponential backoff |
26
+ | Synchronous call chaining | A→B→C→D accumulates latency | async or parallelize |
27
+ | Hidden remote calls | caller doesn’t know it’s network IO | make fallibility explicit in API names/types |
28
+
29
+ ### 1.3 Test Owner checklist
30
+
31
+ - [ ] Tests cover dependency timeouts (mock timeouts)
32
+ - [ ] Tests cover dependency error responses
33
+ - [ ] Tests cover degraded behavior after circuit breaking
34
+ - [ ] Tests cover retry logic (verify max retries)
35
+
36
+ ---
37
+
38
+ ## 2) Distributed Failure Impact Assessment
39
+
40
+ ### 2.1 Failure mode list
41
+
42
+ | Failure type | Blast radius | Detection | Recovery strategy |
43
+ |----------|----------|----------|----------|
44
+ | Network partition | service A can’t reach service B | health-check timeouts | circuit breaker + degrade |
45
+ | Node crash | single-node outage | heartbeat failures | load-balancer failover |
46
+ | Slow responses | end-to-end latency increases | p99 latency alerts | rate-limit + queue |
47
+ | Data inconsistency | replicas out of sync | reconciliation jobs | retry + compensation |
48
+
49
+ ### 2.2 The design doc must declare
50
+
51
+ - [ ] Which inter-service dependencies are involved?
52
+ - [ ] What is the blast radius for each dependency failure?
53
+ - [ ] What user-visible behavior occurs under failure?
54
+ - [ ] Do we need chaos testing / failure drills?
55
+
56
+ ---
57
+
58
+ ## 3) Distributed Tracing
59
+
60
+ ### 3.1 Design requirements
61
+
62
+ - [ ] All RPC calls propagate `trace_id`
63
+ - [ ] Logs include `trace_id`
64
+ - [ ] Events/messages include `trace_id`
65
+
66
+ ### 3.2 Implementation checks
67
+
68
+ ```
69
+ Headers: `X-Trace-Id` / `X-Request-Id`
70
+ Log format: `{"trace_id": "xxx", "message": "...", "timestamp": "..." }`
71
+ Message fields: `{"trace_id": "xxx", "event_type": "...", "payload": {...} }`
72
+ ```
73
+
74
+ ### 3.3 Test Owner checklist
75
+
76
+ - [ ] Tests verify trace_id is propagated across services
77
+ - [ ] Tests verify logs include trace_id
78
+ - [ ] Tests verify error logs can be traced back to the originating request via trace_id
79
+
80
+ ---
81
+
82
+ ## 4) Inter-service Contract Management
83
+
84
+ ### 4.1 Contract definition requirements
85
+
86
+ - [ ] Use OpenAPI/Proto/AsyncAPI to define contracts
87
+ - [ ] Contract files are version-controlled
88
+ - [ ] Contract changes go through compatibility checks
89
+
90
+ ### 4.2 Contract testing requirements
91
+
92
+ - [ ] Provider-side contract tests (implementation matches contract)
93
+ - [ ] Consumer-side contract tests (consumer assumptions are correct)
94
+ - [ ] Both sides run tests on contract changes
95
+
96
+ ### 4.3 Breaking change handling
97
+
98
+ - [ ] Do not delete published APIs directly
99
+ - [ ] Run old and new versions in parallel for at least 2 release cycles
100
+ - [ ] Provide a migration guide and deprecation timeline
101
+
102
+ ---
103
+
104
+ ## 5) Exactly-once and Idempotency
105
+
106
+ ### 5.1 Choosing delivery semantics
107
+
108
+ | Semantics | Use case | Implementation complexity |
109
+ |------|----------|------------|
110
+ | at-most-once | logs/telemetry (loss allowed) | Low |
111
+ | at-least-once | notifications/analytics (duplicates allowed) | Medium |
112
+ | exactly-once | payments/orders (no loss or duplicates) | High |
113
+
114
+ ### 5.2 Exactly-once implementation checklist
115
+
116
+ - [ ] Messages include a unique `message_id`
117
+ - [ ] Consumers persist processed `message_id` (DB/Redis)
118
+ - [ ] Duplicate messages return success (idempotent handling)
119
+ - [ ] Tests cover: consume the same message 3 times, execute side effects only once
120
+
121
+ ### 5.3 Test Owner checklist
122
+
123
+ - [ ] Tests verify duplicates do not cause duplicate side effects
124
+ - [ ] Tests verify retry succeeds after message loss
125
+ - [ ] Tests verify partial failure compensation works correctly
126
+
127
+ ---
128
+
129
+ ## 6) Design Doc Template Additions
130
+
131
+ In the “Target Architecture” section of `design.md`, add:
132
+
133
+ ```markdown
134
+ ### Microservice Design Constraints (if applicable)
135
+
136
+ #### Service dependency sketch
137
+ - This service → Dependency Service A (timeout 3s, retries 2, degrade to empty list)
138
+ - This service → Dependency Service B (timeout 5s, retries 0, degrade to cached value)
139
+
140
+ #### Failure modes and degradation
141
+ | Failure scenario | User-visible behavior | Recovery strategy |
142
+ |----------|--------------|----------|
143
+ | Service A unavailable | show “no data” | circuit-break 60s then retry |
144
+ | Service B slow | use cached data | rate-limit when p99 > 1s |
145
+
146
+ #### Tracing requirements
147
+ - All APIs propagate `X-Trace-Id`
148
+ - Logs are JSON and include `trace_id`
149
+ ```
@@ -0,0 +1,240 @@
1
+ # Telemetry Privacy & Compliance Checklist
2
+
3
+ Inspired by VS Code’s `telemetry.instructions.md`, this document defines privacy/compliance requirements for telemetry data.
4
+
5
+ ---
6
+
7
+ ## 1) GDPR classification requirements
8
+
9
+ When `design.md` or a spec delta includes telemetry, you **must** fill in the following fields:
10
+
11
+ ```markdown
12
+ ## Telemetry Design
13
+
14
+ ### GDPR Classification
15
+
16
+ | Field | Value | Notes |
17
+ |------|-----|------|
18
+ | **owner** | @username | data owner (must be a team member) |
19
+ | **isMeasurement** | true/false | whether it’s measurement data (non-PII) |
20
+ | **purpose** | PerformanceAndHealth / BusinessInsight / FeatureInsight | collection purpose |
21
+ | **classification** | SystemMetaData / CallstackOrException / EndUserPseudonymizedInformation | data category |
22
+ | **retention** | 90d / 1y / permanent | retention period |
23
+ | **gdprRequired** | true/false | whether user consent is required |
24
+
25
+ ### Telemetry event definitions
26
+
27
+ | Event name | Trigger | Data fields | Classification |
28
+ |--------|----------|----------|------|
29
+ | feature.used | when the user uses feature X | `{ featureId, duration }` | SystemMetaData |
30
+ | error.occurred | when an error occurs | `{ errorCode, stack }` | CallstackOrException |
31
+ ```
32
+
33
+ ---
34
+
35
+ ## 2) Data classification guidance
36
+
37
+ ### SystemMetaData
38
+
39
+ **Definition**: system information that does not identify the user.
40
+
41
+ **Allowed**:
42
+ - OS version
43
+ - App version
44
+ - Feature flag states
45
+ - Performance metrics (latency, memory)
46
+ - Anonymous usage frequency
47
+
48
+ **Example**:
49
+ ```typescript
50
+ // Compliant: system metadata
51
+ telemetry.log('app.startup', {
52
+ version: '1.0.0',
53
+ os: 'darwin',
54
+ memoryUsage: process.memoryUsage().heapUsed,
55
+ });
56
+ ```
57
+
58
+ ### CallstackOrException
59
+
60
+ **Definition**: error information and callstacks.
61
+
62
+ **Allowed**:
63
+ - Error codes
64
+ - Error messages (must be sanitized)
65
+ - Callstacks (must sanitize file paths)
66
+
67
+ **Sanitization requirements**:
68
+ - Remove usernames: `/Users/john/` → `/Users/<username>/`
69
+ - Remove project paths: `/project/secret/` → `<project>/`
70
+ - Remove sensitive filenames: `credentials.json` → `<sensitive>`
71
+
72
+ **Example**:
73
+ ```typescript
74
+ // Compliant: sanitized exception
75
+ telemetry.logError('app.error', {
76
+ errorCode: 'E001',
77
+ message: sanitizeMessage(error.message),
78
+ stack: sanitizeStack(error.stack),
79
+ });
80
+ ```
81
+
82
+ ### EndUserPseudonymizedInformation
83
+
84
+ **Definition**: user information that has been pseudonymized.
85
+
86
+ **Requirements**:
87
+ - Must use one-way hashing
88
+ - Must not be reversible
89
+ - Requires user consent
90
+
91
+ **Example**:
92
+ ```typescript
93
+ // Compliant: pseudonymized user ID
94
+ telemetry.log('user.action', {
95
+ hashedUserId: sha256(userId + salt), // one-way hash
96
+ action: 'click',
97
+ });
98
+ ```
99
+
100
+ ### PublicNonPersonalData
101
+
102
+ **Definition**: fully public data that does not include personal information.
103
+
104
+ **Allowed**:
105
+ - Public configuration options
106
+ - Public API versions
107
+ - Public feature lists
108
+
109
+ ---
110
+
111
+ ## 3) Data you must not collect
112
+
113
+ | Type | Examples | Reason |
114
+ |------|------|------|
115
+ | Plain PII | name, email, phone | directly identifies users |
116
+ | Location info | GPS, IP address | indirectly identifies users |
117
+ | File contents | user docs, source code | sensitive data |
118
+ | Passwords/tokens | API keys, passwords | security risk |
119
+ | Health info | medical data | sensitive data |
120
+ | Financial info | credit card numbers | sensitive data |
121
+
122
+ **Detection rules**:
123
+ ```bash
124
+ # Detect possible PII collection
125
+ rg "email|phone|name|address|ip" --type ts -g "*telemetry*"
126
+ rg "password|token|secret|key" --type ts -g "*telemetry*"
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 4) Event naming conventions
132
+
133
+ ### Standard events (publicLog2)
134
+
135
+ Used for normal feature usage and performance measurement:
136
+
137
+ ```typescript
138
+ // Naming format: <domain>.<action>
139
+ publicLog2<{ duration: number }>('editor.opened', { duration: 123 });
140
+ publicLog2<{ count: number }>('search.performed', { count: 10 });
141
+ ```
142
+
143
+ ### Exception events (publicLogError2)
144
+
145
+ Used for errors and exceptional conditions:
146
+
147
+ ```typescript
148
+ // Naming format: <domain>.error or <domain>.failed
149
+ publicLogError2<{ code: string }>('editor.error', { code: 'E001' });
150
+ publicLogError2<{ reason: string }>('save.failed', { reason: 'disk_full' });
151
+ ```
152
+
153
+ ---
154
+
155
+ ## 5) Code review checklist
156
+
157
+ When reviewing telemetry-related code:
158
+
159
+ ### Must check
160
+
161
+ - [ ] **Is GDPR classification complete?**
162
+ - Is `owner` specified?
163
+ - Is `classification` correct?
164
+ - Is `purpose` clear?
165
+
166
+ - [ ] **Is data sanitized?**
167
+ - Are usernames removed from file paths?
168
+ - Are error messages filtered for sensitive data?
169
+ - Is there any plain PII?
170
+
171
+ - [ ] **Is naming compliant?**
172
+ - Do event names follow `<domain>.<action>`?
173
+ - Do error events use `publicLogError2`?
174
+
175
+ - [ ] **Is user consent handled?**
176
+ - For consent-required data, is `telemetryLevel` checked?
177
+ - Are user privacy settings respected?
178
+
179
+ ### Automated checks
180
+
181
+ ```bash
182
+ # Check for telemetry without classification
183
+ rg "publicLog2|telemetry\.log" --type ts | xargs -I {} grep -L "classification" {}
184
+
185
+ # Check for sensitive data collection
186
+ rg "(email|phone|password|token)" --type ts -g "*telemetry*"
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 6) design.md template snippet
192
+
193
+ When `design.md` includes telemetry, add:
194
+
195
+ ```markdown
196
+ ## Telemetry Impact
197
+
198
+ ### New telemetry events
199
+
200
+ | Event | owner | classification | purpose | isMeasurement |
201
+ |------|-------|----------------|---------|---------------|
202
+ | feature.x.used | @alice | SystemMetaData | FeatureInsight | true |
203
+ | feature.x.error | @alice | CallstackOrException | PerformanceAndHealth | false |
204
+
205
+ ### Data field definitions
206
+
207
+ ```typescript
208
+ interface FeatureXUsedEvent {
209
+ duration: number; // duration (ms)
210
+ success: boolean; // success
211
+ // Do not add: userId, filePath, etc.
212
+ }
213
+ ```
214
+
215
+ ### Privacy impact assessment
216
+
217
+ - [ ] No PII collected
218
+ - [ ] Sensitive paths are sanitized
219
+ - [ ] telemetryLevel settings checked
220
+ - [ ] Privacy Review completed (if required)
221
+ ```
222
+
223
+ ---
224
+
225
+ ## 7) Compliance approval workflow
226
+
227
+ | Data category | Approval requirement |
228
+ |----------|----------|
229
+ | SystemMetaData | no approval required |
230
+ | CallstackOrException | no approval required (must sanitize) |
231
+ | EndUserPseudonymizedInformation | requires Privacy Review |
232
+ | Any new PII | requires Legal Review |
233
+
234
+ ---
235
+
236
+ ## References
237
+
238
+ - [GDPR data classification guide](https://gdpr.eu/data-protection/)
239
+ - [VS Code telemetry documentation](https://code.visualstudio.com/docs/getstarted/telemetry)
240
+ - [Microsoft Privacy Statement](https://privacy.microsoft.com/)