@zigrivers/scaffold 2.1.2 → 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.
- package/README.md +272 -59
- package/knowledge/core/adr-craft.md +53 -0
- package/knowledge/core/ai-memory-management.md +246 -0
- package/knowledge/core/api-design.md +4 -0
- package/knowledge/core/claude-md-patterns.md +254 -0
- package/knowledge/core/coding-conventions.md +246 -0
- package/knowledge/core/database-design.md +4 -0
- package/knowledge/core/design-system-tokens.md +465 -0
- package/knowledge/core/dev-environment.md +223 -0
- package/knowledge/core/domain-modeling.md +4 -0
- package/knowledge/core/eval-craft.md +1008 -0
- package/knowledge/core/multi-model-review-dispatch.md +250 -0
- package/knowledge/core/operations-runbook.md +37 -226
- package/knowledge/core/project-structure-patterns.md +231 -0
- package/knowledge/core/review-step-template.md +247 -0
- package/knowledge/core/{security-review.md → security-best-practices.md} +5 -1
- package/knowledge/core/task-decomposition.md +57 -34
- package/knowledge/core/task-tracking.md +225 -0
- package/knowledge/core/tech-stack-selection.md +214 -0
- package/knowledge/core/testing-strategy.md +63 -70
- package/knowledge/core/user-stories.md +69 -60
- package/knowledge/core/user-story-innovation.md +57 -0
- package/knowledge/core/ux-specification.md +5 -148
- package/knowledge/finalization/apply-fixes-and-freeze.md +165 -14
- package/knowledge/product/prd-craft.md +55 -34
- package/knowledge/review/review-adr.md +32 -0
- package/knowledge/review/{review-api-contracts.md → review-api-design.md} +34 -1
- package/knowledge/review/{review-database-schema.md → review-database-design.md} +27 -1
- package/knowledge/review/review-domain-modeling.md +33 -0
- package/knowledge/review/review-implementation-tasks.md +50 -0
- package/knowledge/review/review-operations.md +55 -0
- package/knowledge/review/review-prd.md +33 -0
- package/knowledge/review/review-security.md +53 -0
- package/knowledge/review/review-system-architecture.md +28 -0
- package/knowledge/review/review-testing-strategy.md +51 -0
- package/knowledge/review/review-user-stories.md +54 -0
- package/knowledge/review/{review-ux-spec.md → review-ux-specification.md} +37 -1
- package/methodology/custom-defaults.yml +32 -3
- package/methodology/deep.yml +32 -3
- package/methodology/mvp.yml +32 -3
- package/package.json +2 -1
- package/pipeline/architecture/review-architecture.md +18 -6
- package/pipeline/architecture/system-architecture.md +14 -2
- package/pipeline/consolidation/claude-md-optimization.md +73 -0
- package/pipeline/consolidation/workflow-audit.md +73 -0
- package/pipeline/decisions/adrs.md +14 -2
- package/pipeline/decisions/review-adrs.md +18 -5
- package/pipeline/environment/ai-memory-setup.md +70 -0
- package/pipeline/environment/automated-pr-review.md +70 -0
- package/pipeline/environment/design-system.md +73 -0
- package/pipeline/environment/dev-env-setup.md +65 -0
- package/pipeline/environment/git-workflow.md +71 -0
- package/pipeline/finalization/apply-fixes-and-freeze.md +1 -1
- package/pipeline/finalization/developer-onboarding-guide.md +1 -1
- package/pipeline/finalization/implementation-playbook.md +3 -3
- package/pipeline/foundation/beads.md +68 -0
- package/pipeline/foundation/coding-standards.md +68 -0
- package/pipeline/foundation/project-structure.md +69 -0
- package/pipeline/foundation/tdd.md +60 -0
- package/pipeline/foundation/tech-stack.md +74 -0
- package/pipeline/integration/add-e2e-testing.md +65 -0
- package/pipeline/modeling/domain-modeling.md +14 -2
- package/pipeline/modeling/review-domain-modeling.md +18 -5
- package/pipeline/parity/platform-parity-review.md +70 -0
- package/pipeline/planning/implementation-plan-review.md +56 -0
- package/pipeline/planning/{implementation-tasks.md → implementation-plan.md} +29 -9
- package/pipeline/pre/create-prd.md +13 -4
- package/pipeline/pre/innovate-prd.md +37 -8
- package/pipeline/pre/innovate-user-stories.md +38 -7
- package/pipeline/pre/review-prd.md +18 -6
- package/pipeline/pre/review-user-stories.md +23 -6
- package/pipeline/pre/user-stories.md +12 -2
- package/pipeline/quality/create-evals.md +102 -0
- package/pipeline/quality/operations.md +38 -13
- package/pipeline/quality/review-operations.md +17 -5
- package/pipeline/quality/review-security.md +17 -5
- package/pipeline/quality/review-testing.md +20 -8
- package/pipeline/quality/security.md +25 -3
- package/pipeline/quality/story-tests.md +73 -0
- package/pipeline/specification/api-contracts.md +17 -2
- package/pipeline/specification/database-schema.md +17 -2
- package/pipeline/specification/review-api.md +18 -6
- package/pipeline/specification/review-database.md +18 -6
- package/pipeline/specification/review-ux.md +19 -7
- package/pipeline/specification/ux-spec.md +29 -10
- package/pipeline/validation/critical-path-walkthrough.md +34 -7
- package/pipeline/validation/cross-phase-consistency.md +34 -7
- package/pipeline/validation/decision-completeness.md +34 -7
- package/pipeline/validation/dependency-graph-validation.md +34 -7
- package/pipeline/validation/implementability-dry-run.md +34 -7
- package/pipeline/validation/scope-creep-check.md +34 -7
- package/pipeline/validation/traceability-matrix.md +34 -7
- package/skills/multi-model-dispatch/SKILL.md +326 -0
- package/skills/scaffold-pipeline/SKILL.md +195 -0
- package/skills/scaffold-runner/SKILL.md +465 -0
- package/pipeline/planning/review-tasks.md +0 -38
- package/pipeline/quality/testing-strategy.md +0 -42
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: multi-model-review-dispatch
|
|
3
|
+
description: Patterns for dispatching reviews to external AI models (Codex, Gemini) at depth 4+, including fallback strategies and finding reconciliation
|
|
4
|
+
topics: [multi-model, code-review, depth-scaling, codex, gemini, review-synthesis]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Multi-Model Review Dispatch
|
|
8
|
+
|
|
9
|
+
At higher methodology depths (4+), reviews benefit from independent validation by external AI models. Different models have different blind spots — Codex excels at code-centric analysis while Gemini brings strength in design and architectural reasoning. Dispatching to multiple models and reconciling their findings produces higher-quality reviews than any single model alone. This knowledge covers when to dispatch, how to dispatch, how to handle failures, and how to reconcile disagreements.
|
|
10
|
+
|
|
11
|
+
## Summary
|
|
12
|
+
|
|
13
|
+
### When to Dispatch
|
|
14
|
+
|
|
15
|
+
Multi-model review activates at depth 4+ in the methodology scaling system:
|
|
16
|
+
|
|
17
|
+
| Depth | Review Approach |
|
|
18
|
+
|-------|----------------|
|
|
19
|
+
| 1-2 | Claude-only, reduced pass count |
|
|
20
|
+
| 3 | Claude-only, full pass count |
|
|
21
|
+
| 4 | Full passes + one external model (if available) |
|
|
22
|
+
| 5 | Full passes + multi-model with reconciliation |
|
|
23
|
+
|
|
24
|
+
Dispatch is always optional. If no external model CLI is available, the review proceeds as a Claude-only enhanced review with additional self-review passes to partially compensate.
|
|
25
|
+
|
|
26
|
+
### Model Selection
|
|
27
|
+
|
|
28
|
+
| Model | Strength | Best For |
|
|
29
|
+
|-------|----------|----------|
|
|
30
|
+
| **Codex** (OpenAI) | Code analysis, implementation correctness, API contract validation | Code reviews, security reviews, API reviews, database schema reviews |
|
|
31
|
+
| **Gemini** (Google) | Design reasoning, architectural patterns, broad context understanding | Architecture reviews, PRD reviews, UX reviews, domain model reviews |
|
|
32
|
+
|
|
33
|
+
When both models are available at depth 5, dispatch to both and reconcile. At depth 4, choose the model best suited to the artifact type.
|
|
34
|
+
|
|
35
|
+
### Graceful Fallback
|
|
36
|
+
|
|
37
|
+
External models are never required. The fallback chain:
|
|
38
|
+
1. Attempt dispatch to selected model(s)
|
|
39
|
+
2. If CLI unavailable → skip that model, note in report
|
|
40
|
+
3. If timeout → use partial results if any, note incompleteness
|
|
41
|
+
4. If all external models fail → Claude-only enhanced review (additional self-review passes)
|
|
42
|
+
|
|
43
|
+
The review never blocks on external model availability.
|
|
44
|
+
|
|
45
|
+
## Deep Guidance
|
|
46
|
+
|
|
47
|
+
### Dispatch Mechanics
|
|
48
|
+
|
|
49
|
+
#### CLI Availability Check
|
|
50
|
+
|
|
51
|
+
Before dispatching, verify the model CLI is installed and authenticated:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Codex check
|
|
55
|
+
which codex && codex --version 2>/dev/null
|
|
56
|
+
|
|
57
|
+
# Gemini check (via Google Cloud CLI or dedicated tool)
|
|
58
|
+
which gemini 2>/dev/null || (which gcloud && gcloud ai models list 2>/dev/null)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
If the CLI is not found, skip dispatch immediately. Do not prompt the user to install it — this is a review enhancement, not a requirement.
|
|
62
|
+
|
|
63
|
+
#### Prompt Formatting
|
|
64
|
+
|
|
65
|
+
External model prompts must be self-contained. The external model has no access to the pipeline context, CLAUDE.md, or prior conversation. Every dispatch includes:
|
|
66
|
+
|
|
67
|
+
1. **Artifact content** — The full text of the document being reviewed
|
|
68
|
+
2. **Review focus** — What specific aspects to evaluate (coverage, consistency, correctness)
|
|
69
|
+
3. **Upstream context** — Relevant upstream artifacts that the document should be consistent with
|
|
70
|
+
4. **Output format** — Structured JSON for machine-parseable findings
|
|
71
|
+
|
|
72
|
+
**Prompt template:**
|
|
73
|
+
```
|
|
74
|
+
You are reviewing the following [artifact type] for a software project.
|
|
75
|
+
|
|
76
|
+
## Document Under Review
|
|
77
|
+
[full artifact content]
|
|
78
|
+
|
|
79
|
+
## Upstream Context
|
|
80
|
+
[relevant upstream artifacts, summarized or in full]
|
|
81
|
+
|
|
82
|
+
## Review Instructions
|
|
83
|
+
Evaluate this document for:
|
|
84
|
+
1. Coverage — Are all expected topics addressed?
|
|
85
|
+
2. Consistency — Does it agree with the upstream context?
|
|
86
|
+
3. Correctness — Are technical claims accurate?
|
|
87
|
+
4. Completeness — Are there gaps that would block downstream work?
|
|
88
|
+
|
|
89
|
+
## Output Format
|
|
90
|
+
Respond with a JSON array of findings:
|
|
91
|
+
[
|
|
92
|
+
{
|
|
93
|
+
"id": "F-001",
|
|
94
|
+
"severity": "P0|P1|P2|P3",
|
|
95
|
+
"category": "coverage|consistency|correctness|completeness",
|
|
96
|
+
"location": "section or line reference",
|
|
97
|
+
"finding": "description of the issue",
|
|
98
|
+
"suggestion": "recommended fix"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Output Parsing
|
|
104
|
+
|
|
105
|
+
External model output is parsed as JSON. Handle common parsing issues:
|
|
106
|
+
- Strip markdown code fences (```json ... ```) if the model wraps output
|
|
107
|
+
- Handle trailing commas in JSON arrays
|
|
108
|
+
- Validate that each finding has the required fields (severity, category, finding)
|
|
109
|
+
- Discard malformed entries rather than failing the entire parse
|
|
110
|
+
|
|
111
|
+
Store raw output for audit:
|
|
112
|
+
```
|
|
113
|
+
docs/reviews/{artifact}/codex-review.json — raw Codex findings
|
|
114
|
+
docs/reviews/{artifact}/gemini-review.json — raw Gemini findings
|
|
115
|
+
docs/reviews/{artifact}/review-summary.md — reconciled synthesis
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Timeout Handling
|
|
119
|
+
|
|
120
|
+
External model calls can hang or take unreasonably long. Set reasonable timeouts:
|
|
121
|
+
|
|
122
|
+
| Operation | Timeout | Rationale |
|
|
123
|
+
|-----------|---------|-----------|
|
|
124
|
+
| CLI availability check | 5 seconds | Should be instant |
|
|
125
|
+
| Small artifact review (<2000 words) | 60 seconds | Quick read and analysis |
|
|
126
|
+
| Medium artifact review (2000-10000 words) | 120 seconds | Needs more processing time |
|
|
127
|
+
| Large artifact review (>10000 words) | 180 seconds | Maximum reasonable wait |
|
|
128
|
+
|
|
129
|
+
#### Partial Result Handling
|
|
130
|
+
|
|
131
|
+
If a timeout occurs mid-response:
|
|
132
|
+
1. Check if the partial output contains valid JSON entries
|
|
133
|
+
2. If yes, use the valid entries and note "partial results" in the report
|
|
134
|
+
3. If no, treat as a model failure and fall back
|
|
135
|
+
|
|
136
|
+
Never wait indefinitely. A review that completes in 3 minutes with Claude-only findings is better than one that blocks for 10 minutes waiting for an external model.
|
|
137
|
+
|
|
138
|
+
### Finding Reconciliation
|
|
139
|
+
|
|
140
|
+
When multiple models produce findings, reconciliation synthesizes them into a unified report.
|
|
141
|
+
|
|
142
|
+
#### Consensus Analysis
|
|
143
|
+
|
|
144
|
+
Compare findings across models to identify agreement and disagreement:
|
|
145
|
+
|
|
146
|
+
**Consensus** — Multiple models flag the same issue (possibly with different wording). High confidence in the finding. Use the most specific description.
|
|
147
|
+
|
|
148
|
+
**Single-source finding** — Only one model flags an issue. Lower confidence but still valuable. Include in the report with a note about which model found it.
|
|
149
|
+
|
|
150
|
+
**Disagreement** — One model flags an issue that another model explicitly considers correct. Requires manual analysis.
|
|
151
|
+
|
|
152
|
+
#### Reconciliation Process
|
|
153
|
+
|
|
154
|
+
1. **Normalize findings.** Map each model's findings to a common schema (severity, category, location, description).
|
|
155
|
+
|
|
156
|
+
2. **Match findings across models.** Two findings match if they reference the same location and describe the same underlying issue (even with different wording). Use location + category as the matching key.
|
|
157
|
+
|
|
158
|
+
3. **Score by consensus.**
|
|
159
|
+
- Found by all models → confidence: high
|
|
160
|
+
- Found by majority → confidence: medium
|
|
161
|
+
- Found by one model → confidence: low (but still reported)
|
|
162
|
+
|
|
163
|
+
4. **Resolve severity disagreements.** When models disagree on severity:
|
|
164
|
+
- If one says P0 and another says P1 → use P0 (err on the side of caution)
|
|
165
|
+
- If one says P1 and another says P3 → investigate the specific finding before deciding
|
|
166
|
+
- Document the disagreement in the synthesis report
|
|
167
|
+
|
|
168
|
+
5. **Merge descriptions.** When multiple models describe the same finding differently, combine their perspectives. Model A might identify the symptom while Model B identifies the root cause.
|
|
169
|
+
|
|
170
|
+
#### Disagreement Resolution
|
|
171
|
+
|
|
172
|
+
When models actively disagree (one flags an issue, another says the same thing is correct):
|
|
173
|
+
|
|
174
|
+
1. **Read both arguments.** Each model explains its reasoning. One may have a factual error.
|
|
175
|
+
2. **Check against source material.** Read the actual artifact and upstream docs. The correct answer is in the documents, not in model opinions.
|
|
176
|
+
3. **Default to the stricter interpretation.** If genuinely ambiguous, the finding stands at reduced severity (P1 → P2).
|
|
177
|
+
4. **Document the disagreement.** The reconciliation report should note: "Models disagreed on [topic]. Resolution: [decision and rationale]."
|
|
178
|
+
|
|
179
|
+
### Output Format
|
|
180
|
+
|
|
181
|
+
#### Review Summary (review-summary.md)
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
# Multi-Model Review Summary: [Artifact Name]
|
|
185
|
+
|
|
186
|
+
## Models Used
|
|
187
|
+
- Claude (primary reviewer)
|
|
188
|
+
- Codex (external, depth 4+) — [available/unavailable/timeout]
|
|
189
|
+
- Gemini (external, depth 5) — [available/unavailable/timeout]
|
|
190
|
+
|
|
191
|
+
## Consensus Findings
|
|
192
|
+
| # | Severity | Finding | Models | Confidence |
|
|
193
|
+
|---|----------|---------|--------|------------|
|
|
194
|
+
| 1 | P0 | [description] | Claude, Codex | High |
|
|
195
|
+
| 2 | P1 | [description] | Claude, Codex, Gemini | High |
|
|
196
|
+
|
|
197
|
+
## Single-Source Findings
|
|
198
|
+
| # | Severity | Finding | Source | Confidence |
|
|
199
|
+
|---|----------|---------|--------|------------|
|
|
200
|
+
| 3 | P1 | [description] | Gemini | Low |
|
|
201
|
+
|
|
202
|
+
## Disagreements
|
|
203
|
+
| # | Topic | Claude | Codex | Resolution |
|
|
204
|
+
|---|-------|--------|-------|------------|
|
|
205
|
+
| 4 | [topic] | P1 issue | No issue | [resolution rationale] |
|
|
206
|
+
|
|
207
|
+
## Reconciliation Notes
|
|
208
|
+
[Any significant observations about model agreement patterns, recurring themes,
|
|
209
|
+
or areas where external models provided unique value]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### Raw JSON Preservation
|
|
213
|
+
|
|
214
|
+
Always preserve the raw JSON output from external models, even after reconciliation. The raw findings serve as an audit trail and enable re-analysis if the reconciliation logic is later improved.
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
docs/reviews/{artifact}/
|
|
218
|
+
codex-review.json — raw output from Codex
|
|
219
|
+
gemini-review.json — raw output from Gemini
|
|
220
|
+
review-summary.md — reconciled synthesis
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Quality Gates
|
|
224
|
+
|
|
225
|
+
Minimum standards for a multi-model review to be considered complete:
|
|
226
|
+
|
|
227
|
+
| Gate | Threshold | Rationale |
|
|
228
|
+
|------|-----------|-----------|
|
|
229
|
+
| Minimum finding count | At least 3 findings across all models | A review with zero findings likely missed something |
|
|
230
|
+
| Coverage threshold | Every review pass has at least one finding or explicit "no issues found" note | Ensures all passes were actually executed |
|
|
231
|
+
| Reconciliation completeness | All cross-model disagreements have documented resolutions | No unresolved conflicts |
|
|
232
|
+
| Raw output preserved | JSON files exist for all models that were dispatched | Audit trail |
|
|
233
|
+
|
|
234
|
+
If the primary Claude review produces zero findings and external models are unavailable, the review should explicitly note this as unusual and recommend a targeted re-review at a later stage.
|
|
235
|
+
|
|
236
|
+
### Common Anti-Patterns
|
|
237
|
+
|
|
238
|
+
**Blind trust of external findings.** An external model flags an issue and the reviewer includes it without verification. External models hallucinate — they may flag a "missing section" that actually exists, or cite a "contradiction" based on a misread. Fix: every external finding must be verified against the actual artifact before inclusion in the final report.
|
|
239
|
+
|
|
240
|
+
**Ignoring disagreements.** Two models disagree, and the reviewer picks one without analysis. Fix: disagreements are the most valuable signal in multi-model review. They identify areas of genuine ambiguity or complexity. Always investigate and document the resolution.
|
|
241
|
+
|
|
242
|
+
**Dispatching at low depth.** Running external model reviews at depth 1-2 where the review scope is intentionally minimal. The external model does a full analysis anyway, producing findings that are out of scope. Fix: only dispatch at depth 4+. Lower depths use Claude-only review with reduced pass count.
|
|
243
|
+
|
|
244
|
+
**No fallback plan.** The review pipeline assumes external models are always available. When Codex is down, the review fails entirely. Fix: external dispatch is always optional. The fallback to Claude-only enhanced review must be implemented and tested.
|
|
245
|
+
|
|
246
|
+
**Over-weighting consensus.** Two models agree on a finding, so it must be correct. But both models may share the same bias (e.g., both flag a pattern as an anti-pattern that is actually appropriate for this project's constraints). Fix: consensus increases confidence but does not guarantee correctness. All findings still require artifact-level verification.
|
|
247
|
+
|
|
248
|
+
**Dispatching the full pipeline context.** Sending the entire project context (all docs, all code) to the external model. This exceeds context limits and dilutes focus. Fix: send only the artifact under review and the minimal upstream context needed for that specific review.
|
|
249
|
+
|
|
250
|
+
**Ignoring partial results.** A model times out after producing 3 of 5 findings. The reviewer discards all results because the review is "incomplete." Fix: partial results are still valuable. Include them with a note about incompleteness. Three real findings are better than zero.
|
|
@@ -1,257 +1,70 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: operations-runbook
|
|
3
|
-
description:
|
|
4
|
-
topics: [operations, cicd, deployment, monitoring,
|
|
3
|
+
description: Deployment pipeline, deployment strategies, monitoring, alerting, and incident response
|
|
4
|
+
topics: [operations, cicd, deployment, monitoring, incident-response, alerting, rollback]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## Dev Environment
|
|
7
|
+
## Dev Environment Reference
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Local development setup (prerequisites, env vars, one-command setup, database, hot reload, common commands, troubleshooting) is defined in `docs/dev-setup.md`, created by the Dev Setup prompt. The operations runbook should reference it rather than redefine it.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
**Operations-specific additions** (not covered by dev-setup):
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Environment-Specific Configuration
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|------------|---------|-----|
|
|
17
|
-
| Node.js | 20.x LTS | Runtime |
|
|
18
|
-
| Python | 3.12+ | Backend scripts |
|
|
19
|
-
| PostgreSQL | 16+ | Primary database |
|
|
20
|
-
| Redis | 7+ | Caching and sessions |
|
|
21
|
-
| Docker | 24+ | Database containers (optional) |
|
|
15
|
+
Document how environment variables differ across environments:
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
| Variable | Local | Staging | Production |
|
|
18
|
+
|----------|-------|---------|------------|
|
|
19
|
+
| `APP_ENV` | development | staging | production |
|
|
20
|
+
| `DATABASE_URL` | localhost | staging-db-host | prod-db-host |
|
|
21
|
+
| `LOG_LEVEL` | debug | info | warn |
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
### Secrets Management
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
Production secrets should never be in code or `.env` files:
|
|
26
|
+
- Use a secrets manager (AWS Secrets Manager, GCP Secret Manager, Vault, Doppler)
|
|
27
|
+
- Rotate secrets on a schedule (90 days for API keys, 365 days for service accounts)
|
|
28
|
+
- Audit access to secrets
|
|
29
|
+
- Document which secrets exist, where they're stored, and who can access them
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
## Deployment Pipeline
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Application
|
|
38
|
-
APP_PORT=3000 # Port for the dev server
|
|
39
|
-
APP_ENV=development # development | staging | production
|
|
40
|
-
APP_URL=http://localhost:3000 # Base URL for the app
|
|
41
|
-
|
|
42
|
-
# Database
|
|
43
|
-
DATABASE_URL=postgresql://localhost:5432/myapp_dev # Local PostgreSQL
|
|
44
|
-
DATABASE_POOL_SIZE=5 # Connection pool size
|
|
45
|
-
|
|
46
|
-
# Authentication
|
|
47
|
-
JWT_SECRET=local-dev-secret-change-in-production # JWT signing key
|
|
48
|
-
SESSION_SECRET=local-session-secret # Session cookie secret
|
|
49
|
-
|
|
50
|
-
# External Services (optional for local dev)
|
|
51
|
-
# STRIPE_SECRET_KEY=sk_test_... # Uncomment when testing payments
|
|
52
|
-
# SENDGRID_API_KEY=SG.... # Uncomment when testing emails
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**`.env`** — Actual local configuration, gitignored. Created by copying `.env.example`.
|
|
56
|
-
|
|
57
|
-
**Required vs. optional:** Clearly mark which variables are required for the app to start and which are optional (features degrade gracefully without them).
|
|
58
|
-
|
|
59
|
-
### One-Command Setup
|
|
60
|
-
|
|
61
|
-
Provide a single command that installs all dependencies, creates the database, runs migrations, seeds data, and starts the dev server:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# First time setup
|
|
65
|
-
make setup # or: npm run setup
|
|
66
|
-
|
|
67
|
-
# Daily development
|
|
68
|
-
make dev # or: npm run dev
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The setup command should be idempotent — safe to run twice without breaking anything.
|
|
72
|
-
|
|
73
|
-
### Database Setup for Local Development
|
|
74
|
-
|
|
75
|
-
**Option A: Local installation**
|
|
76
|
-
- Install database server natively
|
|
77
|
-
- Create dev database: `createdb myapp_dev` (PostgreSQL)
|
|
78
|
-
- Run migrations: `make db-migrate`
|
|
79
|
-
- Seed data: `make db-seed`
|
|
80
|
-
|
|
81
|
-
**Option B: Docker Compose**
|
|
82
|
-
```yaml
|
|
83
|
-
services:
|
|
84
|
-
db:
|
|
85
|
-
image: postgres:16
|
|
86
|
-
ports: ["5432:5432"]
|
|
87
|
-
environment:
|
|
88
|
-
POSTGRES_DB: myapp_dev
|
|
89
|
-
POSTGRES_USER: postgres
|
|
90
|
-
POSTGRES_PASSWORD: postgres
|
|
91
|
-
volumes:
|
|
92
|
-
- pgdata:/var/lib/postgresql/data
|
|
93
|
-
|
|
94
|
-
redis:
|
|
95
|
-
image: redis:7
|
|
96
|
-
ports: ["6379:6379"]
|
|
97
|
-
|
|
98
|
-
volumes:
|
|
99
|
-
pgdata:
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Docker Compose is convenient for managing service dependencies but adds startup time and complexity. For simple stacks (SQLite, single service), skip Docker entirely.
|
|
103
|
-
|
|
104
|
-
**Option C: SQLite for development**
|
|
105
|
-
- No setup required
|
|
106
|
-
- Create database file on first run
|
|
107
|
-
- Fast, zero-configuration
|
|
108
|
-
- Trade-off: behavior differences from production PostgreSQL (no JSONB, different SQL dialect)
|
|
109
|
-
|
|
110
|
-
### Hot Reloading Configuration
|
|
111
|
-
|
|
112
|
-
The dev server must reload automatically when code changes:
|
|
113
|
-
|
|
114
|
-
- **Frontend:** Vite HMR (React, Vue, Svelte), Next.js Fast Refresh, or webpack HMR
|
|
115
|
-
- **Backend (Node.js):** `tsx watch`, `nodemon`, or `ts-node-dev` for TypeScript; `node --watch` for plain Node
|
|
116
|
-
- **Backend (Python):** `uvicorn --reload` (FastAPI), `flask run --debug` (Flask), `manage.py runserver` (Django)
|
|
117
|
-
- **Full-stack:** Run frontend and backend concurrently with a process manager (`concurrently`, `honcho`, or Makefile with `&`)
|
|
118
|
-
|
|
119
|
-
### Common Dev Commands
|
|
120
|
-
|
|
121
|
-
Every project should have a consistent set of commands. Use whatever mechanism fits the stack:
|
|
122
|
-
|
|
123
|
-
| Command | Purpose | Implementation |
|
|
124
|
-
|---------|---------|---------------|
|
|
125
|
-
| `make dev` | Start dev server with hot reload | Frontend + backend concurrently |
|
|
126
|
-
| `make test` | Run all tests | Test runner with coverage |
|
|
127
|
-
| `make test-watch` | Run tests in watch mode | Test runner in watch mode |
|
|
128
|
-
| `make lint` | Check code style | Linter for each language |
|
|
129
|
-
| `make format` | Auto-fix formatting | Formatter for each language |
|
|
130
|
-
| `make db-migrate` | Run pending migrations | Migration tool |
|
|
131
|
-
| `make db-seed` | Seed database with sample data | Seed script |
|
|
132
|
-
| `make db-reset` | Drop, recreate, migrate, seed | Compose the above |
|
|
133
|
-
| `make check` | Run all quality gates | lint + type-check + test |
|
|
134
|
-
|
|
135
|
-
Commands should be:
|
|
136
|
-
- Short and memorable (not `npx jest --runInBand --coverage --passWithNoTests`)
|
|
137
|
-
- Documented with help text
|
|
138
|
-
- Idempotent where possible
|
|
139
|
-
- Fast enough to run frequently
|
|
140
|
-
|
|
141
|
-
### Troubleshooting Guide
|
|
142
|
-
|
|
143
|
-
Document solutions for common development issues:
|
|
144
|
-
|
|
145
|
-
**Port already in use:**
|
|
146
|
-
```bash
|
|
147
|
-
lsof -i :3000 # Find the process
|
|
148
|
-
kill -9 <PID> # Kill it
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
**Database connection refused:**
|
|
152
|
-
- Is the database running? `pg_isready` or `docker ps`
|
|
153
|
-
- Is the connection string correct? Check `.env`
|
|
154
|
-
- Is the port correct? Check for port conflicts
|
|
155
|
-
|
|
156
|
-
**Dependencies out of sync:**
|
|
157
|
-
```bash
|
|
158
|
-
rm -rf node_modules && npm install # Node.js
|
|
159
|
-
rm -rf .venv && python -m venv .venv && pip install -r requirements.txt # Python
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**Migrations out of date:**
|
|
163
|
-
```bash
|
|
164
|
-
make db-migrate # Run pending migrations
|
|
165
|
-
make db-reset # Nuclear option: start fresh
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## CI/CD Pipeline
|
|
33
|
+
The base CI pipeline (lint + test on PRs) is configured by the Git Workflow prompt in `.github/workflows/ci.yml`. The operations runbook extends this with production deployment stages — it does not redefine the base CI.
|
|
169
34
|
|
|
170
35
|
### Pipeline Architecture
|
|
171
36
|
|
|
172
|
-
A CI/CD pipeline automates the path from code commit to production deployment. Design it in stages:
|
|
173
|
-
|
|
174
37
|
```
|
|
175
|
-
|
|
176
|
-
-> Stage 1: Fast checks (30s)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
-> Stage 3: Build (1-2 min)
|
|
181
|
-
|
|
182
|
-
-> Stage
|
|
183
|
-
Deploy to staging/production
|
|
184
|
-
|
|
185
|
-
PR merge to main
|
|
186
|
-
-> All stages above
|
|
187
|
-
-> Stage 5: Post-deploy verification
|
|
188
|
-
Smoke tests against deployed environment
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Stage Design
|
|
192
|
-
|
|
193
|
-
**Stage 1: Fast Checks**
|
|
194
|
-
- Run on every push and PR
|
|
195
|
-
- Fail fast: if linting fails, don't bother running tests
|
|
196
|
-
- Cache dependencies between runs
|
|
197
|
-
- Target: <30 seconds
|
|
198
|
-
|
|
199
|
-
```yaml
|
|
200
|
-
# GitHub Actions example
|
|
201
|
-
lint:
|
|
202
|
-
runs-on: ubuntu-latest
|
|
203
|
-
steps:
|
|
204
|
-
- uses: actions/checkout@v4
|
|
205
|
-
- uses: actions/setup-node@v4
|
|
206
|
-
with: { node-version-file: '.nvmrc' }
|
|
207
|
-
- run: npm ci --ignore-scripts
|
|
208
|
-
- run: npm run lint
|
|
209
|
-
- run: npm run type-check
|
|
38
|
+
Existing CI (from git-workflow — already configured):
|
|
39
|
+
-> Stage 1: Fast checks (30s) — lint, format, type check
|
|
40
|
+
-> Stage 2: Tests (2-5 min) — unit + integration in parallel
|
|
41
|
+
|
|
42
|
+
Operations adds (main branch only):
|
|
43
|
+
-> Stage 3: Build (1-2 min) — compile, bundle, generate artifacts
|
|
44
|
+
-> Stage 4: Deploy (2-5 min) — deploy to staging/production
|
|
45
|
+
-> Stage 5: Post-deploy verification — smoke tests
|
|
210
46
|
```
|
|
211
47
|
|
|
212
|
-
|
|
213
|
-
- Run unit and integration tests in parallel
|
|
214
|
-
- Use a service container for the test database
|
|
215
|
-
- Upload coverage reports as artifacts
|
|
216
|
-
- Target: <5 minutes
|
|
217
|
-
|
|
218
|
-
```yaml
|
|
219
|
-
test:
|
|
220
|
-
runs-on: ubuntu-latest
|
|
221
|
-
services:
|
|
222
|
-
postgres:
|
|
223
|
-
image: postgres:16
|
|
224
|
-
env:
|
|
225
|
-
POSTGRES_DB: test
|
|
226
|
-
POSTGRES_PASSWORD: test
|
|
227
|
-
ports: ['5432:5432']
|
|
228
|
-
steps:
|
|
229
|
-
- uses: actions/checkout@v4
|
|
230
|
-
- uses: actions/setup-node@v4
|
|
231
|
-
- run: npm ci
|
|
232
|
-
- run: npm run test:ci
|
|
233
|
-
env:
|
|
234
|
-
DATABASE_URL: postgresql://postgres:test@localhost:5432/test
|
|
235
|
-
```
|
|
48
|
+
### Stage 3: Build
|
|
236
49
|
|
|
237
|
-
**Stage 3: Build**
|
|
238
50
|
- Compile TypeScript, bundle frontend assets, generate Docker image
|
|
239
51
|
- Verify the build artifact is valid (start the server and check health endpoint)
|
|
240
52
|
- Store the build artifact for deployment
|
|
53
|
+
- Only runs after Stages 1-2 pass
|
|
54
|
+
|
|
55
|
+
### Stage 4: Deploy
|
|
241
56
|
|
|
242
|
-
**Stage 4: Deploy**
|
|
243
57
|
- Only runs on main branch (after PR merge)
|
|
244
58
|
- Deploy the build artifact from Stage 3
|
|
245
59
|
- Run database migrations before starting new version
|
|
246
60
|
- Verify health check after deployment
|
|
247
61
|
|
|
248
|
-
###
|
|
249
|
-
|
|
250
|
-
**Parallel jobs:** Run lint, unit tests, and integration tests as separate parallel jobs. The total pipeline time equals the longest individual job, not the sum.
|
|
62
|
+
### Stage 5: Post-Deploy Verification
|
|
251
63
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
64
|
+
- Run smoke tests against the deployed environment
|
|
65
|
+
- Verify critical user flows work end-to-end
|
|
66
|
+
- Check external dependency connectivity
|
|
67
|
+
- If smoke tests fail: trigger automatic rollback
|
|
255
68
|
|
|
256
69
|
### Artifact Management
|
|
257
70
|
|
|
@@ -502,8 +315,6 @@ Define service level targets for the application:
|
|
|
502
315
|
|
|
503
316
|
**Alert fatigue.** Too many alerts firing for non-critical issues. The on-call person starts ignoring alerts because most are noise. A real incident gets missed. Fix: every alert must have a clear response action. Remove alerts that routinely fire without requiring action.
|
|
504
317
|
|
|
505
|
-
**No local dev story.** "It works on the CI server" but developers can't run the application locally. Fix: document the local setup, make it one command, test it regularly by having new team members follow the instructions.
|
|
506
|
-
|
|
507
318
|
**Manual deployment steps.** Deployment requires an engineer to SSH into a server and run commands. This is error-prone, unreproducible, and blocks deployment on individual availability. Fix: fully automate deployment. A merge to main should trigger deployment automatically.
|
|
508
319
|
|
|
509
320
|
**No monitoring before launch.** Monitoring is added after the first incident, when it's most needed and least available. Fix: set up monitoring as part of the infrastructure phase, before any user traffic.
|