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.
- package/LICENSE +21 -0
- package/README.md +463 -0
- package/bin/devbooks.js +986 -0
- package/package.json +41 -0
- package/skills/Skill-Development-Guide.md +249 -0
- package/skills/Skills-Usage-Guide.md +447 -0
- package/skills/_shared/context-detection-template.md +315 -0
- package/skills/_shared/mcp-enhancement-template.md +144 -0
- package/skills/_shared/references/universal-gating-protocol.md +114 -0
- package/skills/_template/config-discovery-template.md +126 -0
- package/skills/devbooks-brownfield-bootstrap/SKILL.md +168 -0
- package/skills/devbooks-brownfield-bootstrap/references/10-glossary-template.md +42 -0
- package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap-prompt.md +115 -0
- package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap.md +96 -0
- package/skills/devbooks-brownfield-bootstrap/references/code-navigation-strategy.md +203 -0
- package/skills/devbooks-brownfield-bootstrap/scripts/cod-update.sh +357 -0
- package/skills/devbooks-brownfield-bootstrap/templates/project-profile-template.md +172 -0
- package/skills/devbooks-c4-map/SKILL.md +151 -0
- package/skills/devbooks-c4-map/references/c4-architecture-map-prompt.md +33 -0
- package/skills/devbooks-c4-map/references/layered-constraint-checklist.md +185 -0
- package/skills/devbooks-code-review/SKILL.md +175 -0
- package/skills/devbooks-code-review/references/code-review-prompt.md +100 -0
- package/skills/devbooks-code-review/references/code-smell-cheatsheet.md +498 -0
- package/skills/devbooks-code-review/references/pr-template-and-guidelines.md +321 -0
- package/skills/devbooks-code-review/references/resource-management-review-checklist.md +311 -0
- package/skills/devbooks-coder/SKILL.md +219 -0
- package/skills/devbooks-coder/references/code-implementation-prompt.md +74 -0
- package/skills/devbooks-coder/references/coding-style-guidelines.md +351 -0
- package/skills/devbooks-coder/references/error-code-standard.md +463 -0
- package/skills/devbooks-coder/references/logging-standard.md +329 -0
- package/skills/devbooks-coder/references/low-risk-modification-techniques.md +275 -0
- package/skills/devbooks-delivery-workflow/SKILL.md +217 -0
- package/skills/devbooks-delivery-workflow/references/9-change-verification-traceability-template.md +133 -0
- package/skills/devbooks-delivery-workflow/references/delivery-acceptance-workflow.md +177 -0
- package/skills/devbooks-delivery-workflow/references/prototype-production-dual-track.md +169 -0
- package/skills/devbooks-delivery-workflow/scripts/ac-trace-check.sh +330 -0
- package/skills/devbooks-delivery-workflow/scripts/audit-scope.sh +262 -0
- package/skills/devbooks-delivery-workflow/scripts/change-check.sh +1039 -0
- package/skills/devbooks-delivery-workflow/scripts/change-codemod-scaffold.sh +135 -0
- package/skills/devbooks-delivery-workflow/scripts/change-evidence.sh +152 -0
- package/skills/devbooks-delivery-workflow/scripts/change-scaffold.sh +467 -0
- package/skills/devbooks-delivery-workflow/scripts/change-spec-delta-scaffold.sh +135 -0
- package/skills/devbooks-delivery-workflow/scripts/constitution-check.sh +237 -0
- package/skills/devbooks-delivery-workflow/scripts/env-match-check.sh +128 -0
- package/skills/devbooks-delivery-workflow/scripts/fitness-check.sh +365 -0
- package/skills/devbooks-delivery-workflow/scripts/guardrail-check.sh +516 -0
- package/skills/devbooks-delivery-workflow/scripts/handoff-check.sh +141 -0
- package/skills/devbooks-delivery-workflow/scripts/hygiene-check.sh +340 -0
- package/skills/devbooks-delivery-workflow/scripts/migrate-from-openspec.sh +385 -0
- package/skills/devbooks-delivery-workflow/scripts/migrate-to-v2-gates.sh +202 -0
- package/skills/devbooks-delivery-workflow/scripts/progress-dashboard.sh +319 -0
- package/skills/devbooks-delivery-workflow/scripts/prototype-promote.sh +341 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-preview.sh +203 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-promote.sh +118 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-rollback.sh +124 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-stage.sh +117 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-all.sh +78 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-npm-package.sh +123 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-openspec-free.sh +81 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-slash-commands.sh +146 -0
- package/skills/devbooks-delivery-workflow/templates/handoff.md +50 -0
- package/skills/devbooks-design-backport/SKILL.md +73 -0
- package/skills/devbooks-design-backport/references/design-backport-prompt.md +132 -0
- package/skills/devbooks-design-doc/SKILL.md +121 -0
- package/skills/devbooks-design-doc/references/design-doc-prompt.md +188 -0
- package/skills/devbooks-design-doc/references/microservice-design-checklist.md +149 -0
- package/skills/devbooks-design-doc/references/privacy-compliance-checklist.md +240 -0
- package/skills/devbooks-entropy-monitor/SKILL.md +188 -0
- package/skills/devbooks-entropy-monitor/references/entropy-metrics-methodology.md +218 -0
- package/skills/devbooks-entropy-monitor/scripts/entropy-measure.sh +449 -0
- package/skills/devbooks-entropy-monitor/scripts/entropy-report.sh +303 -0
- package/skills/devbooks-entropy-monitor/templates/thresholds.json +99 -0
- package/skills/devbooks-federation/SKILL.md +264 -0
- package/skills/devbooks-federation/scripts/federation-check.sh +144 -0
- package/skills/devbooks-federation/templates/federation.yaml +89 -0
- package/skills/devbooks-impact-analysis/SKILL.md +135 -0
- package/skills/devbooks-impact-analysis/references/impact-analysis-prompt.md +82 -0
- package/skills/devbooks-impact-analysis/scripts/graph-cache.sh +214 -0
- package/skills/devbooks-implementation-plan/SKILL.md +83 -0
- package/skills/devbooks-implementation-plan/references/implementation-plan-prompt.md +95 -0
- package/skills/devbooks-index-bootstrap/SKILL.md +240 -0
- package/skills/devbooks-proposal-author/SKILL.md +83 -0
- package/skills/devbooks-proposal-author/references/proposal-authoring-prompt.md +66 -0
- package/skills/devbooks-proposal-challenger/SKILL.md +86 -0
- package/skills/devbooks-proposal-challenger/references/ethics-and-compliance-checklist.md +176 -0
- package/skills/devbooks-proposal-challenger/references/proposal-challenge-prompt.md +57 -0
- package/skills/devbooks-proposal-debate-workflow/SKILL.md +78 -0
- package/skills/devbooks-proposal-debate-workflow/references/11-proposal-debate-template.md +35 -0
- package/skills/devbooks-proposal-debate-workflow/references/proposal-debate-workflow.md +24 -0
- package/skills/devbooks-proposal-debate-workflow/scripts/proposal-debate-check.sh +102 -0
- package/skills/devbooks-proposal-judge/SKILL.md +78 -0
- package/skills/devbooks-proposal-judge/references/proposal-judge-prompt.md +37 -0
- package/skills/devbooks-router/SKILL.md +346 -0
- package/skills/devbooks-spec-contract/SKILL.md +191 -0
- package/skills/devbooks-spec-contract/references/api-design-guide.md +349 -0
- package/skills/devbooks-spec-contract/references/contract-and-data-definition-prompt.md +85 -0
- package/skills/devbooks-spec-contract/references/implicit-change-detection-prompt.md +183 -0
- package/skills/devbooks-spec-contract/references/spec-change-prompt.md +63 -0
- package/skills/devbooks-spec-contract/scripts/implicit-change-detect.sh +378 -0
- package/skills/devbooks-spec-gardener/SKILL.md +73 -0
- package/skills/devbooks-spec-gardener/references/spec-gardener-prompt.md +41 -0
- package/skills/devbooks-test-owner/SKILL.md +173 -0
- package/skills/devbooks-test-owner/references/9-change-verification-traceability-template.md +133 -0
- package/skills/devbooks-test-owner/references/async-system-test-strategy.md +316 -0
- package/skills/devbooks-test-owner/references/decoupling-techniques-cheatsheet.md +269 -0
- package/skills/devbooks-test-owner/references/test-code-prompt.md +171 -0
- package/skills/devbooks-test-owner/references/test-driven-development.md +351 -0
- package/skills/devbooks-test-owner/references/test-layering-strategy.md +281 -0
- package/skills/devbooks-test-reviewer/SKILL.md +189 -0
- package/templates/.devbooks/config.yaml +88 -0
- package/templates/claude-commands/devbooks/apply.md +38 -0
- package/templates/claude-commands/devbooks/archive.md +33 -0
- package/templates/claude-commands/devbooks/backport.md +19 -0
- package/templates/claude-commands/devbooks/bootstrap.md +20 -0
- package/templates/claude-commands/devbooks/c4.md +20 -0
- package/templates/claude-commands/devbooks/challenger.md +19 -0
- package/templates/claude-commands/devbooks/code.md +20 -0
- package/templates/claude-commands/devbooks/debate.md +20 -0
- package/templates/claude-commands/devbooks/delivery.md +20 -0
- package/templates/claude-commands/devbooks/design.md +20 -0
- package/templates/claude-commands/devbooks/entropy.md +19 -0
- package/templates/claude-commands/devbooks/federation.md +19 -0
- package/templates/claude-commands/devbooks/gardener.md +19 -0
- package/templates/claude-commands/devbooks/impact.md +19 -0
- package/templates/claude-commands/devbooks/index.md +19 -0
- package/templates/claude-commands/devbooks/judge.md +19 -0
- package/templates/claude-commands/devbooks/plan.md +20 -0
- package/templates/claude-commands/devbooks/proposal.md +20 -0
- package/templates/claude-commands/devbooks/quick.md +43 -0
- package/templates/claude-commands/devbooks/review.md +20 -0
- package/templates/claude-commands/devbooks/router.md +19 -0
- package/templates/claude-commands/devbooks/spec.md +20 -0
- package/templates/claude-commands/devbooks/test-review.md +19 -0
- package/templates/claude-commands/devbooks/test.md +20 -0
- package/templates/dev-playbooks/changes/.gitkeep +1 -0
- package/templates/dev-playbooks/constitution.md +116 -0
- package/templates/dev-playbooks/project.md +96 -0
- package/templates/dev-playbooks/scripts/.gitkeep +1 -0
- package/templates/dev-playbooks/specs/_meta/anti-patterns/.gitkeep +2 -0
- package/templates/dev-playbooks/specs/_meta/glossary.md +48 -0
- package/templates/dev-playbooks/specs/_meta/project-profile.md +79 -0
- package/templates/dev-playbooks/specs/architecture/fitness-rules.md +95 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# C4 Architecture Map Prompt
|
|
2
|
+
|
|
3
|
+
> **Role**: You are the strongest “architecture visualization brain” — combining the knowledge of Simon Brown (C4 model), Martin Fowler (architecture patterns), and Gregor Hohpe (enterprise integration). Your architecture map 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 **C4 Map Maintainer**. Your goal is to maintain a **stable architecture map (Current Truth)** for a large project using C4 (Context/Container/Component), and ensure it provides actionable input for impact analysis, task decomposition, and architecture guardrails (fitness tests).
|
|
9
|
+
|
|
10
|
+
Key viewpoints:
|
|
11
|
+
- The “authoritative” C4 map should not be scattered across per-change design docs; it is a cross-change “current truth map”.
|
|
12
|
+
- Each change’s design doc should only include a **C4 Delta** (what is added/modified/removed), and the change package should include tasks to update the authoritative map.
|
|
13
|
+
|
|
14
|
+
Recommended location (not external-facing docs):
|
|
15
|
+
- Keep the authoritative C4 map in the “truth root”, for example:
|
|
16
|
+
- `<truth-root>/architecture/c4.md` (or an equivalent location you choose)
|
|
17
|
+
|
|
18
|
+
Inputs (provided by me):
|
|
19
|
+
- The current C4 map (if it exists)
|
|
20
|
+
- Current specs: `<truth-root>/`
|
|
21
|
+
- The design doc for this change: `<change-root>/<change-id>/design.md` (if this is an architecture change)
|
|
22
|
+
|
|
23
|
+
Output format (MECE):
|
|
24
|
+
1) C1: System Context (system boundary, external systems, primary users)
|
|
25
|
+
2) C2: Container (major containers/services/apps, interfaces and dependency direction)
|
|
26
|
+
3) C3: Component (expand only key containers; keep minimal)
|
|
27
|
+
4) Architecture Guardrails (recommended fitness tests, e.g., layering / no cycles / no boundary violations)
|
|
28
|
+
|
|
29
|
+
Diagram requirements:
|
|
30
|
+
- Mermaid is allowed; prefer text-readable expressions (avoid over-styling).
|
|
31
|
+
- Do not cover every detail; the goal is to align on boundaries and dependency direction.
|
|
32
|
+
|
|
33
|
+
Now output the C4 map in Markdown. Do not output extra explanations.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Layering Constraints Checklist
|
|
2
|
+
|
|
3
|
+
Inspired by VS Code’s `code-layering.ts` and `layersChecker.ts`, this document defines practical checks for a layered architecture.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1) Layer Dependency Checks
|
|
8
|
+
|
|
9
|
+
### 1.1 Unidirectional Dependency Violations
|
|
10
|
+
|
|
11
|
+
**How to check**: scan `import`/`require` statements and validate dependency direction.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Violation: base layer importing platform layer
|
|
15
|
+
// src/base/utils.ts
|
|
16
|
+
import { ConfigService } from '../platform/config'; // ❌ violation
|
|
17
|
+
|
|
18
|
+
// Correct: platform layer importing base layer
|
|
19
|
+
// src/platform/config.ts
|
|
20
|
+
import { deepClone } from '../base/utils'; // ✅ allowed
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Example commands** (grep/rg):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Check whether base illegally imports platform
|
|
27
|
+
rg "from ['\"].*platform" src/base/ --type ts
|
|
28
|
+
|
|
29
|
+
# Check whether common illegally imports browser/node
|
|
30
|
+
rg "from ['\"].*(browser|node)" src/common/ --type ts
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 1.2 Environment Isolation Violations
|
|
34
|
+
|
|
35
|
+
| Environment | Forbidden APIs | Detection regex |
|
|
36
|
+
|------|-----------|---------|
|
|
37
|
+
| common | DOM API | `document\.|window\.|navigator\.` |
|
|
38
|
+
| common | Node API | `require\(['"]fs['"]\)|process\.|__dirname` |
|
|
39
|
+
| browser | Node API | `require\(['"]fs['"]\)|child_process` |
|
|
40
|
+
| node | DOM API | `document\.|window\.|DOM\.` |
|
|
41
|
+
|
|
42
|
+
### 1.3 contrib Reverse-Dependency Checks
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Check whether core illegally imports contrib
|
|
46
|
+
rg "from ['\"].*contrib" src/core/ --type ts
|
|
47
|
+
rg "from ['\"].*contrib" src/workbench/services/ --type ts
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 2) Layering Constraints Template
|
|
53
|
+
|
|
54
|
+
Add this to `<truth-root>/architecture/c4.md`:
|
|
55
|
+
|
|
56
|
+
```markdown
|
|
57
|
+
## Architecture Guardrails
|
|
58
|
+
|
|
59
|
+
### Layering Constraints
|
|
60
|
+
|
|
61
|
+
This project uses an N-layer architecture with dependency direction: `base ← platform ← domain ← application ← ui`
|
|
62
|
+
|
|
63
|
+
| Layer | Directory | Responsibility | Allowed deps | Forbidden deps |
|
|
64
|
+
|------|------|------|--------|----------|
|
|
65
|
+
| base | src/base/ | Utilities, cross-platform abstractions | (none) | all other layers |
|
|
66
|
+
| platform | src/platform/ | Platform services, dependency injection | base | domain, app, ui |
|
|
67
|
+
| domain | src/domain/ | Business logic, domain model | base, platform | app, ui |
|
|
68
|
+
| application | src/app/ | App services, use-case orchestration | base, platform, domain | ui |
|
|
69
|
+
| ui | src/ui/ | User interface, interaction logic | all layers | (none) |
|
|
70
|
+
|
|
71
|
+
### Environment Constraints
|
|
72
|
+
|
|
73
|
+
| Environment directory | Allowed | Forbidden |
|
|
74
|
+
|----------|--------|----------|
|
|
75
|
+
| */common/ | platform-agnostic libs | */browser/*, */node/* |
|
|
76
|
+
| */browser/ | */common/* | */node/* |
|
|
77
|
+
| */node/ | */common/* | */browser/* |
|
|
78
|
+
|
|
79
|
+
### Validation Commands
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Layering violations check
|
|
83
|
+
npm run valid-layers-check
|
|
84
|
+
|
|
85
|
+
# Or check manually
|
|
86
|
+
rg "from ['\"].*platform" src/base/ --type ts && echo "FAIL: base→platform" || echo "OK"
|
|
87
|
+
```
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 3) Severity Levels for Layering Violations
|
|
93
|
+
|
|
94
|
+
| Violation type | Severity | Handling |
|
|
95
|
+
|----------|----------|----------|
|
|
96
|
+
| Lower layer depends on upper layer | **Critical** | must fix immediately; block merge |
|
|
97
|
+
| common depends on browser/node | **Critical** | must fix immediately |
|
|
98
|
+
| Cross-layer deep import of Internal modules | **High** | use public APIs instead |
|
|
99
|
+
| core depends on contrib | **High** | violates extension-point design |
|
|
100
|
+
| Cyclic dependencies | **High** | requires refactoring/decoupling |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 4) Integrating Layer Checks
|
|
105
|
+
|
|
106
|
+
### 4.1 Configure in ESLint (recommended)
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
// eslint.config.js
|
|
110
|
+
module.exports = {
|
|
111
|
+
rules: {
|
|
112
|
+
'import/no-restricted-paths': ['error', {
|
|
113
|
+
zones: [
|
|
114
|
+
// base must not import platform
|
|
115
|
+
{ target: './src/base', from: './src/platform', message: 'base cannot import platform' },
|
|
116
|
+
// platform must not import domain
|
|
117
|
+
{ target: './src/platform', from: './src/domain', message: 'platform cannot import domain' },
|
|
118
|
+
// common must not import browser/node
|
|
119
|
+
{ target: './src/**/common', from: './src/**/browser', message: 'common cannot import browser' },
|
|
120
|
+
{ target: './src/**/common', from: './src/**/node', message: 'common cannot import node' },
|
|
121
|
+
]
|
|
122
|
+
}]
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 4.2 Configure in TypeScript
|
|
128
|
+
|
|
129
|
+
Create a separate `tsconfig` for each layer:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
// tsconfig.base.json
|
|
133
|
+
{
|
|
134
|
+
"compilerOptions": {
|
|
135
|
+
"paths": {
|
|
136
|
+
// base layer can only see itself
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"include": ["src/base/**/*"],
|
|
140
|
+
"exclude": ["src/platform/**/*", "src/domain/**/*"]
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 4.3 Configure in CI
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
# .github/workflows/pr.yml
|
|
148
|
+
- name: Check layer constraints
|
|
149
|
+
run: |
|
|
150
|
+
# Check for layering violations
|
|
151
|
+
./scripts/valid-layers-check.sh || exit 1
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 5) Layering Refactoring Guide
|
|
157
|
+
|
|
158
|
+
When a layering violation is found:
|
|
159
|
+
|
|
160
|
+
1. **Identify the reason**
|
|
161
|
+
- Is the dependency actually legitimate? (You may need to adjust the layering definition.)
|
|
162
|
+
- Can you decouple via interface abstractions?
|
|
163
|
+
- Should the code be moved to the correct layer?
|
|
164
|
+
|
|
165
|
+
2. **Decoupling strategies**
|
|
166
|
+
- **Dependency injection**: upper layers inject interfaces; lower layers do not depend on implementations
|
|
167
|
+
- **Events**: lower layers publish events; upper layers subscribe
|
|
168
|
+
- **Callbacks**: lower layers accept callback functions and avoid knowing callers
|
|
169
|
+
|
|
170
|
+
3. **Code movement**
|
|
171
|
+
- If the code belongs in a lower layer, move it to the correct location
|
|
172
|
+
- Update all import paths
|
|
173
|
+
- Run layer checks to confirm the fix
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 6) Review Checklist
|
|
178
|
+
|
|
179
|
+
During code review, check:
|
|
180
|
+
|
|
181
|
+
- [ ] Do new imports follow layer constraints?
|
|
182
|
+
- [ ] Are there deep imports into Internal modules?
|
|
183
|
+
- [ ] Does code under `common/` use platform-specific APIs?
|
|
184
|
+
- [ ] Does `core` import `contrib`?
|
|
185
|
+
- [ ] Are there cyclic dependencies?
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: devbooks-code-review
|
|
3
|
+
description: devbooks-code-review: Perform readability/consistency/dependency health/code smell reviews as a Reviewer role, outputting only review comments and actionable suggestions without discussing business correctness. Use when user says "help me do code review/review maintainability/code smells/dependency risks/consistency suggestions", or when executing as reviewer during DevBooks apply phase.
|
|
4
|
+
tools:
|
|
5
|
+
- Glob
|
|
6
|
+
- Grep
|
|
7
|
+
- Read
|
|
8
|
+
- Bash
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# DevBooks: Code Review (Reviewer)
|
|
12
|
+
|
|
13
|
+
## Prerequisites: Configuration Discovery (Protocol Agnostic)
|
|
14
|
+
|
|
15
|
+
- `<truth-root>`: Current truth directory root
|
|
16
|
+
- `<change-root>`: Change package directory root
|
|
17
|
+
|
|
18
|
+
Before execution, **must** search for configuration in the following order (stop when found):
|
|
19
|
+
1. `.devbooks/config.yaml` (if exists) -> Parse and use its mappings
|
|
20
|
+
2. `dev-playbooks/project.md` (if exists) -> DevBooks 2.0 protocol, use default mappings
|
|
21
|
+
4. `project.md` (if exists) -> template protocol, use default mappings
|
|
22
|
+
5. If still undetermined -> **Stop and ask user**
|
|
23
|
+
|
|
24
|
+
**Key Constraints**:
|
|
25
|
+
- If configuration specifies `agents_doc` (rules document), **must read that document first** before executing any operations
|
|
26
|
+
- Do not guess directory roots
|
|
27
|
+
- Do not skip reading rules document
|
|
28
|
+
|
|
29
|
+
## Review Dimensions
|
|
30
|
+
|
|
31
|
+
### 1. Readability Review
|
|
32
|
+
- Naming consistency (PascalCase/camelCase)
|
|
33
|
+
- Function length and complexity
|
|
34
|
+
- Comment quality and necessity
|
|
35
|
+
- Code formatting
|
|
36
|
+
|
|
37
|
+
### 2. Dependency Health Review
|
|
38
|
+
- Layer constraint compliance (see devbooks-c4-map)
|
|
39
|
+
- Circular dependency detection
|
|
40
|
+
- Internal module encapsulation (prohibit deep imports of *Internal files)
|
|
41
|
+
- Dependency direction correctness
|
|
42
|
+
|
|
43
|
+
### 3. Resource Management Review
|
|
44
|
+
|
|
45
|
+
**Resource leak patterns that must be checked**:
|
|
46
|
+
|
|
47
|
+
| Check Item | Violation Pattern | Correct Pattern |
|
|
48
|
+
|------------|-------------------|-----------------|
|
|
49
|
+
| Unsubscribed subscriptions | `event.on(...)` without corresponding `off()` | Register to DisposableStore |
|
|
50
|
+
| Uncleaned timers | `setInterval()` without `clearInterval()` | Clean up in dispose() |
|
|
51
|
+
| Unreleased listeners | `addEventListener()` without `removeEventListener()` | Use AbortController |
|
|
52
|
+
| Unclosed streams | `createReadStream()` without `close()` | Use try-finally or using |
|
|
53
|
+
| Unreleased connections | `connect()` without `disconnect()` | Use connection pool or dispose pattern |
|
|
54
|
+
|
|
55
|
+
**DisposableStore Pattern Checks**:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Violation: mutable disposable field
|
|
59
|
+
private disposable = new DisposableStore(); // should be readonly
|
|
60
|
+
|
|
61
|
+
// Violation: dispose() not calling super.dispose()
|
|
62
|
+
dispose() {
|
|
63
|
+
this.cleanup(); // missing super.dispose()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Correct pattern
|
|
67
|
+
private readonly _disposables = new DisposableStore();
|
|
68
|
+
|
|
69
|
+
override dispose() {
|
|
70
|
+
this._disposables.dispose();
|
|
71
|
+
super.dispose();
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Resource Management Checklist**:
|
|
76
|
+
- [ ] Are DisposableStore fields declared as `readonly` or `const`?
|
|
77
|
+
- [ ] Does the dispose() method call `super.dispose()`?
|
|
78
|
+
- [ ] Are subscriptions/listeners registered to DisposableStore?
|
|
79
|
+
- [ ] Do tests include `ensureNoDisposablesAreLeakedInTestSuite()`?
|
|
80
|
+
|
|
81
|
+
### 4. Type Safety Review
|
|
82
|
+
|
|
83
|
+
- [ ] Are there `as any` type assertions?
|
|
84
|
+
- [ ] Are there dangerous `{} as T` assertions?
|
|
85
|
+
- [ ] Is `unknown` used instead of `any`?
|
|
86
|
+
- [ ] Are generic constraints strict enough?
|
|
87
|
+
|
|
88
|
+
### 5. Code Smell Detection
|
|
89
|
+
|
|
90
|
+
See: `references/code-smell-cheatsheet.md`
|
|
91
|
+
|
|
92
|
+
### 6. Test Quality Review
|
|
93
|
+
|
|
94
|
+
- [ ] Are there `test.only` / `describe.only`?
|
|
95
|
+
- [ ] Do tests have cleanup logic (afterEach)?
|
|
96
|
+
- [ ] Are tests independent (not dependent on execution order)?
|
|
97
|
+
- [ ] Are mocks properly reset?
|
|
98
|
+
|
|
99
|
+
## Execution Method
|
|
100
|
+
|
|
101
|
+
1) First read and follow: `_shared/references/universal-gating-protocol.md` (verifiability + structural quality gates).
|
|
102
|
+
2) Read resource management guide: `references/resource-management-checklist.md`.
|
|
103
|
+
3) Strictly follow the complete prompt to output review comments: `references/code-review-prompt.md`.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Context Awareness
|
|
108
|
+
|
|
109
|
+
This Skill automatically detects context before execution and selects the appropriate review scope.
|
|
110
|
+
|
|
111
|
+
Detection rules reference: `skills/_shared/context-detection-template.md`
|
|
112
|
+
|
|
113
|
+
### Detection Flow
|
|
114
|
+
|
|
115
|
+
1. Detect if change package exists
|
|
116
|
+
2. Detect if there are code changes (git diff)
|
|
117
|
+
3. Detect hotspot files (via CKB getHotspots)
|
|
118
|
+
|
|
119
|
+
### Modes Supported by This Skill
|
|
120
|
+
|
|
121
|
+
| Mode | Trigger Condition | Behavior |
|
|
122
|
+
|------|-------------------|----------|
|
|
123
|
+
| **Change Package Review** | change-id provided | Review code changes related to that change package |
|
|
124
|
+
| **File Review** | Specific file path provided | Review specified files |
|
|
125
|
+
| **Hotspot Priority Review** | Hotspot file changes detected | Prioritize reviewing high-risk hotspots |
|
|
126
|
+
|
|
127
|
+
### Detection Output Example
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Detection Results:
|
|
131
|
+
- Change package status: exists
|
|
132
|
+
- Code changes: 12 files
|
|
133
|
+
- Hotspot files: 3 (require focused attention)
|
|
134
|
+
- Running mode: Change package review + Hotspot priority
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## MCP Enhancement
|
|
140
|
+
|
|
141
|
+
This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
|
|
142
|
+
|
|
143
|
+
MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
|
|
144
|
+
|
|
145
|
+
### Dependent MCP Services
|
|
146
|
+
|
|
147
|
+
| Service | Purpose | Timeout |
|
|
148
|
+
|---------|---------|---------|
|
|
149
|
+
| `mcp__ckb__getHotspots` | Detect hotspot files for priority review | 2s |
|
|
150
|
+
| `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
|
|
151
|
+
|
|
152
|
+
### Detection Flow
|
|
153
|
+
|
|
154
|
+
1. Call `mcp__ckb__getStatus` (2s timeout)
|
|
155
|
+
2. If CKB available -> Call `mcp__ckb__getHotspots` to get hotspot files
|
|
156
|
+
3. Perform priority review on hotspot files
|
|
157
|
+
4. If timeout or failure -> Fallback to basic mode
|
|
158
|
+
|
|
159
|
+
### Enhanced Mode vs Basic Mode
|
|
160
|
+
|
|
161
|
+
| Feature | Enhanced Mode | Basic Mode |
|
|
162
|
+
|---------|---------------|------------|
|
|
163
|
+
| Hotspot priority review | Automatically identify high-risk files | Review in change order |
|
|
164
|
+
| Dependency direction check | Based on module graph analysis | Inferred from file paths |
|
|
165
|
+
| Circular dependency detection | CKB precise detection | Grep heuristic detection |
|
|
166
|
+
|
|
167
|
+
### Fallback Notice
|
|
168
|
+
|
|
169
|
+
When MCP is unavailable, output the following notice:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
Warning: CKB unavailable, cannot perform hotspot priority review.
|
|
173
|
+
Reviewing in change file order.
|
|
174
|
+
```
|
|
175
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Code Review Prompt
|
|
2
|
+
|
|
3
|
+
> **Role**: You are the strongest “code review brain” — combining the knowledge of Michael Feathers (legacy code), Robert C. Martin (Clean Code), and Martin Fowler (refactoring and readability). Your review 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 **Reviewer**. Your task is to evaluate readability, consistency, dependency health, and code-smell risk, and provide actionable improvement suggestions.
|
|
9
|
+
|
|
10
|
+
Inputs (provided by me):
|
|
11
|
+
- The code involved in this change
|
|
12
|
+
- Project profile & conventions: `<truth-root>/_meta/project-profile.md`
|
|
13
|
+
- Glossary / ubiquitous language (if present): `<truth-root>/_meta/glossary.md`
|
|
14
|
+
- High-ROI pitfalls list (if present): `<truth-root>/engineering/pitfalls.md`
|
|
15
|
+
|
|
16
|
+
Hard constraints (must follow):
|
|
17
|
+
1) Output only review findings and concrete change suggestions; do not directly modify `tests/` or design documents.
|
|
18
|
+
2) Do not debate business correctness (tests/specs decide that); focus only on maintainability and engineering quality.
|
|
19
|
+
|
|
20
|
+
Review focus (must cover):
|
|
21
|
+
- Readability: naming, structure, responsibility boundaries, consistent error handling
|
|
22
|
+
- Dependency health: version alignment, implicit/transitive dependencies, cycles
|
|
23
|
+
- Convention alignment: consistency with at least 3 similar files in this repo
|
|
24
|
+
- Structural guardrails: detect whether “proxy-metric-driven” changes damage cohesion/coupling/testability
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Eight Core Code Smells (must check)
|
|
29
|
+
|
|
30
|
+
> Source: *Refactoring* (debate edition) — reduced from 22 to 8 high-frequency/high-impact smells
|
|
31
|
+
|
|
32
|
+
| Smell | Detection criteria | Severity | Suggested refactoring |
|
|
33
|
+
|------|--------------------|----------|------------------------|
|
|
34
|
+
| **1) Duplicated Code** | ≥2 code blocks with >80% similarity | Blocking | Extract Method → Pull Up Method |
|
|
35
|
+
| **2) Long Method** | **P95 < 50 lines** (exceptions allowed; exceed triggers discussion) | Blocking | Extract Method / Replace Temp with Query |
|
|
36
|
+
| **3) Large Class** | **P95 < 500 lines** (exceptions allowed) | Warning | Extract Class / Extract Subclass |
|
|
37
|
+
| **4) Long Parameter List** | Parameter count > 5 | Blocking | Introduce Parameter Object / Preserve Whole Object |
|
|
38
|
+
| **5) Divergent Change** | One class changes for multiple unrelated reasons | Warning | Extract Class (separate change axes) |
|
|
39
|
+
| **6) Shotgun Surgery** | One change requires edits across ≥3 classes | Blocking | Move Method / Move Field |
|
|
40
|
+
| **7) Feature Envy** | A function calls other classes more than its own | Warning | Move Method |
|
|
41
|
+
| **8) Primitive Obsession** | Business concepts (Money/Email/UserId) are not modeled as value objects | Warning | Replace Data Value with Object |
|
|
42
|
+
|
|
43
|
+
**Threshold notes**:
|
|
44
|
+
- P95 allows 5% exceptions; exceeding should trigger human discussion rather than automatic rejection.
|
|
45
|
+
- “Blocking” = must be fixed before merge.
|
|
46
|
+
- “Warning” = recommended to fix; acceptable to merge with a recorded tech-debt item.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## N+1 Detection (conditional)
|
|
51
|
+
|
|
52
|
+
> **Trigger condition**: only check if the change touches ORM calls or loops that call external API/RPC; pure computation/utilities may skip.
|
|
53
|
+
|
|
54
|
+
- **ORM N+1**: ORM query inside a loop? Missing eager loading / batch fetch?
|
|
55
|
+
- **Remote N+1**: API/RPC call inside a loop? Should it become a batch endpoint?
|
|
56
|
+
- If an N+1 pattern is detected, mark it as a **blocking issue (must fix)**.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Terminology Consistency (Ubiquitous Language) (must check)
|
|
61
|
+
|
|
62
|
+
- Do class/variable/method names match `glossary.md`?
|
|
63
|
+
- Are there new terms not defined in `glossary.md`? (If so, recommend updating the glossary first.)
|
|
64
|
+
- Is the same concept named inconsistently across modules (e.g., User/Account/Member mixed)?
|
|
65
|
+
- Is Entity vs Value Object modeled correctly? (Entity has an ID; VO has no ID and is immutable.)
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Invariant Protection (must check)
|
|
70
|
+
|
|
71
|
+
- If `design.md` marks an `[Invariant]`, verify the code has matching assertions/validation.
|
|
72
|
+
- Can state transitions violate declared invariants?
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Design Pattern Checks (situational)
|
|
77
|
+
|
|
78
|
+
> The following are **C-level (optional)** checks; apply only when relevant.
|
|
79
|
+
|
|
80
|
+
- **Program to interfaces**: are external dependencies (DB/cache/API) abstracted behind interfaces?
|
|
81
|
+
- **Prefer composition over inheritance**: warn if inheritance depth > 3 (allow shallow inheritance ≤2)
|
|
82
|
+
- **Singleton detection**: recommend dependency injection (treat as maintainability risk, not blocking)
|
|
83
|
+
- **Change-point detection**: if `if/else` or `switch` branches > 5, suggest strategy/polymorphism (advice only)
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Checks Removed After Debate
|
|
88
|
+
|
|
89
|
+
The following were removed or downgraded after a three-role debate and are no longer mandatory:
|
|
90
|
+
- ~~Parallel Inheritance Hierarchies~~ → rare in modern codebases
|
|
91
|
+
- ~~Lazy Class~~ → conflicts with SRP; small classes are often good design
|
|
92
|
+
- ~~Message Chains~~ → functional chaining is common
|
|
93
|
+
- ~~Warn if function > 20 lines~~ → replaced by P95 < 50 lines
|
|
94
|
+
- ~~Warn if params > 3~~ → replaced by blocking if > 5
|
|
95
|
+
|
|
96
|
+
Output format:
|
|
97
|
+
1) Blocking issues (must fix)
|
|
98
|
+
2) Maintainability risks (recommended)
|
|
99
|
+
3) Style & consistency suggestions (optional)
|
|
100
|
+
4) If new quality gates are needed (lint/complexity/dependency rules), propose them concretely
|