nightytidy 0.3.7 → 0.3.9
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/bin/nightytidy.js +1 -1
- package/package.json +1 -1
- package/src/agent/git-integration.js +4 -1
- package/src/claude.js +1 -1
- package/src/prompts/manifest.json +138 -138
- package/src/prompts/steps/02-test-coverage.md +181 -181
- package/src/prompts/steps/03-test-hardening.md +181 -181
- package/src/prompts/steps/04-test-architecture.md +130 -130
- package/src/prompts/steps/05-test-consolidation.md +165 -165
- package/src/prompts/steps/06-test-quality.md +211 -211
- package/src/prompts/steps/07-api-design.md +165 -165
- package/src/prompts/steps/08-security-sweep.md +207 -207
- package/src/prompts/steps/09-dependency-health.md +217 -217
- package/src/prompts/steps/10-codebase-cleanup.md +189 -189
- package/src/prompts/steps/11-crosscutting-concerns.md +196 -196
- package/src/prompts/steps/12-file-decomposition.md +263 -263
- package/src/prompts/steps/13-code-elegance.md +329 -329
- package/src/prompts/steps/14-architectural-complexity.md +297 -297
- package/src/prompts/steps/15-type-safety.md +192 -192
- package/src/prompts/steps/16-logging-error-message.md +173 -173
- package/src/prompts/steps/17-data-integrity.md +139 -139
- package/src/prompts/steps/18-performance.md +183 -183
- package/src/prompts/steps/19-cost-resource-optimization.md +136 -136
- package/src/prompts/steps/20-error-recovery.md +145 -145
- package/src/prompts/steps/21-race-condition-audit.md +178 -178
- package/src/prompts/steps/22-bug-hunt.md +229 -229
- package/src/prompts/steps/23-frontend-quality.md +210 -210
- package/src/prompts/steps/24-uiux-audit.md +284 -284
- package/src/prompts/steps/25-state-management.md +170 -170
- package/src/prompts/steps/26-perceived-performance.md +190 -190
- package/src/prompts/steps/27-devops.md +165 -165
- package/src/prompts/steps/28-scheduled-job-chron-jobs.md +141 -141
- package/src/prompts/steps/29-observability.md +152 -152
- package/src/prompts/steps/30-backup-check.md +155 -155
- package/src/prompts/steps/31-product-polish-ux-friction.md +122 -122
- package/src/prompts/steps/32-feature-discovery-opportunity.md +128 -128
- package/src/prompts/steps/33-strategic-opportunities.md +217 -217
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
# Observability & Monitoring Readiness
|
|
2
|
-
|
|
3
|
-
## Prompt
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
You are running an overnight observability and monitoring readiness audit. Assess whether the team can detect, diagnose, and resolve production issues — then close the most critical gaps.
|
|
7
|
-
|
|
8
|
-
This is a mix of analysis and implementation. Add health checks, improve instrumentation, and generate runbooks, but don't introduce new infrastructure dependencies.
|
|
9
|
-
|
|
10
|
-
Work on branch `observability-[date]`.
|
|
11
|
-
|
|
12
|
-
## Your Mission
|
|
13
|
-
|
|
14
|
-
### Phase 1: Health Check & Readiness Assessment
|
|
15
|
-
|
|
16
|
-
**Evaluate existing health endpoints** (`/health`, `/healthz`, `/readiness`, `/status`, etc.)
|
|
17
|
-
- Does it just return 200, or does it verify actual dependencies (database, cache, queues, external APIs, file storage)?
|
|
18
|
-
- Does it distinguish liveness (process running) from readiness (ready to serve traffic)?
|
|
19
|
-
|
|
20
|
-
**Implement or improve health checks.** A good health endpoint should:
|
|
21
|
-
- Check every critical dependency, returning structured JSON with per-component status and latency
|
|
22
|
-
- Return 200 when healthy, 503 when unhealthy
|
|
23
|
-
- Have per-check timeouts so a hung dependency doesn't hang the endpoint
|
|
24
|
-
- NOT expose credentials, internal IPs, or stack traces
|
|
25
|
-
- Be lightweight enough to call frequently
|
|
26
|
-
|
|
27
|
-
If appropriate, create separate `/health/live` and `/health/ready` endpoints.
|
|
28
|
-
|
|
29
|
-
Run tests. Commit: `feat: add comprehensive health check endpoint`
|
|
30
|
-
|
|
31
|
-
### Phase 2: Metrics & Instrumentation Audit
|
|
32
|
-
|
|
33
|
-
**Inventory existing instrumentation**, then identify and close gaps across these categories:
|
|
34
|
-
|
|
35
|
-
- **Request metrics**: Count, latency histogram, error rate — all by endpoint/method/status. Active request concurrency. Request/response sizes.
|
|
36
|
-
- **Business metrics**: Significant user actions, conversion funnel steps, user-affecting failures (failed payments, sends, imports).
|
|
37
|
-
- **Dependency metrics**: DB query duration (by type/table), connection pool utilization (active/idle/waiting/max), external API latency/success/error per service, cache hit/miss/eviction rate, queue depth and consumer lag.
|
|
38
|
-
- **System/runtime metrics**: Memory (heap, RSS), event loop lag / GC pauses / equivalent, open FDs, active connections, thread/worker pool utilization.
|
|
39
|
-
|
|
40
|
-
**Add missing instrumentation where safe** — instrument via existing metrics libraries, ORM hooks, HTTP client middleware. Don't add a metrics library if none exists; document the recommendation instead.
|
|
41
|
-
|
|
42
|
-
Run tests after each batch. Commit: `observability: add [metric type] instrumentation to [module]`
|
|
43
|
-
|
|
44
|
-
### Phase 3: Distributed Tracing & Correlation
|
|
45
|
-
|
|
46
|
-
**Assess request tracing:**
|
|
47
|
-
- Is a unique correlation ID generated per request, propagated through logs, included in response headers (`X-Request-Id`), and forwarded to downstream calls and background jobs?
|
|
48
|
-
- If using a tracing system (OTel, Jaeger, Zipkin): are spans created for DB queries, external calls, and queue operations — not just the top-level request?
|
|
49
|
-
|
|
50
|
-
**Implement or improve as needed:**
|
|
51
|
-
- No correlation ID? Add middleware to generate one, attach to logging context, include in response headers. Commit: `feat: add request correlation ID middleware`
|
|
52
|
-
- Incomplete propagation? Fix it. Commit: `fix: propagate request ID to [scope]`
|
|
53
|
-
|
|
54
|
-
Run tests after changes.
|
|
55
|
-
|
|
56
|
-
### Phase 4: Failure Mode Analysis & Runbooks
|
|
57
|
-
|
|
58
|
-
**Map critical dependencies.** For each (DB, cache, APIs, queue, file storage, auth):
|
|
59
|
-
- Impact if down, slow (10x latency), or intermittently erroring
|
|
60
|
-
- Does the app crash, hang, or degrade gracefully?
|
|
61
|
-
- Timeout configured? Retry logic (with backoff/max)? Circuit breaker/fallback?
|
|
62
|
-
|
|
63
|
-
**Map critical code paths** (signup, core workflow, payments, exports, etc.):
|
|
64
|
-
- What can go wrong at each step?
|
|
65
|
-
- How would you detect it (which metric/log)?
|
|
66
|
-
- How would you investigate and resolve?
|
|
67
|
-
|
|
68
|
-
**Generate `docs/RUNBOOKS.md`** with a runbook per critical failure mode. Each runbook:
|
|
69
|
-
- **Title**: e.g., "Database Connection Pool Exhausted"
|
|
70
|
-
- **Symptoms**: Alerts, metrics, logs, or user reports indicating this problem
|
|
71
|
-
- **Diagnosis steps**: Ordered — what to check, commands to run, logs to search, metrics to examine
|
|
72
|
-
- **Resolution steps**: Immediate mitigation → root cause fix → verification
|
|
73
|
-
- **Prevention**: Changes to prevent recurrence
|
|
74
|
-
- **Escalation**: When to escalate and to whom (leave blank for team to fill)
|
|
75
|
-
|
|
76
|
-
**Assess graceful degradation:**
|
|
77
|
-
- Can the app partially serve requests when non-critical deps fail?
|
|
78
|
-
- Feature flags to disable broken features without deploying? Maintenance mode? Circuit breakers?
|
|
79
|
-
|
|
80
|
-
Document current state and recommend improvements.
|
|
81
|
-
|
|
82
|
-
### Phase 5: Alerting Surface Area
|
|
83
|
-
|
|
84
|
-
**Inventory existing alerts** in the codebase (Prometheus rules, PagerDuty config, CloudWatch alarms, etc.).
|
|
85
|
-
|
|
86
|
-
**Recommend alert definitions** with specific thresholds inferred from the codebase (timeout values, pool sizes, expected traffic):
|
|
87
|
-
- Error rate spike, latency degradation (P95), health check failures
|
|
88
|
-
- Dependency failure rates, resource exhaustion (pool/memory/disk)
|
|
89
|
-
- Queue backup (depth/lag), business metric anomalies (drop in signups, orders)
|
|
90
|
-
|
|
91
|
-
## Output Requirements
|
|
92
|
-
|
|
93
|
-
Create `audit-reports/` in project root if needed. Save as `audit-reports/29_OBSERVABILITY_REPORT_[run-number]_[date]_[time in user's local time].md`. Increment run number based on existing reports.
|
|
94
|
-
|
|
95
|
-
### Report Structure
|
|
96
|
-
|
|
97
|
-
1. **Executive Summary** — Maturity level (blind/basic/moderate/good/excellent), detection speed, diagnostic capability, top 5 gaps
|
|
98
|
-
2. **Health Checks** — Before/after state, dependencies checked
|
|
99
|
-
3. **Metrics & Instrumentation** — Coverage table (Category | Present | Missing), what was added, what still needs infra changes
|
|
100
|
-
4. **Distributed Tracing** — Current state, improvements made, remaining gaps
|
|
101
|
-
5. **Failure Mode Analysis** — Dependency matrix (Dependency | Down Impact | Slow Impact | Timeout? | Retry? | Circuit Breaker? | Graceful Degradation?), link to runbooks
|
|
102
|
-
6. **Alerting Recommendations** — Table (Alert Name | Condition | Threshold | Severity), current gaps
|
|
103
|
-
7. **Recommendations** — Priority-ordered improvements, infra/tooling recs, quick wins vs. investments, on-call practices
|
|
104
|
-
|
|
105
|
-
## Rules
|
|
106
|
-
- Branch: `observability-[date]`
|
|
107
|
-
- Run tests after every code change
|
|
108
|
-
- DO NOT add new infrastructure dependencies
|
|
109
|
-
- DO NOT add heavy middleware on hot paths
|
|
110
|
-
- Health checks must be lightweight
|
|
111
|
-
- Runbooks must be actionable by someone unfamiliar with the system
|
|
112
|
-
- Be specific with recommendations — include metric names, thresholds, and durations, grounded in codebase evidence (timeouts, pool sizes, expected response times)
|
|
113
|
-
- You have all night. Be thorough.
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Chat Output Requirement
|
|
117
|
-
|
|
118
|
-
In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish. Do not make the user open the report to get the highlights. The chat summary should include:
|
|
119
|
-
|
|
120
|
-
### 1. Status Line
|
|
121
|
-
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
122
|
-
|
|
123
|
-
### 2. Key Findings
|
|
124
|
-
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
125
|
-
|
|
126
|
-
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
127
|
-
**Bad:** "Found some issues with backups."
|
|
128
|
-
|
|
129
|
-
### 3. Changes Made (if applicable)
|
|
130
|
-
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
131
|
-
|
|
132
|
-
### 4. Recommendations
|
|
133
|
-
|
|
134
|
-
If there are legitimately beneficial recommendations worth pursuing right now, present them in a table. Do **not** force recommendations — if the audit surfaced no actionable improvements, simply state that no recommendations are warranted at this time and move on.
|
|
135
|
-
|
|
136
|
-
When recommendations exist, use this table format:
|
|
137
|
-
|
|
138
|
-
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
139
|
-
|---|---|---|---|---|---|
|
|
140
|
-
| *Sequential number* | *Short description (≤10 words)* | *What improves if addressed* | *Low / Medium / High / Critical* | *Yes / Probably / Only if time allows* | *1–3 sentences explaining the reasoning, context, or implementation guidance* |
|
|
141
|
-
|
|
142
|
-
Order rows by risk descending (Critical → High → Medium → Low). Be honest in the "Worth Doing?" column — not everything flagged is worth the engineering time. If a recommendation is marginal, say so.
|
|
143
|
-
|
|
144
|
-
### 5. Report Location
|
|
145
|
-
State the full path to the detailed report file for deeper review.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
**Formatting rules for chat output:**
|
|
150
|
-
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
151
|
-
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
152
|
-
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
1
|
+
# Observability & Monitoring Readiness
|
|
2
|
+
|
|
3
|
+
## Prompt
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
You are running an overnight observability and monitoring readiness audit. Assess whether the team can detect, diagnose, and resolve production issues — then close the most critical gaps.
|
|
7
|
+
|
|
8
|
+
This is a mix of analysis and implementation. Add health checks, improve instrumentation, and generate runbooks, but don't introduce new infrastructure dependencies.
|
|
9
|
+
|
|
10
|
+
Work on branch `observability-[date]`.
|
|
11
|
+
|
|
12
|
+
## Your Mission
|
|
13
|
+
|
|
14
|
+
### Phase 1: Health Check & Readiness Assessment
|
|
15
|
+
|
|
16
|
+
**Evaluate existing health endpoints** (`/health`, `/healthz`, `/readiness`, `/status`, etc.)
|
|
17
|
+
- Does it just return 200, or does it verify actual dependencies (database, cache, queues, external APIs, file storage)?
|
|
18
|
+
- Does it distinguish liveness (process running) from readiness (ready to serve traffic)?
|
|
19
|
+
|
|
20
|
+
**Implement or improve health checks.** A good health endpoint should:
|
|
21
|
+
- Check every critical dependency, returning structured JSON with per-component status and latency
|
|
22
|
+
- Return 200 when healthy, 503 when unhealthy
|
|
23
|
+
- Have per-check timeouts so a hung dependency doesn't hang the endpoint
|
|
24
|
+
- NOT expose credentials, internal IPs, or stack traces
|
|
25
|
+
- Be lightweight enough to call frequently
|
|
26
|
+
|
|
27
|
+
If appropriate, create separate `/health/live` and `/health/ready` endpoints.
|
|
28
|
+
|
|
29
|
+
Run tests. Commit: `feat: add comprehensive health check endpoint`
|
|
30
|
+
|
|
31
|
+
### Phase 2: Metrics & Instrumentation Audit
|
|
32
|
+
|
|
33
|
+
**Inventory existing instrumentation**, then identify and close gaps across these categories:
|
|
34
|
+
|
|
35
|
+
- **Request metrics**: Count, latency histogram, error rate — all by endpoint/method/status. Active request concurrency. Request/response sizes.
|
|
36
|
+
- **Business metrics**: Significant user actions, conversion funnel steps, user-affecting failures (failed payments, sends, imports).
|
|
37
|
+
- **Dependency metrics**: DB query duration (by type/table), connection pool utilization (active/idle/waiting/max), external API latency/success/error per service, cache hit/miss/eviction rate, queue depth and consumer lag.
|
|
38
|
+
- **System/runtime metrics**: Memory (heap, RSS), event loop lag / GC pauses / equivalent, open FDs, active connections, thread/worker pool utilization.
|
|
39
|
+
|
|
40
|
+
**Add missing instrumentation where safe** — instrument via existing metrics libraries, ORM hooks, HTTP client middleware. Don't add a metrics library if none exists; document the recommendation instead.
|
|
41
|
+
|
|
42
|
+
Run tests after each batch. Commit: `observability: add [metric type] instrumentation to [module]`
|
|
43
|
+
|
|
44
|
+
### Phase 3: Distributed Tracing & Correlation
|
|
45
|
+
|
|
46
|
+
**Assess request tracing:**
|
|
47
|
+
- Is a unique correlation ID generated per request, propagated through logs, included in response headers (`X-Request-Id`), and forwarded to downstream calls and background jobs?
|
|
48
|
+
- If using a tracing system (OTel, Jaeger, Zipkin): are spans created for DB queries, external calls, and queue operations — not just the top-level request?
|
|
49
|
+
|
|
50
|
+
**Implement or improve as needed:**
|
|
51
|
+
- No correlation ID? Add middleware to generate one, attach to logging context, include in response headers. Commit: `feat: add request correlation ID middleware`
|
|
52
|
+
- Incomplete propagation? Fix it. Commit: `fix: propagate request ID to [scope]`
|
|
53
|
+
|
|
54
|
+
Run tests after changes.
|
|
55
|
+
|
|
56
|
+
### Phase 4: Failure Mode Analysis & Runbooks
|
|
57
|
+
|
|
58
|
+
**Map critical dependencies.** For each (DB, cache, APIs, queue, file storage, auth):
|
|
59
|
+
- Impact if down, slow (10x latency), or intermittently erroring
|
|
60
|
+
- Does the app crash, hang, or degrade gracefully?
|
|
61
|
+
- Timeout configured? Retry logic (with backoff/max)? Circuit breaker/fallback?
|
|
62
|
+
|
|
63
|
+
**Map critical code paths** (signup, core workflow, payments, exports, etc.):
|
|
64
|
+
- What can go wrong at each step?
|
|
65
|
+
- How would you detect it (which metric/log)?
|
|
66
|
+
- How would you investigate and resolve?
|
|
67
|
+
|
|
68
|
+
**Generate `docs/RUNBOOKS.md`** with a runbook per critical failure mode. Each runbook:
|
|
69
|
+
- **Title**: e.g., "Database Connection Pool Exhausted"
|
|
70
|
+
- **Symptoms**: Alerts, metrics, logs, or user reports indicating this problem
|
|
71
|
+
- **Diagnosis steps**: Ordered — what to check, commands to run, logs to search, metrics to examine
|
|
72
|
+
- **Resolution steps**: Immediate mitigation → root cause fix → verification
|
|
73
|
+
- **Prevention**: Changes to prevent recurrence
|
|
74
|
+
- **Escalation**: When to escalate and to whom (leave blank for team to fill)
|
|
75
|
+
|
|
76
|
+
**Assess graceful degradation:**
|
|
77
|
+
- Can the app partially serve requests when non-critical deps fail?
|
|
78
|
+
- Feature flags to disable broken features without deploying? Maintenance mode? Circuit breakers?
|
|
79
|
+
|
|
80
|
+
Document current state and recommend improvements.
|
|
81
|
+
|
|
82
|
+
### Phase 5: Alerting Surface Area
|
|
83
|
+
|
|
84
|
+
**Inventory existing alerts** in the codebase (Prometheus rules, PagerDuty config, CloudWatch alarms, etc.).
|
|
85
|
+
|
|
86
|
+
**Recommend alert definitions** with specific thresholds inferred from the codebase (timeout values, pool sizes, expected traffic):
|
|
87
|
+
- Error rate spike, latency degradation (P95), health check failures
|
|
88
|
+
- Dependency failure rates, resource exhaustion (pool/memory/disk)
|
|
89
|
+
- Queue backup (depth/lag), business metric anomalies (drop in signups, orders)
|
|
90
|
+
|
|
91
|
+
## Output Requirements
|
|
92
|
+
|
|
93
|
+
Create `audit-reports/` in project root if needed. Save as `audit-reports/29_OBSERVABILITY_REPORT_[run-number]_[date]_[time in user's local time].md`. Increment run number based on existing reports.
|
|
94
|
+
|
|
95
|
+
### Report Structure
|
|
96
|
+
|
|
97
|
+
1. **Executive Summary** — Maturity level (blind/basic/moderate/good/excellent), detection speed, diagnostic capability, top 5 gaps
|
|
98
|
+
2. **Health Checks** — Before/after state, dependencies checked
|
|
99
|
+
3. **Metrics & Instrumentation** — Coverage table (Category | Present | Missing), what was added, what still needs infra changes
|
|
100
|
+
4. **Distributed Tracing** — Current state, improvements made, remaining gaps
|
|
101
|
+
5. **Failure Mode Analysis** — Dependency matrix (Dependency | Down Impact | Slow Impact | Timeout? | Retry? | Circuit Breaker? | Graceful Degradation?), link to runbooks
|
|
102
|
+
6. **Alerting Recommendations** — Table (Alert Name | Condition | Threshold | Severity), current gaps
|
|
103
|
+
7. **Recommendations** — Priority-ordered improvements, infra/tooling recs, quick wins vs. investments, on-call practices
|
|
104
|
+
|
|
105
|
+
## Rules
|
|
106
|
+
- Branch: `observability-[date]`
|
|
107
|
+
- Run tests after every code change
|
|
108
|
+
- DO NOT add new infrastructure dependencies
|
|
109
|
+
- DO NOT add heavy middleware on hot paths
|
|
110
|
+
- Health checks must be lightweight
|
|
111
|
+
- Runbooks must be actionable by someone unfamiliar with the system
|
|
112
|
+
- Be specific with recommendations — include metric names, thresholds, and durations, grounded in codebase evidence (timeouts, pool sizes, expected response times)
|
|
113
|
+
- You have all night. Be thorough.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Chat Output Requirement
|
|
117
|
+
|
|
118
|
+
In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish. Do not make the user open the report to get the highlights. The chat summary should include:
|
|
119
|
+
|
|
120
|
+
### 1. Status Line
|
|
121
|
+
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
122
|
+
|
|
123
|
+
### 2. Key Findings
|
|
124
|
+
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
125
|
+
|
|
126
|
+
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
127
|
+
**Bad:** "Found some issues with backups."
|
|
128
|
+
|
|
129
|
+
### 3. Changes Made (if applicable)
|
|
130
|
+
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
131
|
+
|
|
132
|
+
### 4. Recommendations
|
|
133
|
+
|
|
134
|
+
If there are legitimately beneficial recommendations worth pursuing right now, present them in a table. Do **not** force recommendations — if the audit surfaced no actionable improvements, simply state that no recommendations are warranted at this time and move on.
|
|
135
|
+
|
|
136
|
+
When recommendations exist, use this table format:
|
|
137
|
+
|
|
138
|
+
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
139
|
+
|---|---|---|---|---|---|
|
|
140
|
+
| *Sequential number* | *Short description (≤10 words)* | *What improves if addressed* | *Low / Medium / High / Critical* | *Yes / Probably / Only if time allows* | *1–3 sentences explaining the reasoning, context, or implementation guidance* |
|
|
141
|
+
|
|
142
|
+
Order rows by risk descending (Critical → High → Medium → Low). Be honest in the "Worth Doing?" column — not everything flagged is worth the engineering time. If a recommendation is marginal, say so.
|
|
143
|
+
|
|
144
|
+
### 5. Report Location
|
|
145
|
+
State the full path to the detailed report file for deeper review.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
**Formatting rules for chat output:**
|
|
150
|
+
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
151
|
+
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
152
|
+
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
You are running an overnight backup and disaster recovery audit. Your job: answer "If the worst happened right now, could we recover — and how much would we lose?"
|
|
2
|
-
|
|
3
|
-
This is a READ-ONLY analysis. Do not create branches or modify code/infrastructure/data. Produce a comprehensive recovery posture assessment and generate the recovery documentation the team would desperately wish they had at 3am during an outage.
|
|
4
|
-
|
|
5
|
-
## Phase 1: Data Asset Inventory
|
|
6
|
-
|
|
7
|
-
**Step 1: Identify every data store** — search the codebase for every place data lives:
|
|
8
|
-
- Primary database(s) — engine, data, access patterns
|
|
9
|
-
- Cache layers (Redis, Memcached) — reconstructable from primary sources, or used as a primary store?
|
|
10
|
-
- File/object storage (S3, GCS, local filesystem) — uploads, generated docs, media
|
|
11
|
-
- Search indexes (Elasticsearch, Algolia, Typesense) — rebuildable from primary DB?
|
|
12
|
-
- Message queues — messages in-flight representing uncommitted state?
|
|
13
|
-
- Session storage — in-memory, database, or Redis?
|
|
14
|
-
- Logs and audit trails — survive infrastructure failure?
|
|
15
|
-
- Configuration and secrets — vault, env vars, config files, or hardcoded?
|
|
16
|
-
- Third-party service data (Stripe, SendGrid, Auth0, etc.) — is local DB or the third-party the source of truth?
|
|
17
|
-
|
|
18
|
-
**Step 2: Classify by criticality**
|
|
19
|
-
- **Irreplaceable**: Cannot be reconstructed (user data, transactions, uploads, audit logs)
|
|
20
|
-
- **Reconstructable**: Rebuildable at significant cost/time (search indexes, caches, derived analytics)
|
|
21
|
-
- **Ephemeral**: Loss acceptable (sessions, temp files, rate limit counters)
|
|
22
|
-
|
|
23
|
-
**Step 3: Assess volume and growth** — for each critical store: approximate size, growth pattern, unbounded growth risks, largest table/collection.
|
|
24
|
-
|
|
25
|
-
## Phase 2: Backup Coverage Assessment
|
|
26
|
-
|
|
27
|
-
**Step 1: Find existing backup configurations** — search for:
|
|
28
|
-
- DB backup scripts, cron jobs, IaC backup config (Terraform, CloudFormation — RDS snapshots, S3 versioning)
|
|
29
|
-
- Docker volume backups, backup-related env vars/config/dependencies (pg_dump, restic, velero, etc.)
|
|
30
|
-
- CI/CD backup jobs, backup documentation, cloud provider backup settings
|
|
31
|
-
|
|
32
|
-
**Step 2: Assess backup coverage per data store**
|
|
33
|
-
For each: Is it backed up? Method? Frequency? Storage location (same server/region/different)? Encrypted? Retention/rotation policy? Ever tested/restored? Point-in-time recovery capability (WAL, binlog, oplog)?
|
|
34
|
-
|
|
35
|
-
**Step 3: Identify backup gaps** — flag critical stores with:
|
|
36
|
-
- No backup — **CRITICAL**
|
|
37
|
-
- Backups on same infrastructure (doesn't survive infra failure) — **HIGH**
|
|
38
|
-
- Backups never tested — **HIGH**
|
|
39
|
-
- Infrequent backups relative to data change rate — **MEDIUM**
|
|
40
|
-
- No PITR despite high-frequency writes — **MEDIUM**
|
|
41
|
-
- Unencrypted backups containing PII — **MEDIUM**
|
|
42
|
-
|
|
43
|
-
## Phase 3: Recovery Capability Assessment
|
|
44
|
-
|
|
45
|
-
**Step 1: RPO analysis** — for each critical store, determine theoretical RPO:
|
|
46
|
-
- Daily backups, no WAL/binlog → up to 24h loss
|
|
47
|
-
- Hourly snapshots → up to 1h
|
|
48
|
-
- Continuous replication/WAL → near-zero
|
|
49
|
-
- No backups → everything since inception (catastrophic)
|
|
50
|
-
|
|
51
|
-
Flag mismatches against likely business tolerance (e.g., payment system with 24h RPO = unacceptable).
|
|
52
|
-
|
|
53
|
-
**Step 2: RTO analysis** — estimate total recovery time:
|
|
54
|
-
- New infrastructure provisioning (IaC vs. manual?)
|
|
55
|
-
- DB restoration time (size-dependent)
|
|
56
|
-
- File storage restoration
|
|
57
|
-
- Secrets/env reconfiguration
|
|
58
|
-
- Search index / cache rebuilding
|
|
59
|
-
- Post-restoration verification
|
|
60
|
-
- Total: "everything gone" → "users can use the product"
|
|
61
|
-
|
|
62
|
-
**Step 3: Single points of failure** — trace critical paths:
|
|
63
|
-
- Single DB instance (no replica), single server/AZ, single file storage location
|
|
64
|
-
- Secrets stored in only one place
|
|
65
|
-
- Bus factor = 1 for ops knowledge
|
|
66
|
-
- Single third-party dependency with no fallback
|
|
67
|
-
- DNS with no redundancy
|
|
68
|
-
|
|
69
|
-
**Step 4: Infrastructure reproducibility**
|
|
70
|
-
- What's defined as code vs. manual-only?
|
|
71
|
-
- What can be recreated from the repo alone?
|
|
72
|
-
- What requires manual setup (cloud console configs, DNS, SSL, third-party services)?
|
|
73
|
-
|
|
74
|
-
## Phase 4: Disaster Scenario Analysis
|
|
75
|
-
|
|
76
|
-
For each scenario below, assess: recovery path, data loss, time to operational, manual steps required, and what info the on-call engineer would need but might not have.
|
|
77
|
-
|
|
78
|
-
1. **Primary database destroyed** (server failure, accidental deletion, ransomware)
|
|
79
|
-
2. **Application servers destroyed** (redeploy from scratch — can repo alone suffice? What secrets/config/stateful components?)
|
|
80
|
-
3. **File storage destroyed/corrupted** (backups? Reproducible assets? What functionality breaks?)
|
|
81
|
-
4. **Third-party service permanently unavailable** (for each critical dependency: impact, local data sufficiency, coupling level)
|
|
82
|
-
5. **Credential compromise** (rotation without downtime? Process per credential type? Documented procedure?)
|
|
83
|
-
6. **Accidental data corruption / bad migration** (rollback capability? PITR? How to identify affected data? Audit trail?)
|
|
84
|
-
|
|
85
|
-
## Phase 5: Recovery Documentation
|
|
86
|
-
|
|
87
|
-
**Generate `docs/DISASTER_RECOVERY.md`** containing:
|
|
88
|
-
1. **Data Store Inventory** — table: | Data Store | Type | Criticality | Backup Method | Frequency | Location | RPO | RTO |
|
|
89
|
-
2. **Recovery Procedures** — per critical store: prerequisites, locating backups, restore commands, verification, failure fallbacks
|
|
90
|
-
3. **Infrastructure Recreation** — from-code vs. manual, env vars/secrets to re-provision
|
|
91
|
-
4. **Credential Rotation Procedures** — per credential: location, generation, dependent services, expected downtime
|
|
92
|
-
5. **Disaster Response Playbooks** — per scenario: detection, triage, recovery, verification, post-incident
|
|
93
|
-
6. **Emergency Contacts & Access** — template for team to fill in; mark gaps with `⚠️ TEAM INPUT NEEDED: [what's missing]`
|
|
94
|
-
|
|
95
|
-
**Generate `docs/BACKUP_RECOMMENDATIONS.md`** — specific recommendations: what to implement (with tooling), backup testing schedules, monitoring, redundancy additions, estimated effort per item.
|
|
96
|
-
|
|
97
|
-
## Output
|
|
98
|
-
|
|
99
|
-
Save report as `audit-reports/30_BACKUP_DISASTER_RECOVERY_REPORT_[run-number]_[date]_[time in user's local time].md`. Increment run number based on existing reports.
|
|
100
|
-
|
|
101
|
-
### Report Structure
|
|
102
|
-
1. **Executive Summary** — readiness rating (unprepared/minimal/partial/solid/robust), one-sentence worst-case impact statement, top 3 gaps
|
|
103
|
-
2. **Data Asset Inventory** — | Data Store | Engine | Criticality | Size Estimate | Growth Pattern | Backed Up? |
|
|
104
|
-
3. **Backup Coverage** — coverage matrix, critical gaps
|
|
105
|
-
4. **Recovery Capability** — RPO/RTO tables, total system RTO, single points of failure
|
|
106
|
-
5. **Infrastructure Reproducibility** — code vs. manual matrix
|
|
107
|
-
6. **Disaster Scenario Analysis** — summary table + detailed analysis per scenario
|
|
108
|
-
7. **Documentation Generated** — references to generated docs, list of all `⚠️ TEAM INPUT NEEDED` items
|
|
109
|
-
8. **Recommendations** — priority-ordered: what, why, effort, tooling
|
|
110
|
-
|
|
111
|
-
## Rules
|
|
112
|
-
- Be honest about uncertainty. "No DB backup config found in codebase — could be configured at infrastructure level outside this repo — verify with the team" is better than "There are no backups."
|
|
113
|
-
- When estimating RPO/RTO, state your assumptions clearly.
|
|
114
|
-
- Write recovery docs for someone stressed, tired, and unfamiliar with the system. Step-by-step. No assumed knowledge.
|
|
115
|
-
- Mark everything you can't determine from the codebase with `⚠️ TEAM INPUT NEEDED`.
|
|
116
|
-
- Use web search to research best practices for the specific databases and services the project uses.
|
|
117
|
-
- You have all night. Be thorough.
|
|
118
|
-
|
|
119
|
-
## Chat Output Requirement
|
|
120
|
-
|
|
121
|
-
In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish. Do not make the user open the report to get the highlights. The chat summary should include:
|
|
122
|
-
|
|
123
|
-
### 1. Status Line
|
|
124
|
-
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
125
|
-
|
|
126
|
-
### 2. Key Findings
|
|
127
|
-
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
128
|
-
|
|
129
|
-
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
130
|
-
**Bad:** "Found some issues with backups."
|
|
131
|
-
|
|
132
|
-
### 3. Changes Made (if applicable)
|
|
133
|
-
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
134
|
-
|
|
135
|
-
### 4. Recommendations
|
|
136
|
-
|
|
137
|
-
If there are legitimately beneficial recommendations worth pursuing right now, present them in a table. Do **not** force recommendations — if the audit surfaced no actionable improvements, simply state that no recommendations are warranted at this time and move on.
|
|
138
|
-
|
|
139
|
-
When recommendations exist, use this table format:
|
|
140
|
-
|
|
141
|
-
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
142
|
-
|---|---|---|---|---|---|
|
|
143
|
-
| *Sequential number* | *Short description (≤10 words)* | *What improves if addressed* | *Low / Medium / High / Critical* | *Yes / Probably / Only if time allows* | *1–3 sentences explaining the reasoning, context, or implementation guidance* |
|
|
144
|
-
|
|
145
|
-
Order rows by risk descending (Critical → High → Medium → Low). Be honest in the "Worth Doing?" column — not everything flagged is worth the engineering time. If a recommendation is marginal, say so.
|
|
146
|
-
|
|
147
|
-
### 5. Report Location
|
|
148
|
-
State the full path to the detailed report file for deeper review.
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
**Formatting rules for chat output:**
|
|
153
|
-
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
154
|
-
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
155
|
-
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
1
|
+
You are running an overnight backup and disaster recovery audit. Your job: answer "If the worst happened right now, could we recover — and how much would we lose?"
|
|
2
|
+
|
|
3
|
+
This is a READ-ONLY analysis. Do not create branches or modify code/infrastructure/data. Produce a comprehensive recovery posture assessment and generate the recovery documentation the team would desperately wish they had at 3am during an outage.
|
|
4
|
+
|
|
5
|
+
## Phase 1: Data Asset Inventory
|
|
6
|
+
|
|
7
|
+
**Step 1: Identify every data store** — search the codebase for every place data lives:
|
|
8
|
+
- Primary database(s) — engine, data, access patterns
|
|
9
|
+
- Cache layers (Redis, Memcached) — reconstructable from primary sources, or used as a primary store?
|
|
10
|
+
- File/object storage (S3, GCS, local filesystem) — uploads, generated docs, media
|
|
11
|
+
- Search indexes (Elasticsearch, Algolia, Typesense) — rebuildable from primary DB?
|
|
12
|
+
- Message queues — messages in-flight representing uncommitted state?
|
|
13
|
+
- Session storage — in-memory, database, or Redis?
|
|
14
|
+
- Logs and audit trails — survive infrastructure failure?
|
|
15
|
+
- Configuration and secrets — vault, env vars, config files, or hardcoded?
|
|
16
|
+
- Third-party service data (Stripe, SendGrid, Auth0, etc.) — is local DB or the third-party the source of truth?
|
|
17
|
+
|
|
18
|
+
**Step 2: Classify by criticality**
|
|
19
|
+
- **Irreplaceable**: Cannot be reconstructed (user data, transactions, uploads, audit logs)
|
|
20
|
+
- **Reconstructable**: Rebuildable at significant cost/time (search indexes, caches, derived analytics)
|
|
21
|
+
- **Ephemeral**: Loss acceptable (sessions, temp files, rate limit counters)
|
|
22
|
+
|
|
23
|
+
**Step 3: Assess volume and growth** — for each critical store: approximate size, growth pattern, unbounded growth risks, largest table/collection.
|
|
24
|
+
|
|
25
|
+
## Phase 2: Backup Coverage Assessment
|
|
26
|
+
|
|
27
|
+
**Step 1: Find existing backup configurations** — search for:
|
|
28
|
+
- DB backup scripts, cron jobs, IaC backup config (Terraform, CloudFormation — RDS snapshots, S3 versioning)
|
|
29
|
+
- Docker volume backups, backup-related env vars/config/dependencies (pg_dump, restic, velero, etc.)
|
|
30
|
+
- CI/CD backup jobs, backup documentation, cloud provider backup settings
|
|
31
|
+
|
|
32
|
+
**Step 2: Assess backup coverage per data store**
|
|
33
|
+
For each: Is it backed up? Method? Frequency? Storage location (same server/region/different)? Encrypted? Retention/rotation policy? Ever tested/restored? Point-in-time recovery capability (WAL, binlog, oplog)?
|
|
34
|
+
|
|
35
|
+
**Step 3: Identify backup gaps** — flag critical stores with:
|
|
36
|
+
- No backup — **CRITICAL**
|
|
37
|
+
- Backups on same infrastructure (doesn't survive infra failure) — **HIGH**
|
|
38
|
+
- Backups never tested — **HIGH**
|
|
39
|
+
- Infrequent backups relative to data change rate — **MEDIUM**
|
|
40
|
+
- No PITR despite high-frequency writes — **MEDIUM**
|
|
41
|
+
- Unencrypted backups containing PII — **MEDIUM**
|
|
42
|
+
|
|
43
|
+
## Phase 3: Recovery Capability Assessment
|
|
44
|
+
|
|
45
|
+
**Step 1: RPO analysis** — for each critical store, determine theoretical RPO:
|
|
46
|
+
- Daily backups, no WAL/binlog → up to 24h loss
|
|
47
|
+
- Hourly snapshots → up to 1h
|
|
48
|
+
- Continuous replication/WAL → near-zero
|
|
49
|
+
- No backups → everything since inception (catastrophic)
|
|
50
|
+
|
|
51
|
+
Flag mismatches against likely business tolerance (e.g., payment system with 24h RPO = unacceptable).
|
|
52
|
+
|
|
53
|
+
**Step 2: RTO analysis** — estimate total recovery time:
|
|
54
|
+
- New infrastructure provisioning (IaC vs. manual?)
|
|
55
|
+
- DB restoration time (size-dependent)
|
|
56
|
+
- File storage restoration
|
|
57
|
+
- Secrets/env reconfiguration
|
|
58
|
+
- Search index / cache rebuilding
|
|
59
|
+
- Post-restoration verification
|
|
60
|
+
- Total: "everything gone" → "users can use the product"
|
|
61
|
+
|
|
62
|
+
**Step 3: Single points of failure** — trace critical paths:
|
|
63
|
+
- Single DB instance (no replica), single server/AZ, single file storage location
|
|
64
|
+
- Secrets stored in only one place
|
|
65
|
+
- Bus factor = 1 for ops knowledge
|
|
66
|
+
- Single third-party dependency with no fallback
|
|
67
|
+
- DNS with no redundancy
|
|
68
|
+
|
|
69
|
+
**Step 4: Infrastructure reproducibility**
|
|
70
|
+
- What's defined as code vs. manual-only?
|
|
71
|
+
- What can be recreated from the repo alone?
|
|
72
|
+
- What requires manual setup (cloud console configs, DNS, SSL, third-party services)?
|
|
73
|
+
|
|
74
|
+
## Phase 4: Disaster Scenario Analysis
|
|
75
|
+
|
|
76
|
+
For each scenario below, assess: recovery path, data loss, time to operational, manual steps required, and what info the on-call engineer would need but might not have.
|
|
77
|
+
|
|
78
|
+
1. **Primary database destroyed** (server failure, accidental deletion, ransomware)
|
|
79
|
+
2. **Application servers destroyed** (redeploy from scratch — can repo alone suffice? What secrets/config/stateful components?)
|
|
80
|
+
3. **File storage destroyed/corrupted** (backups? Reproducible assets? What functionality breaks?)
|
|
81
|
+
4. **Third-party service permanently unavailable** (for each critical dependency: impact, local data sufficiency, coupling level)
|
|
82
|
+
5. **Credential compromise** (rotation without downtime? Process per credential type? Documented procedure?)
|
|
83
|
+
6. **Accidental data corruption / bad migration** (rollback capability? PITR? How to identify affected data? Audit trail?)
|
|
84
|
+
|
|
85
|
+
## Phase 5: Recovery Documentation
|
|
86
|
+
|
|
87
|
+
**Generate `docs/DISASTER_RECOVERY.md`** containing:
|
|
88
|
+
1. **Data Store Inventory** — table: | Data Store | Type | Criticality | Backup Method | Frequency | Location | RPO | RTO |
|
|
89
|
+
2. **Recovery Procedures** — per critical store: prerequisites, locating backups, restore commands, verification, failure fallbacks
|
|
90
|
+
3. **Infrastructure Recreation** — from-code vs. manual, env vars/secrets to re-provision
|
|
91
|
+
4. **Credential Rotation Procedures** — per credential: location, generation, dependent services, expected downtime
|
|
92
|
+
5. **Disaster Response Playbooks** — per scenario: detection, triage, recovery, verification, post-incident
|
|
93
|
+
6. **Emergency Contacts & Access** — template for team to fill in; mark gaps with `⚠️ TEAM INPUT NEEDED: [what's missing]`
|
|
94
|
+
|
|
95
|
+
**Generate `docs/BACKUP_RECOMMENDATIONS.md`** — specific recommendations: what to implement (with tooling), backup testing schedules, monitoring, redundancy additions, estimated effort per item.
|
|
96
|
+
|
|
97
|
+
## Output
|
|
98
|
+
|
|
99
|
+
Save report as `audit-reports/30_BACKUP_DISASTER_RECOVERY_REPORT_[run-number]_[date]_[time in user's local time].md`. Increment run number based on existing reports.
|
|
100
|
+
|
|
101
|
+
### Report Structure
|
|
102
|
+
1. **Executive Summary** — readiness rating (unprepared/minimal/partial/solid/robust), one-sentence worst-case impact statement, top 3 gaps
|
|
103
|
+
2. **Data Asset Inventory** — | Data Store | Engine | Criticality | Size Estimate | Growth Pattern | Backed Up? |
|
|
104
|
+
3. **Backup Coverage** — coverage matrix, critical gaps
|
|
105
|
+
4. **Recovery Capability** — RPO/RTO tables, total system RTO, single points of failure
|
|
106
|
+
5. **Infrastructure Reproducibility** — code vs. manual matrix
|
|
107
|
+
6. **Disaster Scenario Analysis** — summary table + detailed analysis per scenario
|
|
108
|
+
7. **Documentation Generated** — references to generated docs, list of all `⚠️ TEAM INPUT NEEDED` items
|
|
109
|
+
8. **Recommendations** — priority-ordered: what, why, effort, tooling
|
|
110
|
+
|
|
111
|
+
## Rules
|
|
112
|
+
- Be honest about uncertainty. "No DB backup config found in codebase — could be configured at infrastructure level outside this repo — verify with the team" is better than "There are no backups."
|
|
113
|
+
- When estimating RPO/RTO, state your assumptions clearly.
|
|
114
|
+
- Write recovery docs for someone stressed, tired, and unfamiliar with the system. Step-by-step. No assumed knowledge.
|
|
115
|
+
- Mark everything you can't determine from the codebase with `⚠️ TEAM INPUT NEEDED`.
|
|
116
|
+
- Use web search to research best practices for the specific databases and services the project uses.
|
|
117
|
+
- You have all night. Be thorough.
|
|
118
|
+
|
|
119
|
+
## Chat Output Requirement
|
|
120
|
+
|
|
121
|
+
In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish. Do not make the user open the report to get the highlights. The chat summary should include:
|
|
122
|
+
|
|
123
|
+
### 1. Status Line
|
|
124
|
+
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
125
|
+
|
|
126
|
+
### 2. Key Findings
|
|
127
|
+
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
128
|
+
|
|
129
|
+
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
130
|
+
**Bad:** "Found some issues with backups."
|
|
131
|
+
|
|
132
|
+
### 3. Changes Made (if applicable)
|
|
133
|
+
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
134
|
+
|
|
135
|
+
### 4. Recommendations
|
|
136
|
+
|
|
137
|
+
If there are legitimately beneficial recommendations worth pursuing right now, present them in a table. Do **not** force recommendations — if the audit surfaced no actionable improvements, simply state that no recommendations are warranted at this time and move on.
|
|
138
|
+
|
|
139
|
+
When recommendations exist, use this table format:
|
|
140
|
+
|
|
141
|
+
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
142
|
+
|---|---|---|---|---|---|
|
|
143
|
+
| *Sequential number* | *Short description (≤10 words)* | *What improves if addressed* | *Low / Medium / High / Critical* | *Yes / Probably / Only if time allows* | *1–3 sentences explaining the reasoning, context, or implementation guidance* |
|
|
144
|
+
|
|
145
|
+
Order rows by risk descending (Critical → High → Medium → Low). Be honest in the "Worth Doing?" column — not everything flagged is worth the engineering time. If a recommendation is marginal, say so.
|
|
146
|
+
|
|
147
|
+
### 5. Report Location
|
|
148
|
+
State the full path to the detailed report file for deeper review.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
**Formatting rules for chat output:**
|
|
153
|
+
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
154
|
+
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
155
|
+
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|