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,192 +1,192 @@
|
|
|
1
|
-
# Type Safety & Error Handling Hardening
|
|
2
|
-
|
|
3
|
-
## Prompt
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
You are running an overnight robustness hardening pass. You have several hours. Your job is to make the codebase more resilient by strengthening type safety and error handling. You will be modifying code — every change must keep tests passing.
|
|
7
|
-
|
|
8
|
-
Work on a branch called `robustness-hardening-[date]`.
|
|
9
|
-
|
|
10
|
-
## Your Mission
|
|
11
|
-
|
|
12
|
-
### Phase 1: Type Safety Audit & Improvement
|
|
13
|
-
|
|
14
|
-
**If the project uses TypeScript:**
|
|
15
|
-
|
|
16
|
-
**Step 1: Find type weakness hotspots**
|
|
17
|
-
- Search for every instance of `any` type (explicit `any`, implicit `any` from missing annotations)
|
|
18
|
-
- Search for type assertions (`as`, `!` non-null assertions) — each one is a place where you're telling the compiler "trust me" instead of proving correctness
|
|
19
|
-
- Search for `@ts-ignore` and `@ts-expect-error` comments
|
|
20
|
-
- Check `tsconfig.json` — note which strict mode options are disabled and what they'd catch if enabled
|
|
21
|
-
- Look for functions with no return type annotation
|
|
22
|
-
- Look for function parameters with no type annotation
|
|
23
|
-
- Find places where `Object`, `Function`, `{}`, or `unknown` are used as types
|
|
24
|
-
|
|
25
|
-
**Step 2: Fix type weaknesses, starting with highest risk**
|
|
26
|
-
|
|
27
|
-
Priority order:
|
|
28
|
-
1. **Public API boundaries** (function signatures exposed to other modules or external consumers) — these MUST have explicit, accurate types
|
|
29
|
-
2. **Data layer** (database queries, API responses, data transformations) — where runtime data enters the typed world
|
|
30
|
-
3. **Business logic** (core domain functions) — where incorrect types cause incorrect behavior
|
|
31
|
-
4. **Internal utilities** — lower risk but still worth typing correctly
|
|
32
|
-
5. **Test files** — lowest priority, but remove `any` where it's easy
|
|
33
|
-
|
|
34
|
-
For each fix:
|
|
35
|
-
- Replace `any` with the actual type. If you're not sure what the type should be, read the code that produces and consumes the value to infer it.
|
|
36
|
-
- Replace type assertions with proper type narrowing (type guards, conditional checks, discriminated unions)
|
|
37
|
-
- Remove `@ts-ignore` by fixing the underlying type error
|
|
38
|
-
- Add return type annotations to functions that are missing them
|
|
39
|
-
- Add parameter type annotations where missing
|
|
40
|
-
- Run tests after each batch of related changes
|
|
41
|
-
- Commit: `chore: strengthen types in [module]`
|
|
42
|
-
|
|
43
|
-
**Step 3: Identify structural type improvements**
|
|
44
|
-
Some type weaknesses require larger refactoring. Don't implement these — document them:
|
|
45
|
-
- Places where a discriminated union would prevent impossible states
|
|
46
|
-
- Places where branded types would prevent mixing up similar primitives (userId vs. orderId)
|
|
47
|
-
- Places where generics would replace duplicated type definitions
|
|
48
|
-
- Places where `unknown` should replace `any` as a safer intermediate step
|
|
49
|
-
|
|
50
|
-
**If the project uses JavaScript (no TypeScript):**
|
|
51
|
-
- Add JSDoc type annotations to all public functions
|
|
52
|
-
- Identify functions where input types are ambiguous and document what they actually accept
|
|
53
|
-
- Look for implicit type coercion bugs (== vs ===, string + number, truthy/falsy checks on 0 or "")
|
|
54
|
-
- Look for functions that sometimes return different types (string | undefined | null) without the callers handling all cases
|
|
55
|
-
- Document which files/modules would benefit most from TypeScript migration
|
|
56
|
-
|
|
57
|
-
**If the project uses Python:**
|
|
58
|
-
- Add type hints to all public functions missing them
|
|
59
|
-
- Run mypy or pyright if configured and fix reported issues
|
|
60
|
-
- Look for functions with ambiguous return types (sometimes returns None, sometimes a value)
|
|
61
|
-
- Check for unsafe dict access without `.get()` or key checks
|
|
62
|
-
- Look for broad `except` clauses that swallow type errors
|
|
63
|
-
|
|
64
|
-
### Phase 2: Error Handling Audit & Improvement
|
|
65
|
-
|
|
66
|
-
**Step 1: Find error handling problems**
|
|
67
|
-
|
|
68
|
-
Scan the entire codebase for:
|
|
69
|
-
- **Empty catch blocks**: `catch (e) {}` or `catch (e) { // TODO }` — errors being silently swallowed
|
|
70
|
-
- **Catch-and-log-only**: `catch (e) { console.log(e) }` with no recovery, re-throw, or user notification
|
|
71
|
-
- **Overly broad catches**: Catching all exceptions when only specific ones are expected
|
|
72
|
-
- **Missing catches entirely**: Async operations with no error handling (unhandled promise rejections, uncaught async errors)
|
|
73
|
-
- **Inconsistent error response formats**: API endpoints returning errors in different shapes (`{ error: msg }` vs `{ message: msg }` vs `{ errors: [...] }`)
|
|
74
|
-
- **Error information leakage**: Stack traces, internal paths, database details, or system information exposed in error responses
|
|
75
|
-
- **Missing error boundaries**: React error boundaries (if React), global error handlers, unhandled rejection handlers
|
|
76
|
-
- **String errors**: `throw "something went wrong"` instead of proper Error objects
|
|
77
|
-
- **Error swallowing in chains**: `.catch(() => null)` or `.catch(() => {})` in promise chains
|
|
78
|
-
- **Missing finally blocks**: Resources (connections, file handles, streams) that aren't cleaned up on error
|
|
79
|
-
|
|
80
|
-
**Step 2: Fix error handling issues**
|
|
81
|
-
|
|
82
|
-
Priority order:
|
|
83
|
-
1. **Silent error swallowing** — these are the most dangerous because they hide bugs
|
|
84
|
-
2. **Unhandled async errors** — these crash processes in production
|
|
85
|
-
3. **Information leakage** — security concern
|
|
86
|
-
4. **Inconsistent error formats** — user/developer experience
|
|
87
|
-
5. **Missing cleanup** — resource leaks
|
|
88
|
-
|
|
89
|
-
For each fix:
|
|
90
|
-
- Empty catch blocks: Either handle the error properly, re-throw it, or at minimum log it with context about WHERE and WHY
|
|
91
|
-
- Overly broad catches: Narrow to specific error types, re-throw unexpected errors
|
|
92
|
-
- Missing error handling: Add appropriate try/catch or .catch() handlers
|
|
93
|
-
- Inconsistent formats: Identify the dominant pattern in the codebase and align deviations to it
|
|
94
|
-
- String errors: Convert to proper Error objects (or custom error classes if the project has them)
|
|
95
|
-
- Run tests after each batch of changes
|
|
96
|
-
- Commit: `fix: improve error handling in [module]`
|
|
97
|
-
|
|
98
|
-
**Step 3: Error handling infrastructure**
|
|
99
|
-
Evaluate and document (don't necessarily implement):
|
|
100
|
-
- Does the project have custom error classes? Should it?
|
|
101
|
-
- Is there a global error handler? Is it comprehensive?
|
|
102
|
-
- Is there an error reporting/monitoring integration? Are errors actually reaching it?
|
|
103
|
-
- Are errors being logged with sufficient context to debug them?
|
|
104
|
-
- Is there a consistent pattern for operational errors (expected, like "user not found") vs programmer errors (unexpected, like null reference)?
|
|
105
|
-
|
|
106
|
-
## Output Requirements
|
|
107
|
-
|
|
108
|
-
Create the `audit-reports/` directory in the project root if it doesn't already exist. Save the report as `audit-reports/15_TYPE_SAFETY_REPORT_[run-number]_[date]_[time in user's local time].md` (e.g., `15_TYPE_SAFETY_REPORT_01_2026-02-16_2129.md`). Increment the run number based on any existing reports with the same name prefix in that folder.
|
|
109
|
-
|
|
110
|
-
### Report Structure
|
|
111
|
-
|
|
112
|
-
1. **Summary**
|
|
113
|
-
- `any` types removed: X
|
|
114
|
-
- Type assertions replaced with proper narrowing: X
|
|
115
|
-
- `@ts-ignore` comments removed: X
|
|
116
|
-
- Return type annotations added: X
|
|
117
|
-
- Empty catch blocks fixed: X
|
|
118
|
-
- Unhandled async errors fixed: X
|
|
119
|
-
- Error format inconsistencies fixed: X
|
|
120
|
-
- Tests still passing: yes/no
|
|
121
|
-
|
|
122
|
-
2. **Type Safety Improvements Made**
|
|
123
|
-
- Table: | File | Change | Risk Level | Before → After |
|
|
124
|
-
|
|
125
|
-
3. **Type Safety Improvements Recommended (Not Implemented)**
|
|
126
|
-
- Structural improvements that need team discussion
|
|
127
|
-
- Files/modules that need larger refactoring
|
|
128
|
-
|
|
129
|
-
4. **Error Handling Fixes Made**
|
|
130
|
-
- Table: | File | Issue | Fix Applied |
|
|
131
|
-
|
|
132
|
-
5. **Error Handling Infrastructure Assessment**
|
|
133
|
-
- Current state of error handling patterns
|
|
134
|
-
- What's good, what's missing, what needs work
|
|
135
|
-
|
|
136
|
-
6. **Bugs Discovered**
|
|
137
|
-
- Type errors or error handling gaps that revealed actual bugs
|
|
138
|
-
- These are high-value findings — highlight them
|
|
139
|
-
|
|
140
|
-
7. **Recommendations**
|
|
141
|
-
- Suggested tsconfig.json strict mode changes (with impact assessment)
|
|
142
|
-
- Error handling patterns the team should adopt
|
|
143
|
-
- Custom error classes to create
|
|
144
|
-
|
|
145
|
-
## Rules
|
|
146
|
-
- Branch: `robustness-hardening-[date]`
|
|
147
|
-
- Run tests after EVERY batch of changes. No exceptions.
|
|
148
|
-
- If tests fail, revert and document why
|
|
149
|
-
- DO NOT change business logic. Your job is to make existing logic more type-safe and more resilient to errors, not to change what it does.
|
|
150
|
-
- When replacing `any`, use the ACTUAL correct type — don't just replace `any` with `unknown` everywhere as a cop-out (though `unknown` is appropriate in some cases)
|
|
151
|
-
- When fixing error handling, preserve the existing error recovery intent — if a catch block returns a default value, keep that behavior but add logging
|
|
152
|
-
- Match existing code style and conventions
|
|
153
|
-
- You have all night. Be thorough. Start with the highest-risk code.
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## Chat Output Requirement
|
|
157
|
-
|
|
158
|
-
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:
|
|
159
|
-
|
|
160
|
-
### 1. Status Line
|
|
161
|
-
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
162
|
-
|
|
163
|
-
### 2. Key Findings
|
|
164
|
-
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
165
|
-
|
|
166
|
-
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
167
|
-
**Bad:** "Found some issues with backups."
|
|
168
|
-
|
|
169
|
-
### 3. Changes Made (if applicable)
|
|
170
|
-
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
171
|
-
|
|
172
|
-
### 4. Recommendations
|
|
173
|
-
|
|
174
|
-
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.
|
|
175
|
-
|
|
176
|
-
When recommendations exist, use this table format:
|
|
177
|
-
|
|
178
|
-
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
179
|
-
|---|---|---|---|---|---|
|
|
180
|
-
| *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* |
|
|
181
|
-
|
|
182
|
-
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.
|
|
183
|
-
|
|
184
|
-
### 5. Report Location
|
|
185
|
-
State the full path to the detailed report file for deeper review.
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
**Formatting rules for chat output:**
|
|
190
|
-
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
191
|
-
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
192
|
-
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
1
|
+
# Type Safety & Error Handling Hardening
|
|
2
|
+
|
|
3
|
+
## Prompt
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
You are running an overnight robustness hardening pass. You have several hours. Your job is to make the codebase more resilient by strengthening type safety and error handling. You will be modifying code — every change must keep tests passing.
|
|
7
|
+
|
|
8
|
+
Work on a branch called `robustness-hardening-[date]`.
|
|
9
|
+
|
|
10
|
+
## Your Mission
|
|
11
|
+
|
|
12
|
+
### Phase 1: Type Safety Audit & Improvement
|
|
13
|
+
|
|
14
|
+
**If the project uses TypeScript:**
|
|
15
|
+
|
|
16
|
+
**Step 1: Find type weakness hotspots**
|
|
17
|
+
- Search for every instance of `any` type (explicit `any`, implicit `any` from missing annotations)
|
|
18
|
+
- Search for type assertions (`as`, `!` non-null assertions) — each one is a place where you're telling the compiler "trust me" instead of proving correctness
|
|
19
|
+
- Search for `@ts-ignore` and `@ts-expect-error` comments
|
|
20
|
+
- Check `tsconfig.json` — note which strict mode options are disabled and what they'd catch if enabled
|
|
21
|
+
- Look for functions with no return type annotation
|
|
22
|
+
- Look for function parameters with no type annotation
|
|
23
|
+
- Find places where `Object`, `Function`, `{}`, or `unknown` are used as types
|
|
24
|
+
|
|
25
|
+
**Step 2: Fix type weaknesses, starting with highest risk**
|
|
26
|
+
|
|
27
|
+
Priority order:
|
|
28
|
+
1. **Public API boundaries** (function signatures exposed to other modules or external consumers) — these MUST have explicit, accurate types
|
|
29
|
+
2. **Data layer** (database queries, API responses, data transformations) — where runtime data enters the typed world
|
|
30
|
+
3. **Business logic** (core domain functions) — where incorrect types cause incorrect behavior
|
|
31
|
+
4. **Internal utilities** — lower risk but still worth typing correctly
|
|
32
|
+
5. **Test files** — lowest priority, but remove `any` where it's easy
|
|
33
|
+
|
|
34
|
+
For each fix:
|
|
35
|
+
- Replace `any` with the actual type. If you're not sure what the type should be, read the code that produces and consumes the value to infer it.
|
|
36
|
+
- Replace type assertions with proper type narrowing (type guards, conditional checks, discriminated unions)
|
|
37
|
+
- Remove `@ts-ignore` by fixing the underlying type error
|
|
38
|
+
- Add return type annotations to functions that are missing them
|
|
39
|
+
- Add parameter type annotations where missing
|
|
40
|
+
- Run tests after each batch of related changes
|
|
41
|
+
- Commit: `chore: strengthen types in [module]`
|
|
42
|
+
|
|
43
|
+
**Step 3: Identify structural type improvements**
|
|
44
|
+
Some type weaknesses require larger refactoring. Don't implement these — document them:
|
|
45
|
+
- Places where a discriminated union would prevent impossible states
|
|
46
|
+
- Places where branded types would prevent mixing up similar primitives (userId vs. orderId)
|
|
47
|
+
- Places where generics would replace duplicated type definitions
|
|
48
|
+
- Places where `unknown` should replace `any` as a safer intermediate step
|
|
49
|
+
|
|
50
|
+
**If the project uses JavaScript (no TypeScript):**
|
|
51
|
+
- Add JSDoc type annotations to all public functions
|
|
52
|
+
- Identify functions where input types are ambiguous and document what they actually accept
|
|
53
|
+
- Look for implicit type coercion bugs (== vs ===, string + number, truthy/falsy checks on 0 or "")
|
|
54
|
+
- Look for functions that sometimes return different types (string | undefined | null) without the callers handling all cases
|
|
55
|
+
- Document which files/modules would benefit most from TypeScript migration
|
|
56
|
+
|
|
57
|
+
**If the project uses Python:**
|
|
58
|
+
- Add type hints to all public functions missing them
|
|
59
|
+
- Run mypy or pyright if configured and fix reported issues
|
|
60
|
+
- Look for functions with ambiguous return types (sometimes returns None, sometimes a value)
|
|
61
|
+
- Check for unsafe dict access without `.get()` or key checks
|
|
62
|
+
- Look for broad `except` clauses that swallow type errors
|
|
63
|
+
|
|
64
|
+
### Phase 2: Error Handling Audit & Improvement
|
|
65
|
+
|
|
66
|
+
**Step 1: Find error handling problems**
|
|
67
|
+
|
|
68
|
+
Scan the entire codebase for:
|
|
69
|
+
- **Empty catch blocks**: `catch (e) {}` or `catch (e) { // TODO }` — errors being silently swallowed
|
|
70
|
+
- **Catch-and-log-only**: `catch (e) { console.log(e) }` with no recovery, re-throw, or user notification
|
|
71
|
+
- **Overly broad catches**: Catching all exceptions when only specific ones are expected
|
|
72
|
+
- **Missing catches entirely**: Async operations with no error handling (unhandled promise rejections, uncaught async errors)
|
|
73
|
+
- **Inconsistent error response formats**: API endpoints returning errors in different shapes (`{ error: msg }` vs `{ message: msg }` vs `{ errors: [...] }`)
|
|
74
|
+
- **Error information leakage**: Stack traces, internal paths, database details, or system information exposed in error responses
|
|
75
|
+
- **Missing error boundaries**: React error boundaries (if React), global error handlers, unhandled rejection handlers
|
|
76
|
+
- **String errors**: `throw "something went wrong"` instead of proper Error objects
|
|
77
|
+
- **Error swallowing in chains**: `.catch(() => null)` or `.catch(() => {})` in promise chains
|
|
78
|
+
- **Missing finally blocks**: Resources (connections, file handles, streams) that aren't cleaned up on error
|
|
79
|
+
|
|
80
|
+
**Step 2: Fix error handling issues**
|
|
81
|
+
|
|
82
|
+
Priority order:
|
|
83
|
+
1. **Silent error swallowing** — these are the most dangerous because they hide bugs
|
|
84
|
+
2. **Unhandled async errors** — these crash processes in production
|
|
85
|
+
3. **Information leakage** — security concern
|
|
86
|
+
4. **Inconsistent error formats** — user/developer experience
|
|
87
|
+
5. **Missing cleanup** — resource leaks
|
|
88
|
+
|
|
89
|
+
For each fix:
|
|
90
|
+
- Empty catch blocks: Either handle the error properly, re-throw it, or at minimum log it with context about WHERE and WHY
|
|
91
|
+
- Overly broad catches: Narrow to specific error types, re-throw unexpected errors
|
|
92
|
+
- Missing error handling: Add appropriate try/catch or .catch() handlers
|
|
93
|
+
- Inconsistent formats: Identify the dominant pattern in the codebase and align deviations to it
|
|
94
|
+
- String errors: Convert to proper Error objects (or custom error classes if the project has them)
|
|
95
|
+
- Run tests after each batch of changes
|
|
96
|
+
- Commit: `fix: improve error handling in [module]`
|
|
97
|
+
|
|
98
|
+
**Step 3: Error handling infrastructure**
|
|
99
|
+
Evaluate and document (don't necessarily implement):
|
|
100
|
+
- Does the project have custom error classes? Should it?
|
|
101
|
+
- Is there a global error handler? Is it comprehensive?
|
|
102
|
+
- Is there an error reporting/monitoring integration? Are errors actually reaching it?
|
|
103
|
+
- Are errors being logged with sufficient context to debug them?
|
|
104
|
+
- Is there a consistent pattern for operational errors (expected, like "user not found") vs programmer errors (unexpected, like null reference)?
|
|
105
|
+
|
|
106
|
+
## Output Requirements
|
|
107
|
+
|
|
108
|
+
Create the `audit-reports/` directory in the project root if it doesn't already exist. Save the report as `audit-reports/15_TYPE_SAFETY_REPORT_[run-number]_[date]_[time in user's local time].md` (e.g., `15_TYPE_SAFETY_REPORT_01_2026-02-16_2129.md`). Increment the run number based on any existing reports with the same name prefix in that folder.
|
|
109
|
+
|
|
110
|
+
### Report Structure
|
|
111
|
+
|
|
112
|
+
1. **Summary**
|
|
113
|
+
- `any` types removed: X
|
|
114
|
+
- Type assertions replaced with proper narrowing: X
|
|
115
|
+
- `@ts-ignore` comments removed: X
|
|
116
|
+
- Return type annotations added: X
|
|
117
|
+
- Empty catch blocks fixed: X
|
|
118
|
+
- Unhandled async errors fixed: X
|
|
119
|
+
- Error format inconsistencies fixed: X
|
|
120
|
+
- Tests still passing: yes/no
|
|
121
|
+
|
|
122
|
+
2. **Type Safety Improvements Made**
|
|
123
|
+
- Table: | File | Change | Risk Level | Before → After |
|
|
124
|
+
|
|
125
|
+
3. **Type Safety Improvements Recommended (Not Implemented)**
|
|
126
|
+
- Structural improvements that need team discussion
|
|
127
|
+
- Files/modules that need larger refactoring
|
|
128
|
+
|
|
129
|
+
4. **Error Handling Fixes Made**
|
|
130
|
+
- Table: | File | Issue | Fix Applied |
|
|
131
|
+
|
|
132
|
+
5. **Error Handling Infrastructure Assessment**
|
|
133
|
+
- Current state of error handling patterns
|
|
134
|
+
- What's good, what's missing, what needs work
|
|
135
|
+
|
|
136
|
+
6. **Bugs Discovered**
|
|
137
|
+
- Type errors or error handling gaps that revealed actual bugs
|
|
138
|
+
- These are high-value findings — highlight them
|
|
139
|
+
|
|
140
|
+
7. **Recommendations**
|
|
141
|
+
- Suggested tsconfig.json strict mode changes (with impact assessment)
|
|
142
|
+
- Error handling patterns the team should adopt
|
|
143
|
+
- Custom error classes to create
|
|
144
|
+
|
|
145
|
+
## Rules
|
|
146
|
+
- Branch: `robustness-hardening-[date]`
|
|
147
|
+
- Run tests after EVERY batch of changes. No exceptions.
|
|
148
|
+
- If tests fail, revert and document why
|
|
149
|
+
- DO NOT change business logic. Your job is to make existing logic more type-safe and more resilient to errors, not to change what it does.
|
|
150
|
+
- When replacing `any`, use the ACTUAL correct type — don't just replace `any` with `unknown` everywhere as a cop-out (though `unknown` is appropriate in some cases)
|
|
151
|
+
- When fixing error handling, preserve the existing error recovery intent — if a catch block returns a default value, keep that behavior but add logging
|
|
152
|
+
- Match existing code style and conventions
|
|
153
|
+
- You have all night. Be thorough. Start with the highest-risk code.
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Chat Output Requirement
|
|
157
|
+
|
|
158
|
+
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:
|
|
159
|
+
|
|
160
|
+
### 1. Status Line
|
|
161
|
+
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
162
|
+
|
|
163
|
+
### 2. Key Findings
|
|
164
|
+
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
165
|
+
|
|
166
|
+
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
167
|
+
**Bad:** "Found some issues with backups."
|
|
168
|
+
|
|
169
|
+
### 3. Changes Made (if applicable)
|
|
170
|
+
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
171
|
+
|
|
172
|
+
### 4. Recommendations
|
|
173
|
+
|
|
174
|
+
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.
|
|
175
|
+
|
|
176
|
+
When recommendations exist, use this table format:
|
|
177
|
+
|
|
178
|
+
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
179
|
+
|---|---|---|---|---|---|
|
|
180
|
+
| *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* |
|
|
181
|
+
|
|
182
|
+
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.
|
|
183
|
+
|
|
184
|
+
### 5. Report Location
|
|
185
|
+
State the full path to the detailed report file for deeper review.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
**Formatting rules for chat output:**
|
|
190
|
+
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
191
|
+
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
192
|
+
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|