@zigrivers/scaffold 2.1.1 → 2.28.1

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 (100) hide show
  1. package/README.md +272 -59
  2. package/dist/project/frontmatter.d.ts.map +1 -1
  3. package/dist/project/frontmatter.js +4 -0
  4. package/dist/project/frontmatter.js.map +1 -1
  5. package/knowledge/core/adr-craft.md +53 -0
  6. package/knowledge/core/ai-memory-management.md +246 -0
  7. package/knowledge/core/api-design.md +4 -0
  8. package/knowledge/core/claude-md-patterns.md +254 -0
  9. package/knowledge/core/coding-conventions.md +246 -0
  10. package/knowledge/core/database-design.md +4 -0
  11. package/knowledge/core/design-system-tokens.md +465 -0
  12. package/knowledge/core/dev-environment.md +223 -0
  13. package/knowledge/core/domain-modeling.md +4 -0
  14. package/knowledge/core/eval-craft.md +1008 -0
  15. package/knowledge/core/multi-model-review-dispatch.md +250 -0
  16. package/knowledge/core/operations-runbook.md +37 -226
  17. package/knowledge/core/project-structure-patterns.md +231 -0
  18. package/knowledge/core/review-step-template.md +247 -0
  19. package/knowledge/core/{security-review.md → security-best-practices.md} +5 -1
  20. package/knowledge/core/task-decomposition.md +57 -34
  21. package/knowledge/core/task-tracking.md +225 -0
  22. package/knowledge/core/tech-stack-selection.md +214 -0
  23. package/knowledge/core/testing-strategy.md +63 -70
  24. package/knowledge/core/user-stories.md +69 -60
  25. package/knowledge/core/user-story-innovation.md +57 -0
  26. package/knowledge/core/ux-specification.md +5 -148
  27. package/knowledge/finalization/apply-fixes-and-freeze.md +165 -14
  28. package/knowledge/product/prd-craft.md +55 -34
  29. package/knowledge/review/review-adr.md +32 -0
  30. package/knowledge/review/{review-api-contracts.md → review-api-design.md} +34 -1
  31. package/knowledge/review/{review-database-schema.md → review-database-design.md} +27 -1
  32. package/knowledge/review/review-domain-modeling.md +33 -0
  33. package/knowledge/review/review-implementation-tasks.md +50 -0
  34. package/knowledge/review/review-operations.md +55 -0
  35. package/knowledge/review/review-prd.md +33 -0
  36. package/knowledge/review/review-security.md +53 -0
  37. package/knowledge/review/review-system-architecture.md +28 -0
  38. package/knowledge/review/review-testing-strategy.md +51 -0
  39. package/knowledge/review/review-user-stories.md +54 -0
  40. package/knowledge/review/{review-ux-spec.md → review-ux-specification.md} +37 -1
  41. package/methodology/custom-defaults.yml +32 -3
  42. package/methodology/deep.yml +32 -3
  43. package/methodology/mvp.yml +32 -3
  44. package/package.json +2 -1
  45. package/pipeline/architecture/review-architecture.md +18 -6
  46. package/pipeline/architecture/system-architecture.md +14 -2
  47. package/pipeline/consolidation/claude-md-optimization.md +73 -0
  48. package/pipeline/consolidation/workflow-audit.md +73 -0
  49. package/pipeline/decisions/adrs.md +14 -2
  50. package/pipeline/decisions/review-adrs.md +18 -5
  51. package/pipeline/environment/ai-memory-setup.md +70 -0
  52. package/pipeline/environment/automated-pr-review.md +70 -0
  53. package/pipeline/environment/design-system.md +73 -0
  54. package/pipeline/environment/dev-env-setup.md +65 -0
  55. package/pipeline/environment/git-workflow.md +71 -0
  56. package/pipeline/finalization/apply-fixes-and-freeze.md +1 -1
  57. package/pipeline/finalization/developer-onboarding-guide.md +1 -1
  58. package/pipeline/finalization/implementation-playbook.md +3 -3
  59. package/pipeline/foundation/beads.md +68 -0
  60. package/pipeline/foundation/coding-standards.md +68 -0
  61. package/pipeline/foundation/project-structure.md +69 -0
  62. package/pipeline/foundation/tdd.md +60 -0
  63. package/pipeline/foundation/tech-stack.md +74 -0
  64. package/pipeline/integration/add-e2e-testing.md +65 -0
  65. package/pipeline/modeling/domain-modeling.md +14 -2
  66. package/pipeline/modeling/review-domain-modeling.md +18 -5
  67. package/pipeline/parity/platform-parity-review.md +70 -0
  68. package/pipeline/planning/implementation-plan-review.md +56 -0
  69. package/pipeline/planning/{implementation-tasks.md → implementation-plan.md} +29 -9
  70. package/pipeline/pre/create-prd.md +13 -4
  71. package/pipeline/pre/innovate-prd.md +37 -8
  72. package/pipeline/pre/innovate-user-stories.md +38 -7
  73. package/pipeline/pre/review-prd.md +18 -6
  74. package/pipeline/pre/review-user-stories.md +23 -6
  75. package/pipeline/pre/user-stories.md +12 -2
  76. package/pipeline/quality/create-evals.md +102 -0
  77. package/pipeline/quality/operations.md +38 -13
  78. package/pipeline/quality/review-operations.md +17 -5
  79. package/pipeline/quality/review-security.md +17 -5
  80. package/pipeline/quality/review-testing.md +20 -8
  81. package/pipeline/quality/security.md +25 -3
  82. package/pipeline/quality/story-tests.md +73 -0
  83. package/pipeline/specification/api-contracts.md +17 -2
  84. package/pipeline/specification/database-schema.md +17 -2
  85. package/pipeline/specification/review-api.md +18 -6
  86. package/pipeline/specification/review-database.md +18 -6
  87. package/pipeline/specification/review-ux.md +19 -7
  88. package/pipeline/specification/ux-spec.md +29 -10
  89. package/pipeline/validation/critical-path-walkthrough.md +34 -7
  90. package/pipeline/validation/cross-phase-consistency.md +34 -7
  91. package/pipeline/validation/decision-completeness.md +34 -7
  92. package/pipeline/validation/dependency-graph-validation.md +34 -7
  93. package/pipeline/validation/implementability-dry-run.md +34 -7
  94. package/pipeline/validation/scope-creep-check.md +34 -7
  95. package/pipeline/validation/traceability-matrix.md +34 -7
  96. package/skills/multi-model-dispatch/SKILL.md +326 -0
  97. package/skills/scaffold-pipeline/SKILL.md +195 -0
  98. package/skills/scaffold-runner/SKILL.md +465 -0
  99. package/pipeline/planning/review-tasks.md +0 -38
  100. package/pipeline/quality/testing-strategy.md +0 -42
@@ -0,0 +1,231 @@
1
+ ---
2
+ name: project-structure-patterns
3
+ description: Directory layout patterns by framework, module organization, and file placement rules
4
+ topics: [project-structure, directory-layout, module-organization, file-placement, monorepo, colocation]
5
+ ---
6
+
7
+ # Project Structure Patterns
8
+
9
+ Directory structure is the physical manifestation of architectural decisions. A well-organized project communicates its architecture through the file tree alone — a new developer should understand the system's boundaries by reading directory names. This knowledge covers core layout patterns, framework-specific conventions, and the rules that keep structures clean as projects grow.
10
+
11
+ ## Summary
12
+
13
+ ### Core Patterns
14
+
15
+ Three fundamental approaches to organizing source code:
16
+
17
+ 1. **Feature-Based (Vertical Slices)** — Group by business domain. Each feature directory contains its own components, services, tests, and types. Best for: domain-rich applications, teams organized by feature.
18
+ 2. **Layer-Based (Horizontal Layers)** — Group by technical concern. Separate directories for controllers, services, repositories, models. Best for: small projects, CRUD-heavy apps, teams organized by specialization.
19
+ 3. **Hybrid** — Feature-based at the top level, layer-based within each feature. Most common in practice. Combines domain clarity with technical organization.
20
+
21
+ ### The Co-Location Principle
22
+
23
+ Files that change together should live together. A feature's component, styles, tests, types, and utilities belong in the same directory — not scattered across `components/`, `styles/`, `tests/`, `types/`, and `utils/`. Co-location reduces the cognitive cost of changes.
24
+
25
+ ### The Shared Code Rule
26
+
27
+ Code belongs in a shared directory (`shared/`, `common/`, `lib/`) only when it has 2 or more consumers. A "shared" utility used by one feature is misplaced — it belongs in that feature's directory. Premature extraction into shared code creates coupling without benefit.
28
+
29
+ ### When to Restructure
30
+
31
+ Restructure when: navigation becomes difficult (too many files in one directory), features are tangled (changing one feature touches many directories), or onboarding developers consistently get lost. Do not restructure for aesthetic reasons or because a blog post recommended a different layout.
32
+
33
+ ### Test Placement
34
+
35
+ Co-located tests (`service.test.ts` next to `service.ts`) for unit tests — easy to find, move with refactors. Mirror directory (`tests/` mirroring `src/`) for integration and E2E tests that span modules.
36
+
37
+ ### Config vs. Application Code
38
+
39
+ Tooling config files (`tsconfig.json`, `eslint.config.js`, `Makefile`) live at project root by convention. Application config (`src/config/`) holds runtime settings (database URLs, feature flags). Never mix the two locations.
40
+
41
+ ## Deep Guidance
42
+
43
+ ### Feature-Based Structure
44
+
45
+ Feature-based organization maps directly to the product's domain model:
46
+
47
+ ```
48
+ src/
49
+ features/
50
+ auth/
51
+ components/LoginForm.tsx, LoginForm.test.tsx
52
+ hooks/useAuth.ts, useAuth.test.ts
53
+ services/auth-service.ts, auth-service.test.ts
54
+ types.ts
55
+ index.ts # public API barrel — other features import from here
56
+ billing/
57
+ components/, hooks/, services/, types.ts, index.ts
58
+ shared/
59
+ components/ # truly shared: Button, Modal, Input
60
+ hooks/ # truly shared: useDebounce, useLocalStorage
61
+ utils/ # truly shared: formatDate, validateEmail
62
+ ```
63
+
64
+ **The index.ts barrel** defines each feature's public API. Other features import from `@/features/auth`, never from internal paths. This creates explicit boundaries — internal refactoring cannot break consumers.
65
+
66
+ **When it breaks down**: Heavy cross-cutting concerns (every feature needs auth context, analytics, error boundaries). Solution: shared infrastructure lives in `shared/` or `infrastructure/`.
67
+
68
+ ### Layer-Based Structure
69
+
70
+ Layer-based organization mirrors the technical architecture:
71
+
72
+ ```
73
+ src/
74
+ controllers/auth-controller.ts, billing-controller.ts
75
+ services/auth-service.ts, billing-service.ts
76
+ repositories/user-repository.ts, invoice-repository.ts
77
+ models/user.ts, invoice.ts
78
+ middleware/auth-middleware.ts, logging-middleware.ts
79
+ ```
80
+
81
+ Clear dependency direction: controllers depend on services, services on repositories, never reverse. Breaks down beyond ~20 files per directory — that signals the need for feature grouping.
82
+
83
+ ### Framework-Specific Patterns
84
+
85
+ #### Next.js (App Router)
86
+
87
+ ```
88
+ app/
89
+ layout.tsx, page.tsx
90
+ (auth)/login/page.tsx, signup/page.tsx # route group (no URL segment)
91
+ dashboard/layout.tsx, page.tsx, settings/page.tsx
92
+ api/users/route.ts
93
+ src/features/, src/shared/
94
+ ```
95
+
96
+ Conventions: `page.tsx` defines routes, `layout.tsx` for nested layouts, `loading.tsx` for suspense, `error.tsx` for error boundaries. Route groups `(name)` organize without URL impact. Server Components default — mark `'use client'` explicitly.
97
+
98
+ #### Express / Fastify
99
+
100
+ ```
101
+ src/
102
+ routes/auth.routes.ts, index.ts # route definitions (thin)
103
+ handlers/auth.handler.ts # request/response logic
104
+ services/, repositories/, models/, middleware/
105
+ app.ts, server.ts
106
+ ```
107
+
108
+ Separate routes from handlers. Routes define paths and middleware chains. Handlers contain logic and are independently testable.
109
+
110
+ #### FastAPI
111
+
112
+ ```
113
+ src/app/
114
+ routers/auth.py, billing.py
115
+ services/, repositories/
116
+ models/ # Pydantic schemas
117
+ db/ # SQLAlchemy models
118
+ core/config.py, security.py, dependencies.py
119
+ main.py
120
+ ```
121
+
122
+ Convention: `routers/` not `routes/`. Pydantic models for API schemas, separate ORM models for database. Dependency injection via `Depends()`.
123
+
124
+ #### Go
125
+
126
+ ```
127
+ cmd/server/main.go, cli/main.go
128
+ internal/
129
+ auth/handler.go, service.go, repository.go, handler_test.go
130
+ billing/...
131
+ platform/postgres/, redis/, http/
132
+ pkg/validate/, money/
133
+ ```
134
+
135
+ Convention: `cmd/` for entry points, `internal/` for private code (compiler-enforced), `pkg/` for reusable libraries. Flat package structure preferred.
136
+
137
+ ### Monorepo Patterns
138
+
139
+ Use a monorepo when packages share types/utilities, you need atomic cross-package changes, or packages are tightly coupled. Do not use when packages are independently deployable with no shared code.
140
+
141
+ ```
142
+ packages/
143
+ web/src/, package.json
144
+ api/src/, package.json
145
+ shared/src/, package.json
146
+ config/eslint-base.js, tsconfig-base.json
147
+ package.json # workspace configuration
148
+ turbo.json # build orchestration
149
+ ```
150
+
151
+ Packages import from `@myorg/shared`, never from relative paths across package boundaries. Workspace resolution handles local development.
152
+
153
+ ### The Hybrid Pattern — Detailed Example
154
+
155
+ The hybrid approach is the most practical for medium-to-large applications. Features at the top, layers within:
156
+
157
+ ```
158
+ src/
159
+ features/
160
+ auth/
161
+ controller.ts # HTTP handler / route handler
162
+ service.ts # Business logic
163
+ repository.ts # Data access
164
+ model.ts # Domain types
165
+ service.test.ts # Unit tests co-located
166
+ controller.test.ts
167
+ billing/
168
+ controller.ts
169
+ service.ts
170
+ repository.ts
171
+ model.ts
172
+ ...
173
+ shared/
174
+ middleware/ # Cross-cutting: auth, logging, rate-limit
175
+ utils/ # Truly shared utilities (2+ consumers)
176
+ types/ # Shared type definitions
177
+ config/ # Application configuration
178
+ app.ts # Application bootstrap
179
+ server.ts # Server entry point
180
+ ```
181
+
182
+ Each feature is self-contained. Adding a new feature means creating a new directory — no changes to existing features. Deleting a feature means removing one directory (plus cleanup of any shared references).
183
+
184
+ ### Config File Placement
185
+
186
+ Config files live in the project root by universal convention: `package.json`, `tsconfig.json`, `eslint.config.js`, `pyproject.toml`, `go.mod`, `Makefile`, `Dockerfile`. Do not move them into a `config/` directory — tooling expects them at root. Application configuration (database URLs, feature flags) belongs in `src/config/`.
187
+
188
+ ### Generated File Handling
189
+
190
+ Generated files (API clients, GraphQL types, migrations) need special treatment:
191
+ - **Dedicated directory**: `src/generated/` or `__generated__/` — clearly non-hand-edited
192
+ - **Linter exclusion**: `**/generated/**` excluded from lint configs
193
+ - **Regeneration command**: `make generate` documented in CLAUDE.md
194
+ - **Git decision**: Generated-from-committed-specs can be gitignored; generated-from-external-sources should be committed
195
+
196
+ ### Entry Points and Barrel Files
197
+
198
+ **Entry points** (`main.ts`, `server.ts`, `index.ts` at project root, route files) are imported by the framework, not by other source files. Structure evals must exclude them from orphan detection.
199
+
200
+ **Barrel files** (`index.ts` in feature directories) re-export the feature's public API. Rules:
201
+ - One barrel per feature directory
202
+ - Only re-export what other features need — internal utilities stay unexported
203
+ - Never create barrel files in leaf directories (they add indirection without value)
204
+ - Avoid circular dependencies by keeping barrel imports one-directional (features import from shared, never reverse)
205
+
206
+ ### Common Anti-Patterns
207
+
208
+ **God Directories**: `src/utils/` has 47 files, `src/components/` has 93. Fix: move utilities into their consuming features. Only genuinely shared items (3+ consumers) stay in `shared/`.
209
+
210
+ **Premature Abstraction into Shared**: Creating `shared/formatCurrency.ts` "because someone might need it later." Fix: enforce the 2+ consumer rule. Code enters `shared/` only when a second consumer actually needs it.
211
+
212
+ **Inconsistent Depth**: 5-level nesting next to 2-level nesting. Fix: define maximum nesting depth (3-4 levels from `src/`). Deep nesting signals a feature should be split.
213
+
214
+ **Orphaned Files**: Files not imported by anything and not entry points, accumulated during refactors. Fix: structure evals detect orphans in CI.
215
+
216
+ ### Migration Between Structures
217
+
218
+ Moving from layer-based to feature-based (the most common migration):
219
+
220
+ 1. Create feature directories alongside existing layers
221
+ 2. Move one feature at a time — start with the most self-contained (fewest cross-feature dependencies)
222
+ 3. Update imports as you move — no redirect files
223
+ 4. Verify tests pass after each feature migration
224
+ 5. Delete empty layer directories once all features extracted
225
+ 6. Update `docs/project-structure.md`
226
+
227
+ Move one feature per PR. Each PR leaves the project working with passing tests. Five small PRs over a week is safer than one massive PR touching every file.
228
+
229
+ ## See Also
230
+
231
+ - [system-architecture](../core/system-architecture.md) — Architecture manifests in file structure
@@ -0,0 +1,247 @@
1
+ ---
2
+ name: review-step-template
3
+ description: Shared template pattern for review pipeline steps including multi-model dispatch, finding severity, and resolution workflow
4
+ topics: [review, template, multi-model, quality-gates, methodology]
5
+ ---
6
+
7
+ # Review Step Template
8
+
9
+ ## Summary
10
+
11
+ This entry documents the common structure shared by all 15+ review pipeline steps. Individual review steps customize this structure with artifact-specific failure modes and review passes, but the scaffolding is consistent across all reviews.
12
+
13
+ **Purpose pattern**: Every review step targets domain-specific failure modes for a given artifact — not generic quality checks. Each pass has a specific focus, concrete checking instructions, and example findings.
14
+
15
+ **Standard inputs**: Primary artifact being reviewed, upstream artifacts for cross-reference validation, `review-methodology` knowledge + artifact-specific review knowledge entry.
16
+
17
+ **Standard outputs**: Review document (`docs/reviews/review-{artifact}.md`), updated primary artifact with P0/P1 fixes applied, and at depth 4+: multi-model artifacts (`codex-review.json`, `gemini-review.json`, `review-summary.md`) under `docs/reviews/{artifact}/`.
18
+
19
+ **Finding severity**: P0 (blocking — must fix), P1 (significant — fix before implementation), P2 (improvement — fix if time permits), P3 (nitpick — log for later).
20
+
21
+ **Methodology scaling**: Depth 1-2 runs top passes only (P0 focus). Depth 3 runs all passes. Depth 4-5 adds multi-model dispatch to Codex/Gemini with finding synthesis.
22
+
23
+ **Mode detection**: First review runs all passes from scratch. Re-review preserves prior findings, marks resolved ones, and reports NEW/EXISTING/RESOLVED status.
24
+
25
+ **Frontmatter conventions**: Reviews are order = creation step + 10, always include `review-methodology` in knowledge-base, and are never conditional.
26
+
27
+ ## Deep Guidance
28
+
29
+ ### Purpose Pattern
30
+
31
+ Every review step follows the pattern:
32
+
33
+ > Review **[artifact]** targeting **[domain]**-specific failure modes.
34
+
35
+ The review does not check generic quality ("is this document complete?"). Instead, it runs artifact-specific passes that target the known ways that artifact type fails. Each pass has a specific focus, concrete checking instructions, and example findings.
36
+
37
+ ### Standard Inputs
38
+
39
+ Every review step reads:
40
+ - **Primary artifact**: The document being reviewed (e.g., `docs/domain-models.md`, `docs/api-contracts.md`)
41
+ - **Upstream artifacts**: Documents the primary artifact was built from (e.g., PRD, domain models, ADRs) -- used for cross-reference validation
42
+ - **Knowledge base entries**: `review-methodology` (shared process) + artifact-specific review knowledge (e.g., `review-api-design`, `review-database-design`)
43
+
44
+ ### Standard Outputs
45
+
46
+ Every review step produces:
47
+ - **Review document**: `docs/reviews/review-{artifact}.md` -- findings organized by pass, with severity and trace information
48
+ - **Updated artifact**: The primary artifact with fixes applied for P0/P1 findings
49
+ - **Depth 4+ multi-model artifacts** (when methodology depth >= 4):
50
+ - `docs/reviews/{artifact}/codex-review.json` -- Codex independent review findings
51
+ - `docs/reviews/{artifact}/gemini-review.json` -- Gemini independent review findings
52
+ - `docs/reviews/{artifact}/review-summary.md` -- Synthesized findings from all models
53
+
54
+ ### Finding Severity Levels
55
+
56
+ All review steps use the same four-level severity scale:
57
+
58
+ | Level | Name | Meaning | Action |
59
+ |-------|------|---------|--------|
60
+ | P0 | Blocking | Cannot proceed to downstream steps without fixing | Must fix before moving on |
61
+ | P1 | Significant | Downstream steps can proceed but will encounter problems | Fix before implementation |
62
+ | P2 | Improvement | Artifact works but could be better | Fix if time permits |
63
+ | P3 | Nitpick | Style or preference | Log for future cleanup |
64
+
65
+ ### Finding Format
66
+
67
+ Each finding includes:
68
+ - **Pass**: Which review pass discovered it (e.g., "Pass 3 -- Auth/AuthZ Coverage")
69
+ - **Priority**: P0-P3
70
+ - **Location**: Specific section, line, or element in the artifact
71
+ - **Issue**: What is wrong, with concrete details
72
+ - **Impact**: What goes wrong downstream if this is not fixed
73
+ - **Recommendation**: Specific fix, not just "fix this"
74
+ - **Trace**: Link back to upstream artifact that establishes the requirement (e.g., "PRD Section 3.2 -> Architecture DF-005")
75
+
76
+ ### Example Finding
77
+
78
+ ```markdown
79
+ ### Finding F-003 (P1)
80
+ - **Pass**: Pass 2 — Entity Coverage
81
+ - **Location**: docs/domain-models/order.md, Section "Order Aggregate"
82
+ - **Issue**: Order aggregate does not include a `cancellationReason` field, but PRD
83
+ Section 4.1 requires cancellation reason tracking for analytics.
84
+ - **Impact**: Implementation will lack cancellation reason; analytics pipeline will
85
+ receive null values, causing dashboard gaps.
86
+ - **Recommendation**: Add `cancellationReason: CancellationReason` value object to
87
+ Order aggregate with enum values: USER_REQUEST, PAYMENT_FAILED, OUT_OF_STOCK,
88
+ ADMIN_ACTION.
89
+ - **Trace**: PRD §4.1 → User Story US-014 → Domain Model: Order Aggregate
90
+ ```
91
+
92
+ ### Review Document Structure
93
+
94
+ Every review output document follows a consistent structure:
95
+
96
+ ```markdown
97
+ # Review: [Artifact Name]
98
+
99
+ **Date**: YYYY-MM-DD
100
+ **Methodology**: deep | mvp | custom:depth(N)
101
+ **Status**: INITIAL | RE-REVIEW
102
+ **Models**: Claude | Claude + Codex | Claude + Codex + Gemini
103
+
104
+ ## Findings Summary
105
+ - Total findings: N (P0: X, P1: Y, P2: Z, P3: W)
106
+ - Passes run: N of M
107
+ - Artifacts checked: [list]
108
+
109
+ ## Findings by Pass
110
+
111
+ ### Pass 1 — [Pass Name]
112
+ [Findings listed by severity, highest first]
113
+
114
+ ### Pass 2 — [Pass Name]
115
+ ...
116
+
117
+ ## Resolution Log
118
+ | Finding | Severity | Status | Resolution |
119
+ |---------|----------|--------|------------|
120
+ | F-001 | P0 | RESOLVED | Fixed in commit abc123 |
121
+ | F-002 | P1 | EXISTING | Deferred — tracked in ADR-015 |
122
+
123
+ ## Multi-Model Synthesis (depth 4+)
124
+ ### Convergent Findings
125
+ [Issues found by 2+ models — high confidence]
126
+
127
+ ### Divergent Findings
128
+ [Issues found by only one model — requires manual triage]
129
+ ```
130
+
131
+ ### Methodology Scaling Pattern
132
+
133
+ Review steps scale their thoroughness based on the methodology depth setting:
134
+
135
+ ### Depth 1-2 (MVP/Minimal)
136
+ - Run only the highest-impact passes (typically passes 1-3)
137
+ - Single-model review only
138
+ - Focus on P0 findings; skip P2/P3
139
+ - Abbreviated finding descriptions
140
+
141
+ ### Depth 3 (Standard)
142
+ - Run all review passes
143
+ - Single-model review
144
+ - Report all severity levels
145
+ - Full finding descriptions with trace information
146
+
147
+ ### Depth 4-5 (Comprehensive)
148
+ - Run all review passes
149
+ - Multi-model dispatch: send the artifact to Codex and Gemini for independent analysis
150
+ - Synthesize findings from all models, flagging convergent findings (multiple models found the same issue) as higher confidence
151
+ - Cross-artifact consistency checks against all upstream documents
152
+ - Full finding descriptions with detailed trace and impact analysis
153
+
154
+ ### Depth Scaling Example
155
+
156
+ At depth 2 (MVP), a domain model review might produce:
157
+
158
+ ```markdown
159
+ # Review: Domain Models (MVP)
160
+ ## Findings Summary
161
+ - Total findings: 3 (P0: 1, P1: 2)
162
+ - Passes run: 3 of 10
163
+ ## Findings
164
+ ### F-001 (P0) — Missing aggregate root for Payment bounded context
165
+ ### F-002 (P1) — Order entity lacks status field referenced in user stories
166
+ ### F-003 (P1) — No domain event defined for order completion
167
+ ```
168
+
169
+ At depth 5 (comprehensive), the same review would run all 10 passes, dispatch to
170
+ Codex and Gemini, and produce a full synthesis with 15-30 findings across all
171
+ severity levels.
172
+
173
+ ### Mode Detection Pattern
174
+
175
+ Every review step checks whether this is a first review or a re-review:
176
+
177
+ **First review**: No prior review document exists. Run all passes from scratch.
178
+
179
+ **Re-review**: A prior review document exists (`docs/reviews/review-{artifact}.md`). The step:
180
+ 1. Reads the prior review findings
181
+ 2. Checks which findings were addressed (fixed in the artifact)
182
+ 3. Marks resolved findings as "RESOLVED" rather than removing them
183
+ 4. Runs all passes again looking for new issues or regressions
184
+ 5. Reports findings as "NEW", "EXISTING" (still unfixed), or "RESOLVED"
185
+
186
+ This preserves review history and makes progress visible.
187
+
188
+ ### Resolution Workflow
189
+
190
+ The standard workflow from review to resolution:
191
+
192
+ 1. **Review**: Run the review step, producing findings
193
+ 2. **Triage**: Categorize findings by severity; confirm P0s are genuine blockers
194
+ 3. **Fix**: Update the primary artifact to address P0 and P1 findings
195
+ 4. **Re-review**: Run the review step again in re-review mode
196
+ 5. **Verify**: Confirm all P0 findings are resolved; P1 findings are resolved or have documented justification for deferral
197
+ 6. **Proceed**: Move to the next pipeline phase
198
+
199
+ For depth 4+ reviews, the multi-model dispatch happens in both the initial review and the re-review, ensuring fixes do not introduce new issues visible to other models.
200
+
201
+ ### Frontmatter Pattern
202
+
203
+ Review steps follow a consistent frontmatter structure:
204
+
205
+ ```yaml
206
+ ---
207
+ name: review-{artifact}
208
+ description: "Review {artifact} for completeness, consistency, and downstream readiness"
209
+ phase: "{phase-slug}"
210
+ order: {N}20 # Reviews are always 10 after their creation step
211
+ dependencies: [{creation-step}]
212
+ outputs: [docs/reviews/review-{artifact}.md, docs/reviews/{artifact}/review-summary.md, docs/reviews/{artifact}/codex-review.json, docs/reviews/{artifact}/gemini-review.json]
213
+ conditional: null
214
+ knowledge-base: [review-methodology, review-{artifact-domain}]
215
+ ---
216
+ ```
217
+
218
+ Key conventions:
219
+ - Review steps always have order = creation step order + 10
220
+ - Primary output uses `review-` prefix; multi-model directory uses bare artifact name
221
+ - Knowledge base always includes `review-methodology` plus a domain-specific entry
222
+ - Reviews are never conditional — if the creation step ran, the review runs
223
+
224
+ ### Common Anti-Patterns
225
+
226
+ ### Reviewing Without Upstream Context
227
+ Running a review without loading the upstream artifacts that define requirements.
228
+ The review cannot verify traceability if it does not have the PRD, domain models,
229
+ or ADRs that establish what the artifact should contain.
230
+
231
+ ### Severity Inflation
232
+ Marking everything as P0 to force immediate action. This undermines the severity
233
+ system and causes triage fatigue. Reserve P0 for genuine blockers where downstream
234
+ steps will fail or produce incorrect output.
235
+
236
+ ### Fix Without Re-Review
237
+ Applying fixes to findings without re-running the review. Fixes can introduce new
238
+ issues or incompletely address the original finding. Always re-review after fixes.
239
+
240
+ ### Ignoring Convergent Multi-Model Findings
241
+ When multiple models independently find the same issue, it has high confidence.
242
+ Dismissing convergent findings without strong justification undermines the value
243
+ of multi-model review.
244
+
245
+ ### Removing Prior Findings
246
+ Deleting findings from a re-review output instead of marking them RESOLVED. This
247
+ loses review history and makes it impossible to track what was caught and fixed.
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: security-review
2
+ name: security-best-practices
3
3
  description: OWASP Top 10, authentication, authorization, data protection, and threat modeling
4
4
  topics: [security, owasp, authentication, authorization, threat-modeling, secrets-management, dependency-auditing]
5
5
  ---
@@ -521,3 +521,7 @@ Protect against compromised dependencies:
521
521
  **No rate limiting.** Login endpoints with unlimited attempts allow brute-force password attacks. API endpoints with no rate limits allow denial of service. Fix: implement rate limiting on all public endpoints. Start with conservative limits. Use exponential backoff for authentication failures.
522
522
 
523
523
  **Ignoring dependency vulnerabilities.** Running `npm audit` shows 47 vulnerabilities but nobody addresses them because "they're all low severity." Fix: set a policy and enforce it in CI. Critical and high vulnerabilities block deployment. Medium vulnerabilities have a SLA for resolution.
524
+
525
+ ## See Also
526
+
527
+ - [operations-runbook](../core/operations-runbook.md) — Logging and monitoring sensitive data