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,188 @@
1
+ ---
2
+ name: devbooks-entropy-monitor
3
+ description: devbooks-entropy-monitor: Periodically collect system entropy metrics (structural entropy/change entropy/test entropy/dependency entropy), generate quantitative reports, and recommend refactoring when thresholds are exceeded. Use when user mentions "entropy measurement/complexity trends/refactoring warnings/code health/technical debt measurement".
4
+ tools:
5
+ - Glob
6
+ - Grep
7
+ - Read
8
+ - Bash
9
+ ---
10
+
11
+ # DevBooks: System Entropy Measurement and Alerts (Entropy Monitor)
12
+
13
+ > Source: "The Mythical Man-Month" Chapter 16 "No Silver Bullet" — "The complexity of software entities is an essential property... controlling complexity is the key to software development"
14
+
15
+ ## Prerequisites: Configuration Discovery (Protocol-Agnostic)
16
+
17
+ - `<truth-root>`: Current truth directory root
18
+ - `<change-root>`: Change package directory root
19
+
20
+ Before execution, **must** search for configuration in the following order (stop when found):
21
+ 1. `.devbooks/config.yaml` (if exists) → Parse and use its mappings
22
+ 2. `dev-playbooks/project.md` (if exists) → DevBooks 2.0 protocol, use default mappings
23
+ 4. `project.md` (if exists) → Template protocol, use default mappings
24
+ 5. If still unable to determine → **Stop and ask the user**
25
+
26
+ **Key Constraints**:
27
+ - If `agents_doc` (rules document) is specified in configuration, **must read that document first** before executing any operations
28
+ - Do not guess directory roots
29
+ - Do not skip reading the rules document
30
+
31
+ ## Core Philosophy
32
+
33
+ **System Entropy** = Growth trend of code complexity over time
34
+
35
+ Goals of entropy measurement:
36
+ 1. **Quantification**: All metrics are numerical values/ratios, enabling comparison
37
+ 2. **Trend Visibility**: Historical data supports trend analysis
38
+ 3. **Threshold Alerts**: Proactively recommend refactoring when thresholds are exceeded
39
+ 4. **Periodic Execution**: Run as an independent task, not embedded in every code review
40
+
41
+ ## Execution Method
42
+
43
+ 1) First read and follow: `_shared/references/universal-gating-protocol.md` (verifiability + structural quality gating).
44
+ 2) Strictly output according to the complete prompt: `references/entropy-measurement-methodology.md`.
45
+
46
+ ## Scripts
47
+
48
+ | Script | Purpose | Example |
49
+ |--------|---------|---------|
50
+ | `entropy-measure.sh` | Collect entropy metrics | `entropy-measure.sh --project-root /path/to/repo` |
51
+ | `entropy-report.sh` | Generate report | `entropy-report.sh --output report.md` |
52
+
53
+ ## Metrics System (Four Dimensions)
54
+
55
+ ### A) Structural Entropy
56
+
57
+ | Metric | Collection Method | Healthy Threshold | Description |
58
+ |--------|------------------|-------------------|-------------|
59
+ | Average Cyclomatic Complexity | Static analysis | < 10 | Function-level average |
60
+ | Cyclomatic Complexity P95 | Static analysis | < 20 | 95th percentile |
61
+ | File Lines P95 | Line count | < 500 | Oversized file warning |
62
+ | Function Lines P95 | Static analysis | < 50 | Overly long function warning |
63
+
64
+ ### B) Change Entropy
65
+
66
+ | Metric | Collection Method | Healthy Threshold | Description |
67
+ |--------|------------------|-------------------|-------------|
68
+ | Hotspot File Ratio | git log | < 0.1 | Ratio of frequently modified files |
69
+ | Coupled Change Rate | git log | < 0.3 | Ratio of file pairs frequently modified together |
70
+ | Code Churn Rate | git diff | < 0.5 | Ratio of new code deleted within 30 days |
71
+
72
+ ### C) Test Entropy
73
+
74
+ | Metric | Collection Method | Healthy Threshold | Description |
75
+ |--------|------------------|-------------------|-------------|
76
+ | Flaky Test Ratio | CI logs | < 0.01 | Ratio of unstable tests |
77
+ | Test Coverage | Coverage tools | > 0.7 | Code coverage rate |
78
+ | Test/Code Ratio | Line count | > 0.5 | Ratio of test code to production code |
79
+
80
+ ### D) Dependency Entropy
81
+
82
+ | Metric | Collection Method | Healthy Threshold | Description |
83
+ |--------|------------------|-------------------|-------------|
84
+ | Outdated Dependency Ratio | npm/pip audit | < 0.2 | Dependencies more than 2 major versions behind |
85
+ | Security Vulnerability Count | Security scan | = 0 | Number of high-risk vulnerabilities |
86
+ | Dependency Depth P95 | Dependency tree analysis | < 10 | Levels of transitive dependencies |
87
+
88
+ ## Output Locations
89
+
90
+ | Output | Path | Description |
91
+ |--------|------|-------------|
92
+ | Entropy Report | `<truth-root>/_meta/entropy/entropy-report-YYYY-MM-DD.md` | Current collection report |
93
+ | Historical Data | `<truth-root>/_meta/entropy/history.json` | All historical metrics |
94
+ | Threshold Configuration | `<truth-root>/_meta/entropy/thresholds.json` | Configurable thresholds |
95
+
96
+ ## Recommended Execution Frequency
97
+
98
+ | Project Size | Recommended Frequency | Trigger Method |
99
+ |--------------|----------------------|----------------|
100
+ | Small (< 10K LOC) | Weekly | Manual / CI scheduled |
101
+ | Medium (10K-100K LOC) | Daily | CI scheduled |
102
+ | Large (> 100K LOC) | Every merge | PR merge trigger |
103
+
104
+ ## Relationship with Other Skills
105
+
106
+ | Skill | Relationship |
107
+ |-------|--------------|
108
+ | devbooks-code-review | Entropy measurement is **not** embedded in every review, runs as independent task |
109
+ | devbooks-proposal-author | Entropy reports can serve as data support for refactoring proposals |
110
+ | devbooks-impact-analysis | Changes in high-entropy areas require more careful impact analysis |
111
+
112
+ ## Hard Constraints
113
+
114
+ 1. **Quantification First**: All metrics must be numerical values/ratios, no subjective evaluations
115
+ 2. **Configurable Thresholds**: All thresholds managed through `thresholds.json`, not hardcoded
116
+ 3. **Historical Traceability**: Each collection result appended to `history.json`
117
+ 4. **Independent Execution**: Not embedded in other workflows, runs as periodic independent task
118
+
119
+ ---
120
+
121
+ ## Context Awareness
122
+
123
+ This Skill automatically detects context before execution to select appropriate collection scope.
124
+
125
+ Detection rules reference: `skills/_shared/context-detection-template.md`
126
+
127
+ ### Detection Flow
128
+
129
+ 1. Detect if historical data file exists
130
+ 2. Detect last collection time
131
+ 3. Detect if any metrics exceed thresholds
132
+
133
+ ### Modes Supported by This Skill
134
+
135
+ | Mode | Trigger Condition | Behavior |
136
+ |------|-------------------|----------|
137
+ | **Initial Collection** | Historical data does not exist | Execute full collection and establish baseline |
138
+ | **Incremental Collection** | Interval since last collection exceeded | Collect new data and compare trends |
139
+ | **Alert Mode** | Metrics exceeding thresholds detected | Generate alert report and recommend refactoring |
140
+
141
+ ### Detection Output Example
142
+
143
+ ```
144
+ Detection Results:
145
+ - Historical data: Exists (15 records)
146
+ - Last collection: 2026-01-10
147
+ - Metrics exceeding thresholds: 2 (Cyclomatic Complexity P95, Hotspot File Ratio)
148
+ - Execution mode: Incremental Collection + Alert Mode
149
+ ```
150
+
151
+ ---
152
+
153
+ ## MCP Enhancement
154
+
155
+ This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
156
+
157
+ MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
158
+
159
+ ### Required MCP Services
160
+
161
+ | Service | Purpose | Timeout |
162
+ |---------|---------|---------|
163
+ | `mcp__ckb__getHotspots` | Get hotspot file analysis | 2s |
164
+ | `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
165
+
166
+ ### Detection Flow
167
+
168
+ 1. Call `mcp__ckb__getStatus` (2s timeout)
169
+ 2. If CKB available → Use `getHotspots` for precise hotspot analysis
170
+ 3. If timeout or failure → Fall back to Git history statistics
171
+
172
+ ### Enhanced Mode vs Basic Mode
173
+
174
+ | Feature | Enhanced Mode | Basic Mode |
175
+ |---------|---------------|------------|
176
+ | Hotspot Analysis | CKB real-time analysis (includes complexity) | Git log change frequency statistics |
177
+ | Coupling Detection | Call graph analysis | File co-change analysis |
178
+ | Trend Prediction | Based on complexity change rate | Based on change frequency |
179
+
180
+ ### Fallback Notice
181
+
182
+ When MCP is unavailable, output the following notice:
183
+
184
+ ```
185
+ Warning: CKB unavailable, using Git history for entropy measurement.
186
+ Hotspot analysis based on change frequency, does not include code complexity data.
187
+ ```
188
+
@@ -0,0 +1,218 @@
1
+ # Entropy Metrics Methodology
2
+
3
+ > Source: *The Mythical Man-Month*, Ch. 16 “No Silver Bullet” — “the complexity of software is an essential property… controlling complexity is key”
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 **Entropy Monitor**. Your task is to **quantify** system complexity trends and recommend refactoring when metrics exceed thresholds.
9
+
10
+ ## Core idea
11
+
12
+ **Entropy** = a measure of system disorder.
13
+
14
+ In software systems:
15
+ - **Low entropy** = clear structure, controllable change, healthy tests, healthy dependencies
16
+ - **High entropy** = messy structure, frequent hotspots, fragile tests, dependency decay
17
+
18
+ Entropy growth is inevitable, but it can be reduced via **intentional refactoring**.
19
+
20
+ ## Four-dimension metrics framework
21
+
22
+ ### A) Structural entropy
23
+
24
+ Measures static code complexity.
25
+
26
+ | Metric | Collection | Healthy threshold | Signal |
27
+ |-------|------------|------------------|--------|
28
+ | Cyclomatic complexity mean | static analysis | < 10 | functions are too complex |
29
+ | Cyclomatic complexity P95 | static analysis | < 20 | extreme outlier functions exist |
30
+ | File LOC P95 | `wc -l` | < 500 | files too large; split |
31
+ | Function LOC P95 | static analysis | < 50 | functions too long; extract |
32
+
33
+ Suggested tools:
34
+ - JavaScript/TypeScript: `eslint --rule complexity`
35
+ - Python: `radon cc`
36
+ - Go: `gocyclo`
37
+ - Java: `PMD`, `Checkstyle`
38
+
39
+ ### B) Change entropy
40
+
41
+ Measures dynamic change patterns.
42
+
43
+ | Metric | Collection | Healthy threshold | Signal |
44
+ |-------|------------|------------------|--------|
45
+ | Hotspot ratio | git log analysis | < 0.1 | a few files absorb too much change |
46
+ | Coupled-change ratio | git log analysis | < 0.3 | implicit coupling across files |
47
+ | Churn ratio | git diff analysis | < 0.5 | newly added code is quickly removed |
48
+
49
+ **Hotspot**: a file modified more than 5 times within the analysis window.
50
+
51
+ **Coupled change**: two files modified together in the same commit frequently.
52
+
53
+ ### C) Test entropy
54
+
55
+ Measures test quality and stability.
56
+
57
+ | Metric | Collection | Healthy threshold | Signal |
58
+ |-------|------------|------------------|--------|
59
+ | Flaky ratio | CI log analysis | < 0.01 | unreliable tests |
60
+ | Coverage | coverage tooling | > 0.7 | critical paths untested |
61
+ | Test/code ratio | line counts | > 0.5 | insufficient test investment |
62
+
63
+ **Flaky test**: for the same code, repeated runs yield inconsistent results.
64
+
65
+ ### D) Dependency entropy
66
+
67
+ Measures dependency health.
68
+
69
+ | Metric | Collection | Healthy threshold | Signal |
70
+ |-------|------------|------------------|--------|
71
+ | Outdated ratio | `npm outdated` / `pip-audit` | < 0.2 | tech debt accumulation |
72
+ | Vulnerabilities | security scans | = 0 | security risk |
73
+ | Dependency depth P95 | dependency tree analysis | < 10 | supply-chain complexity |
74
+
75
+ **Outdated dependency**: lags the latest by more than 2 major versions.
76
+
77
+ ## Execution flow
78
+
79
+ ### 1) Collect metrics
80
+
81
+ ```bash
82
+ entropy-measure.sh --project-root /path/to/repo --days 30
83
+
84
+ # Output:
85
+ <truth-root>/_meta/entropy/metrics-YYYY-MM-DD.json
86
+ ```
87
+
88
+ ### 2) Generate report
89
+
90
+ ```bash
91
+ entropy-report.sh --output report.md
92
+
93
+ # Output:
94
+ <truth-root>/_meta/entropy/entropy-report-YYYY-MM-DD.md
95
+ ```
96
+
97
+ ### 3) Trend analysis
98
+
99
+ Historical data lives at `<truth-root>/_meta/entropy/history.json` and can be used to:
100
+ - plot trends
101
+ - compute deltas period-over-period
102
+ - estimate entropy growth rate
103
+
104
+ ### 4) Threshold alerts
105
+
106
+ If any metric exceeds threshold:
107
+ 1. report shows đź”´ status
108
+ 2. an alert entry is generated
109
+ 3. a concrete action is recommended
110
+
111
+ ## Threshold configuration
112
+
113
+ Thresholds live at `<truth-root>/_meta/entropy/thresholds.json`:
114
+
115
+ ```json
116
+ {
117
+ "structural": {
118
+ "complexity_mean": 10,
119
+ "complexity_p95": 20,
120
+ "file_lines_p95": 500,
121
+ "function_lines_p95": 50
122
+ },
123
+ "change": {
124
+ "hotspot_ratio": 0.1,
125
+ "coupling_ratio": 0.3,
126
+ "churn_ratio": 0.5
127
+ },
128
+ "test": {
129
+ "flaky_ratio": 0.01,
130
+ "coverage_min": 0.7,
131
+ "test_code_ratio_min": 0.5
132
+ },
133
+ "dependency": {
134
+ "outdated_ratio": 0.2,
135
+ "vulnerabilities": 0
136
+ }
137
+ }
138
+ ```
139
+
140
+ Threshold tuning principles:
141
+ - tune based on your project reality
142
+ - tighten gradually; do not “one-shot” it
143
+ - record rationale and date for changes
144
+
145
+ ## Connecting to refactoring proposals
146
+
147
+ When multiple entropy metrics are out of bounds:
148
+
149
+ 1. Use `devbooks-proposal-author` to start a refactoring proposal
150
+ 2. Cite entropy report data in the “Why” section of `proposal.md`
151
+ 3. Set verifiable entropy-reduction targets
152
+
153
+ Example:
154
+
155
+ ```markdown
156
+ ## Why
157
+
158
+ Entropy report (2024-01-15) shows:
159
+ - hotspot ratio 0.15 (threshold 0.1)
160
+ - file LOC P95 = 800 (threshold 500)
161
+
162
+ Recommendation: split `src/core/engine.ts` (1200 LOC) into multiple modules.
163
+
164
+ ## Validation
165
+
166
+ After refactor:
167
+ - hotspot ratio < 0.08
168
+ - file LOC P95 < 400
169
+ ```
170
+
171
+ ## Recommended cadence
172
+
173
+ | Project size | Cadence | Execution |
174
+ |-------------|---------|-----------|
175
+ | Small (< 10K LOC) | weekly | manual run |
176
+ | Medium (10K–100K LOC) | daily | scheduled CI job |
177
+ | Large (> 100K LOC) | per merge | trigger after PR merge |
178
+
179
+ ## CI integration example
180
+
181
+ ### GitHub Actions
182
+
183
+ ```yaml
184
+ name: Entropy Monitor
185
+ on:
186
+ schedule:
187
+ - cron: '0 2 * * *' # 2am daily
188
+ workflow_dispatch:
189
+
190
+ jobs:
191
+ measure:
192
+ runs-on: ubuntu-latest
193
+ steps:
194
+ - uses: actions/checkout@v4
195
+ with:
196
+ fetch-depth: 0 # full git history required
197
+ - name: Run entropy measurement
198
+ run: ./scripts/entropy-measure.sh
199
+ - name: Generate report
200
+ run: ./scripts/entropy-report.sh
201
+ - name: Upload artifacts
202
+ uses: actions/upload-artifact@v4
203
+ with:
204
+ name: entropy-report
205
+ path: specs/_meta/entropy/
206
+ ```
207
+
208
+ ## Hard constraints
209
+
210
+ 1. **Quantitative first**: all metrics must be numeric/ratios; no subjective “looks complex”
211
+ 2. **Thresholds are configurable**: managed via config files, not hard-coded
212
+ 3. **History is preserved**: append each run to history.json to enable trend analysis
213
+ 4. **Runs independently**: not embedded in every code review; run periodically as a standalone task
214
+ 5. **Action-oriented**: every threshold breach must have a concrete recommendation
215
+
216
+ ## References
217
+
218
+ - *The Mythical Man-Month*, Ch. 16 “No Silver Bullet”