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.
Files changed (37) hide show
  1. package/bin/nightytidy.js +1 -1
  2. package/package.json +1 -1
  3. package/src/agent/git-integration.js +4 -1
  4. package/src/claude.js +1 -1
  5. package/src/prompts/manifest.json +138 -138
  6. package/src/prompts/steps/02-test-coverage.md +181 -181
  7. package/src/prompts/steps/03-test-hardening.md +181 -181
  8. package/src/prompts/steps/04-test-architecture.md +130 -130
  9. package/src/prompts/steps/05-test-consolidation.md +165 -165
  10. package/src/prompts/steps/06-test-quality.md +211 -211
  11. package/src/prompts/steps/07-api-design.md +165 -165
  12. package/src/prompts/steps/08-security-sweep.md +207 -207
  13. package/src/prompts/steps/09-dependency-health.md +217 -217
  14. package/src/prompts/steps/10-codebase-cleanup.md +189 -189
  15. package/src/prompts/steps/11-crosscutting-concerns.md +196 -196
  16. package/src/prompts/steps/12-file-decomposition.md +263 -263
  17. package/src/prompts/steps/13-code-elegance.md +329 -329
  18. package/src/prompts/steps/14-architectural-complexity.md +297 -297
  19. package/src/prompts/steps/15-type-safety.md +192 -192
  20. package/src/prompts/steps/16-logging-error-message.md +173 -173
  21. package/src/prompts/steps/17-data-integrity.md +139 -139
  22. package/src/prompts/steps/18-performance.md +183 -183
  23. package/src/prompts/steps/19-cost-resource-optimization.md +136 -136
  24. package/src/prompts/steps/20-error-recovery.md +145 -145
  25. package/src/prompts/steps/21-race-condition-audit.md +178 -178
  26. package/src/prompts/steps/22-bug-hunt.md +229 -229
  27. package/src/prompts/steps/23-frontend-quality.md +210 -210
  28. package/src/prompts/steps/24-uiux-audit.md +284 -284
  29. package/src/prompts/steps/25-state-management.md +170 -170
  30. package/src/prompts/steps/26-perceived-performance.md +190 -190
  31. package/src/prompts/steps/27-devops.md +165 -165
  32. package/src/prompts/steps/28-scheduled-job-chron-jobs.md +141 -141
  33. package/src/prompts/steps/29-observability.md +152 -152
  34. package/src/prompts/steps/30-backup-check.md +155 -155
  35. package/src/prompts/steps/31-product-polish-ux-friction.md +122 -122
  36. package/src/prompts/steps/32-feature-discovery-opportunity.md +128 -128
  37. package/src/prompts/steps/33-strategic-opportunities.md +217 -217
@@ -1,165 +1,165 @@
1
- You are running an overnight API design and consistency audit. Evaluate the API surface for design consistency, correctness, and HTTP convention adherence — fix safe issues and document the rest.
2
-
3
- Work on branch `api-consistency-[date]`.
4
-
5
- ## Phase 1: API Surface Discovery
6
-
7
- **Step 1: Inventory every endpoint.** For each, document:
8
- - HTTP method, path (including URL params), controller/handler
9
- - Middleware applied (auth, validation, rate limiting, etc.)
10
- - Request body schema, query parameters accepted
11
- - Response body schema per status code
12
- - Whether it's documented (OpenAPI, README, inline) and whether it has tests
13
-
14
- **Step 2: Identify endpoint groupings**
15
- - Organized by resource, feature, or ad hoc?
16
- - Versioned and unversioned endpoints mixed?
17
- - Same-resource endpoints scattered across files?
18
-
19
- ## Phase 2: Naming & URL Consistency
20
-
21
- **Guiding principle:** For each dimension below, either convention is acceptable — but mixing is not. Identify the dominant convention and flag all deviations.
22
-
23
- **URL paths — check for consistency in:**
24
- - Pluralization (`/users/:id` vs `/user/:id`)
25
- - Casing (lowercase-hyphenated, camelCase, snake_case)
26
- - Nesting depth and patterns for related resources
27
- - Action endpoints (`POST /users/:id/activate` vs `PATCH /users/:id { active: true }`)
28
- - ID parameter naming (`:id` vs `:userId` vs `:user_id`)
29
-
30
- **Request/response fields — check for consistency in:**
31
- - Field casing (camelCase vs snake_case)
32
- - Naming patterns for equivalent concepts (`created_at` vs `createdAt` vs `dateCreated`; `id` vs `_id`)
33
- - Boolean naming (`is_active` vs `active` vs `isActive`)
34
- - Collection naming (`items` vs `data` vs `results`)
35
-
36
- Document the dominant convention for each category — this becomes the target for alignment.
37
-
38
- ## Phase 3: HTTP Method & Status Code Correctness
39
-
40
- **Method audit** — verify semantic correctness:
41
- - **GET**: Read-only, no side effects. Flag any GET that modifies data or triggers actions.
42
- - **POST**: Creates a resource or triggers an action. Flag POSTs that are reads or updates.
43
- - **PUT**: Full replacement. Flag PUTs doing partial updates (should be PATCH).
44
- - **PATCH**: Partial update. Flag PATCHes requiring all fields (should be PUT).
45
- - **DELETE**: Removes a resource. Should be idempotent (second call returns 204 or 404).
46
- - **Idempotency**: PUT and DELETE should be idempotent. Verify.
47
-
48
- **Status code audit** — check every returned code:
49
- - 200 vs 201: Resource-creating POSTs should return 201.
50
- - 204 vs 200: Bodyless DELETE/PUT/PATCH responses should use 204.
51
- - 400 vs 422: Pick one convention for validation errors; use it everywhere.
52
- - 401 vs 403: 401 = not authenticated, 403 = not authorized. Flag misuse.
53
- - 404 vs 403: For inaccessible resources — either convention is fine, but be consistent within a resource type.
54
- - Flag: internal errors returned as 4xx, user errors returned as 5xx.
55
- - Empty list results should be 200 with empty array, not 404.
56
-
57
- ## Phase 4: Error Response Consistency
58
-
59
- 1. **Catalog every error response shape** across all endpoints.
60
- 2. **Identify the dominant pattern** — this is the target format.
61
- 3. **Flag deviations** — for each, note: current format, target format, and whether changing it would break consumers.
62
- 4. **Evaluate error quality:**
63
- - Are messages helpful and specific? (Not just "Validation failed")
64
- - Are all field errors returned at once, or fail-on-first?
65
- - Are machine-readable error codes included?
66
- - Is sensitive info leaked? (SQL errors, stack traces, internal paths)
67
- 5. **Fix safe inconsistencies** — align error format where it won't break consumers. Improve unhelpful messages.
68
-
69
- ## Phase 5: Pagination Consistency
70
-
71
- 1. **Find all list endpoints.**
72
- 2. **Audit each:**
73
- - Paginated at all? (Unbounded lists = performance/security risk)
74
- - Strategy: offset/limit, page/perPage, cursor-based?
75
- - Parameter names consistent? (`page` vs `p`, `limit` vs `per_page` vs `pageSize`)
76
- - Default and maximum page size enforced?
77
- - Response includes pagination metadata? (total count, current page, next/prev links) Format consistent?
78
- 3. **Fix safe issues** — add defaults/maximums where missing, standardize param and metadata formats.
79
-
80
- ## Phase 6: Request Validation Consistency
81
-
82
- 1. **Audit validation patterns:**
83
- - Does every input-accepting endpoint have validation?
84
- - What library/approach? Consistent or mixed?
85
- - Where does validation happen? (Middleware, handler, service layer, mixed?)
86
- 2. **Audit validation behavior:**
87
- - Consistent failure status code? Consistent error format (matching Phase 4)?
88
- - All errors returned at once or one at a time?
89
- - Same fields validated the same way across endpoints?
90
- 3. **Fix safe issues** — add missing validation using existing patterns, standardize error format.
91
-
92
- ## Phase 7: Miscellaneous API Quality
93
-
94
- - **Rate limiting**: Coverage, consistent headers (`X-RateLimit-*`), missing on public/auth/expensive endpoints?
95
- - **Versioning**: Strategy, consistency, deprecated endpoints marked?
96
- - **Content types**: JSON endpoints verify `Content-Type` header? Responses include `Content-Type: application/json`?
97
- - **Idempotency**: Write endpoints (especially payments/orders) support idempotency keys? Mechanism consistent?
98
- - **Discoverability** (informational only): Links to related resources? API index endpoint?
99
-
100
- ## Output
101
-
102
- Create `audit-reports/` in project root if needed. Save as `audit-reports/07_API_DESIGN_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
103
-
104
- ### Report Structure
105
-
106
- 1. **Executive Summary** — Consistency score (poor/fair/good/excellent), total endpoints, endpoints with issues, issues fixed, issues documented for review.
107
- 2. **API Surface Map** — Endpoint inventory table: Method | Path | Auth | Validated? | Paginated? | Tested? | Documented? — Plus grouping assessment.
108
- 3. **Naming Conventions** — Dominant conventions table, URL and field inconsistencies with current vs expected, fixes applied.
109
- 4. **HTTP Correctness** — Method misuse and status code issues with recommendations, fixes applied.
110
- 5. **Error Response Consistency** — Dominant format, deviations table, error quality assessment.
111
- 6. **Pagination** — List endpoints table with strategy/params/metadata/max size, inconsistencies and fixes.
112
- 7. **Validation** — Coverage table, unprotected endpoints sorted by risk, fixes applied.
113
- 8. **Miscellaneous** — Rate limiting, versioning, content types, idempotency.
114
- 9. **API Style Guide** — Generate `docs/API_DESIGN_GUIDE.md` codifying dominant patterns for: URL naming, field naming, pagination, error format, status codes, validation. This is the reference for new endpoints.
115
- 10. **Recommendations** — Priority-ordered fixes, breaking changes needing versioning/migration, tooling recommendations.
116
-
117
- ## Rules
118
-
119
- - Branch: `api-consistency-[date]`
120
- - Run tests after every change. Commit with descriptive messages per module.
121
- - **DO NOT** change endpoint URLs or HTTP methods — these are breaking changes. Document as recommendations.
122
- - **DO NOT** change response structure on endpoints with known external consumers — document as recommendations.
123
- - **Safe to fix**: error message wording, missing validation, pagination defaults, rate limit headers, internal/undocumented endpoint standardization.
124
- - Confirm deviations are unintentional before flagging — some may be deliberate exceptions.
125
- - If no dominant convention exists (true 50/50 split), document both and recommend the team decide.
126
- - Generate the API Style Guide regardless of how much you fix.
127
- - Be thorough. Check every endpoint.
128
-
129
- ## Chat Output Requirement
130
-
131
- 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:
132
-
133
- ### 1. Status Line
134
- One sentence: what you did, how long it took, and whether all tests still pass.
135
-
136
- ### 2. Key Findings
137
- The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
138
-
139
- **Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
140
- **Bad:** "Found some issues with backups."
141
-
142
- ### 3. Changes Made (if applicable)
143
- Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
144
-
145
- ### 4. Recommendations
146
-
147
- 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.
148
-
149
- When recommendations exist, use this table format:
150
-
151
- | # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
152
- |---|---|---|---|---|---|
153
- | *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* |
154
-
155
- 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.
156
-
157
- ### 5. Report Location
158
- State the full path to the detailed report file for deeper review.
159
-
160
- ---
161
-
162
- **Formatting rules for chat output:**
163
- - Use markdown headers, bold for severity labels, and bullet points for scannability.
164
- - Do not duplicate the full report contents — just the highlights and recommendations.
165
- - If you made zero findings in a phase, say so in one line rather than omitting it silently.
1
+ You are running an overnight API design and consistency audit. Evaluate the API surface for design consistency, correctness, and HTTP convention adherence — fix safe issues and document the rest.
2
+
3
+ Work on branch `api-consistency-[date]`.
4
+
5
+ ## Phase 1: API Surface Discovery
6
+
7
+ **Step 1: Inventory every endpoint.** For each, document:
8
+ - HTTP method, path (including URL params), controller/handler
9
+ - Middleware applied (auth, validation, rate limiting, etc.)
10
+ - Request body schema, query parameters accepted
11
+ - Response body schema per status code
12
+ - Whether it's documented (OpenAPI, README, inline) and whether it has tests
13
+
14
+ **Step 2: Identify endpoint groupings**
15
+ - Organized by resource, feature, or ad hoc?
16
+ - Versioned and unversioned endpoints mixed?
17
+ - Same-resource endpoints scattered across files?
18
+
19
+ ## Phase 2: Naming & URL Consistency
20
+
21
+ **Guiding principle:** For each dimension below, either convention is acceptable — but mixing is not. Identify the dominant convention and flag all deviations.
22
+
23
+ **URL paths — check for consistency in:**
24
+ - Pluralization (`/users/:id` vs `/user/:id`)
25
+ - Casing (lowercase-hyphenated, camelCase, snake_case)
26
+ - Nesting depth and patterns for related resources
27
+ - Action endpoints (`POST /users/:id/activate` vs `PATCH /users/:id { active: true }`)
28
+ - ID parameter naming (`:id` vs `:userId` vs `:user_id`)
29
+
30
+ **Request/response fields — check for consistency in:**
31
+ - Field casing (camelCase vs snake_case)
32
+ - Naming patterns for equivalent concepts (`created_at` vs `createdAt` vs `dateCreated`; `id` vs `_id`)
33
+ - Boolean naming (`is_active` vs `active` vs `isActive`)
34
+ - Collection naming (`items` vs `data` vs `results`)
35
+
36
+ Document the dominant convention for each category — this becomes the target for alignment.
37
+
38
+ ## Phase 3: HTTP Method & Status Code Correctness
39
+
40
+ **Method audit** — verify semantic correctness:
41
+ - **GET**: Read-only, no side effects. Flag any GET that modifies data or triggers actions.
42
+ - **POST**: Creates a resource or triggers an action. Flag POSTs that are reads or updates.
43
+ - **PUT**: Full replacement. Flag PUTs doing partial updates (should be PATCH).
44
+ - **PATCH**: Partial update. Flag PATCHes requiring all fields (should be PUT).
45
+ - **DELETE**: Removes a resource. Should be idempotent (second call returns 204 or 404).
46
+ - **Idempotency**: PUT and DELETE should be idempotent. Verify.
47
+
48
+ **Status code audit** — check every returned code:
49
+ - 200 vs 201: Resource-creating POSTs should return 201.
50
+ - 204 vs 200: Bodyless DELETE/PUT/PATCH responses should use 204.
51
+ - 400 vs 422: Pick one convention for validation errors; use it everywhere.
52
+ - 401 vs 403: 401 = not authenticated, 403 = not authorized. Flag misuse.
53
+ - 404 vs 403: For inaccessible resources — either convention is fine, but be consistent within a resource type.
54
+ - Flag: internal errors returned as 4xx, user errors returned as 5xx.
55
+ - Empty list results should be 200 with empty array, not 404.
56
+
57
+ ## Phase 4: Error Response Consistency
58
+
59
+ 1. **Catalog every error response shape** across all endpoints.
60
+ 2. **Identify the dominant pattern** — this is the target format.
61
+ 3. **Flag deviations** — for each, note: current format, target format, and whether changing it would break consumers.
62
+ 4. **Evaluate error quality:**
63
+ - Are messages helpful and specific? (Not just "Validation failed")
64
+ - Are all field errors returned at once, or fail-on-first?
65
+ - Are machine-readable error codes included?
66
+ - Is sensitive info leaked? (SQL errors, stack traces, internal paths)
67
+ 5. **Fix safe inconsistencies** — align error format where it won't break consumers. Improve unhelpful messages.
68
+
69
+ ## Phase 5: Pagination Consistency
70
+
71
+ 1. **Find all list endpoints.**
72
+ 2. **Audit each:**
73
+ - Paginated at all? (Unbounded lists = performance/security risk)
74
+ - Strategy: offset/limit, page/perPage, cursor-based?
75
+ - Parameter names consistent? (`page` vs `p`, `limit` vs `per_page` vs `pageSize`)
76
+ - Default and maximum page size enforced?
77
+ - Response includes pagination metadata? (total count, current page, next/prev links) Format consistent?
78
+ 3. **Fix safe issues** — add defaults/maximums where missing, standardize param and metadata formats.
79
+
80
+ ## Phase 6: Request Validation Consistency
81
+
82
+ 1. **Audit validation patterns:**
83
+ - Does every input-accepting endpoint have validation?
84
+ - What library/approach? Consistent or mixed?
85
+ - Where does validation happen? (Middleware, handler, service layer, mixed?)
86
+ 2. **Audit validation behavior:**
87
+ - Consistent failure status code? Consistent error format (matching Phase 4)?
88
+ - All errors returned at once or one at a time?
89
+ - Same fields validated the same way across endpoints?
90
+ 3. **Fix safe issues** — add missing validation using existing patterns, standardize error format.
91
+
92
+ ## Phase 7: Miscellaneous API Quality
93
+
94
+ - **Rate limiting**: Coverage, consistent headers (`X-RateLimit-*`), missing on public/auth/expensive endpoints?
95
+ - **Versioning**: Strategy, consistency, deprecated endpoints marked?
96
+ - **Content types**: JSON endpoints verify `Content-Type` header? Responses include `Content-Type: application/json`?
97
+ - **Idempotency**: Write endpoints (especially payments/orders) support idempotency keys? Mechanism consistent?
98
+ - **Discoverability** (informational only): Links to related resources? API index endpoint?
99
+
100
+ ## Output
101
+
102
+ Create `audit-reports/` in project root if needed. Save as `audit-reports/07_API_DESIGN_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
103
+
104
+ ### Report Structure
105
+
106
+ 1. **Executive Summary** — Consistency score (poor/fair/good/excellent), total endpoints, endpoints with issues, issues fixed, issues documented for review.
107
+ 2. **API Surface Map** — Endpoint inventory table: Method | Path | Auth | Validated? | Paginated? | Tested? | Documented? — Plus grouping assessment.
108
+ 3. **Naming Conventions** — Dominant conventions table, URL and field inconsistencies with current vs expected, fixes applied.
109
+ 4. **HTTP Correctness** — Method misuse and status code issues with recommendations, fixes applied.
110
+ 5. **Error Response Consistency** — Dominant format, deviations table, error quality assessment.
111
+ 6. **Pagination** — List endpoints table with strategy/params/metadata/max size, inconsistencies and fixes.
112
+ 7. **Validation** — Coverage table, unprotected endpoints sorted by risk, fixes applied.
113
+ 8. **Miscellaneous** — Rate limiting, versioning, content types, idempotency.
114
+ 9. **API Style Guide** — Generate `docs/API_DESIGN_GUIDE.md` codifying dominant patterns for: URL naming, field naming, pagination, error format, status codes, validation. This is the reference for new endpoints.
115
+ 10. **Recommendations** — Priority-ordered fixes, breaking changes needing versioning/migration, tooling recommendations.
116
+
117
+ ## Rules
118
+
119
+ - Branch: `api-consistency-[date]`
120
+ - Run tests after every change. Commit with descriptive messages per module.
121
+ - **DO NOT** change endpoint URLs or HTTP methods — these are breaking changes. Document as recommendations.
122
+ - **DO NOT** change response structure on endpoints with known external consumers — document as recommendations.
123
+ - **Safe to fix**: error message wording, missing validation, pagination defaults, rate limit headers, internal/undocumented endpoint standardization.
124
+ - Confirm deviations are unintentional before flagging — some may be deliberate exceptions.
125
+ - If no dominant convention exists (true 50/50 split), document both and recommend the team decide.
126
+ - Generate the API Style Guide regardless of how much you fix.
127
+ - Be thorough. Check every endpoint.
128
+
129
+ ## Chat Output Requirement
130
+
131
+ 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:
132
+
133
+ ### 1. Status Line
134
+ One sentence: what you did, how long it took, and whether all tests still pass.
135
+
136
+ ### 2. Key Findings
137
+ The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
138
+
139
+ **Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
140
+ **Bad:** "Found some issues with backups."
141
+
142
+ ### 3. Changes Made (if applicable)
143
+ Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
144
+
145
+ ### 4. Recommendations
146
+
147
+ 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.
148
+
149
+ When recommendations exist, use this table format:
150
+
151
+ | # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
152
+ |---|---|---|---|---|---|
153
+ | *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* |
154
+
155
+ 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.
156
+
157
+ ### 5. Report Location
158
+ State the full path to the detailed report file for deeper review.
159
+
160
+ ---
161
+
162
+ **Formatting rules for chat output:**
163
+ - Use markdown headers, bold for severity labels, and bullet points for scannability.
164
+ - Do not duplicate the full report contents — just the highlights and recommendations.
165
+ - If you made zero findings in a phase, say so in one line rather than omitting it silently.