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,190 +1,190 @@
1
- # Perceived Performance Optimization
2
-
3
- Run an overnight pass to make the app *feel* instant. Real speed gains are ideal, but perceived speed is the goal. A 500ms operation that feels instant beats a 200ms one the user waits for.
4
-
5
- Branch: `snappy-[date]`. Commit format: `perf: [what] in [where]`
6
-
7
- ## Global Rules
8
-
9
- - Run tests after every change.
10
- - DO NOT change business logic — only *when/how* data loads and how the UI responds.
11
- - DO NOT add dependencies unless the project has equivalents; document as recommendations instead.
12
- - DO NOT ship optimistic updates that can't be safely rolled back on error.
13
- - Be honest about real vs. perceived speed gains in the report.
14
- - Prioritize by frequency × impact. Critical path > settings page.
15
-
16
- ---
17
-
18
- ## Phase 1: Critical Path Mapping
19
-
20
- ### 1. Identify top 5–10 user journeys
21
- App startup, auth, main dashboard, core CRUD workflow, navigation between sections, search/filtering, write actions.
22
-
23
- ### 2. Trace the loading waterfall for each
24
- For each journey document: trigger → requests (order, serial vs. parallel) → what blocks rendering → what user sees while waiting → total time to interactive.
25
-
26
- ### 3. Rank waits by impact
27
- **Priority = Duration × Frequency × Emptiness × Intent.** Blank screen + high frequency + user just clicked = fix first.
28
-
29
- ---
30
-
31
- ## Phase 2: Prefetching & Preloading
32
-
33
- ### Route-level prefetching
34
- - **Hover/focus**: Start fetching destination data on link hover (~200ms head start).
35
- - **Predictive**: After login → prefetch dashboard. After create → prefetch detail view. After list → prefetch top item. Paginated lists → prefetch next page.
36
- - **Router-level**: Fetch data in parallel with code-splitting chunk load (loader pattern > useEffect pattern).
37
- - Check if data-fetching library prefetch utilities (React Query, SWR, Apollo) exist but aren't used.
38
-
39
- ### Asset preloading
40
- - Images below fold / next screen: `<link rel="preload">` or `new Image().src`
41
- - Fonts: preload in `<head>` to avoid FOIT/FOUT
42
- - Code chunks: `<link rel="prefetch">` or idle `import()` for likely-next routes
43
- - Configs/feature flags: fetch early in boot, not lazily on first use
44
-
45
- ### Cache warming
46
- - Warm caches on startup for commonly accessed data.
47
- - After writes, update cache immediately (or invalidate + refetch).
48
- - Use stale-while-revalidate where appropriate.
49
-
50
- ---
51
-
52
- ## Phase 3: Optimistic UI & Instant Feedback
53
-
54
- ### Audit every mutation
55
- For each create/update/delete/toggle: Is the outcome predictable? What's the failure rate? Can it roll back cleanly?
56
-
57
- ### Good candidates for optimistic updates
58
- Toggles, list adds/removes, text field saves, reordering, simple status transitions.
59
-
60
- ### Bad candidates
61
- Payments, complex server validation, actions with unpredictable side effects (emails, webhooks).
62
-
63
- ### Pattern
64
- ```
65
- // Optimistic: update UI instantly, rollback on error
66
- const prev = item.isFavorite;
67
- setItem({ ...item, isFavorite: !prev });
68
- try { await api.toggleFavorite(id); }
69
- catch { setItem({ ...item, isFavorite: prev }); showErrorToast(); }
70
- ```
71
-
72
- Check if the data-fetching library's built-in optimistic mechanisms are being used.
73
-
74
- ### Instant feedback even without optimistic updates
75
- Every click/tap should produce immediate visual response: button pressed state, skeleton appearance, item fade-out on delete, shell render on navigation.
76
-
77
- ---
78
-
79
- ## Phase 4: Waterfall Elimination
80
-
81
- ### Find sequential chains that should be parallel
82
- ```
83
- // BAD: 650ms serial
84
- const user = await fetchUser();
85
- const prefs = await fetchPreferences(user.id);
86
- const dashboard = await fetchDashboard(user.id);
87
-
88
- // GOOD: 300ms parallel (prefs + dashboard don't depend on each other)
89
- const user = await fetchUser();
90
- const [prefs, dashboard] = await Promise.all([
91
- fetchPreferences(user.id), fetchDashboard(user.id)
92
- ]);
93
- ```
94
-
95
- **Common waterfalls**: nested component fetches, config → user → data chains, list → per-item detail fetches, auth → route data → component data.
96
-
97
- ### Fix
98
- - Lift fetching to route level and fire in parallel.
99
- - Use `Promise.all`/`Promise.allSettled` for independent requests.
100
- - Render partially with early data; show skeletons for slow data.
101
- - Backend: parallelize independent DB/API calls; split slow sub-queries into separate lazy endpoints.
102
-
103
- ---
104
-
105
- ## Phase 5: Rendering & Visual Continuity
106
-
107
- ### Loading state hierarchy (worst → best)
108
- Blank screen → full-page spinner → skeleton screen → stale-while-revalidate
109
-
110
- **Fix**: Every page renders its shell instantly. Replace spinners with skeletons or stale content.
111
-
112
- ### Progressive rendering
113
- Don't gate entire pages on slowest data. Render fast sections immediately, skeleton the rest.
114
-
115
- ### Transitions
116
- - Fix layout shifts: skeleton dimensions must match real content.
117
- - Route transitions: show destination shell immediately, not blank screen.
118
- - List mutations: animate add/remove, don't pop.
119
- - Above-the-fold first; lazy-load below-fold with intersection observer.
120
- - Large lists (50+ items): consider virtual scrolling.
121
-
122
- ---
123
-
124
- ## Phase 6: Caching & Network
125
-
126
- - **HTTP caching**: Proper `Cache-Control` headers? Static assets with content-hash + long TTL?
127
- - **Client caching**: `staleTime`/`cacheTime` configured? (Default 0 = always refetch.) Set appropriately: user profile ~5min, catalog ~1min, live feed ~10s.
128
- - **Deduplication**: Multiple components requesting same data → one request or many?
129
- - **Batching**: Can many small requests become one batch request?
130
- - **Cache invalidation**: Do writes update all views displaying that resource?
131
-
132
- ---
133
-
134
- ## Phase 7: Startup Speed
135
-
136
- ### Audit boot sequence
137
- HTML → CSS (render-blocking?) → JS (bundle size?) → framework hydration → data fetches → first paint → interactive.
138
-
139
- ### Common blockers
140
- Render-blocking scripts (missing `async`/`defer`), large unsplit bundles, sequential boot chains (auth → config → data → render), eager non-critical init (analytics, chat widgets).
141
-
142
- ### Fix
143
- - Defer non-critical scripts until after first interactive render.
144
- - Inline critical CSS.
145
- - Parallelize boot: session + config + page data simultaneously.
146
- - Consider rendering app shell before auth completes.
147
-
148
- ---
149
-
150
- ## Phase 8: Micro-Interactions
151
-
152
- - **Click/tap feedback**: Eliminate delays. All interactive elements need `:active`/`:hover` states. 150ms ease-out transitions on state changes.
153
- - **Animation as perception**: Fade/slide content in after load. Animate modals/drawers open (~200ms). Prefer determinate progress bars over indeterminate spinners.
154
- - **Debounce/throttle**: Search: 150–300ms debounce (not 500ms+). Scroll/resize handlers: throttled/rAF. Auto-save: debounced, no conflict with manual save.
155
- - **Forms**: Instant confirmation after submit (toast). Inline validation as user types. Re-enable on failure. Prefetch next step in multi-step forms.
156
-
157
- ---
158
-
159
- ## Output
160
-
161
- Save to `audit-reports/26_PERCEIVED_PERFORMANCE_REPORT_[run-number]_[date]_[time in user's local time].md`.
162
-
163
- ### Report Sections
164
- 1. **Executive Summary** — Snappiness rating (sluggish → instant-feeling), worst waits, changes made.
165
- 2. **Critical Path Analysis** — Waterfall diagrams, per-journey wait times, ranked by impact.
166
- 3. **Prefetching** — Opportunities, implementations, estimated time saved.
167
- 4. **Optimistic UI** — Mutations audited, which got optimistic treatment, which were too risky.
168
- 5. **Waterfall Elimination** — Before/after for parallelized chains, time saved.
169
- 6. **Rendering** — Loading state upgrades, progressive rendering, layout shift fixes.
170
- 7. **Caching** — Strategy per endpoint, deduplication fixes, header improvements.
171
- 8. **Startup** — Boot timeline before/after, blockers removed.
172
- 9. **Micro-Interactions** — Responsiveness, animation, debounce, form UX fixes.
173
- 10. **Measurements** — Before/after per journey; distinguish real vs. perceived gains.
174
- 11. **Recommendations** — Priority-ordered remaining work.
175
-
176
- ### Chat Summary (required)
177
- Print directly in conversation:
178
-
179
- 1. **Status** — One sentence: what you did, test status.
180
- 2. **Key Findings** — Specific, actionable bullets with user impact. (e.g., "Dashboard loads 4 API calls sequentially = 1.2s. Parallelizing → ~400ms.")
181
- 3. **Changes Made** — What was modified. Skip if read-only run.
182
- 4. **Recommendations** (if any) — Table:
183
-
184
- | # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
185
- |---|---|---|---|---|---|
186
- | | ≤10 words | What improves | Low–Critical | Yes/Probably/If time | 1–3 sentences |
187
-
188
- Order by risk descending. Be honest — not everything is worth the engineering time.
189
-
190
- 5. **Report Location** — Full file path.
1
+ # Perceived Performance Optimization
2
+
3
+ Run an overnight pass to make the app *feel* instant. Real speed gains are ideal, but perceived speed is the goal. A 500ms operation that feels instant beats a 200ms one the user waits for.
4
+
5
+ Branch: `snappy-[date]`. Commit format: `perf: [what] in [where]`
6
+
7
+ ## Global Rules
8
+
9
+ - Run tests after every change.
10
+ - DO NOT change business logic — only *when/how* data loads and how the UI responds.
11
+ - DO NOT add dependencies unless the project has equivalents; document as recommendations instead.
12
+ - DO NOT ship optimistic updates that can't be safely rolled back on error.
13
+ - Be honest about real vs. perceived speed gains in the report.
14
+ - Prioritize by frequency × impact. Critical path > settings page.
15
+
16
+ ---
17
+
18
+ ## Phase 1: Critical Path Mapping
19
+
20
+ ### 1. Identify top 5–10 user journeys
21
+ App startup, auth, main dashboard, core CRUD workflow, navigation between sections, search/filtering, write actions.
22
+
23
+ ### 2. Trace the loading waterfall for each
24
+ For each journey document: trigger → requests (order, serial vs. parallel) → what blocks rendering → what user sees while waiting → total time to interactive.
25
+
26
+ ### 3. Rank waits by impact
27
+ **Priority = Duration × Frequency × Emptiness × Intent.** Blank screen + high frequency + user just clicked = fix first.
28
+
29
+ ---
30
+
31
+ ## Phase 2: Prefetching & Preloading
32
+
33
+ ### Route-level prefetching
34
+ - **Hover/focus**: Start fetching destination data on link hover (~200ms head start).
35
+ - **Predictive**: After login → prefetch dashboard. After create → prefetch detail view. After list → prefetch top item. Paginated lists → prefetch next page.
36
+ - **Router-level**: Fetch data in parallel with code-splitting chunk load (loader pattern > useEffect pattern).
37
+ - Check if data-fetching library prefetch utilities (React Query, SWR, Apollo) exist but aren't used.
38
+
39
+ ### Asset preloading
40
+ - Images below fold / next screen: `<link rel="preload">` or `new Image().src`
41
+ - Fonts: preload in `<head>` to avoid FOIT/FOUT
42
+ - Code chunks: `<link rel="prefetch">` or idle `import()` for likely-next routes
43
+ - Configs/feature flags: fetch early in boot, not lazily on first use
44
+
45
+ ### Cache warming
46
+ - Warm caches on startup for commonly accessed data.
47
+ - After writes, update cache immediately (or invalidate + refetch).
48
+ - Use stale-while-revalidate where appropriate.
49
+
50
+ ---
51
+
52
+ ## Phase 3: Optimistic UI & Instant Feedback
53
+
54
+ ### Audit every mutation
55
+ For each create/update/delete/toggle: Is the outcome predictable? What's the failure rate? Can it roll back cleanly?
56
+
57
+ ### Good candidates for optimistic updates
58
+ Toggles, list adds/removes, text field saves, reordering, simple status transitions.
59
+
60
+ ### Bad candidates
61
+ Payments, complex server validation, actions with unpredictable side effects (emails, webhooks).
62
+
63
+ ### Pattern
64
+ ```
65
+ // Optimistic: update UI instantly, rollback on error
66
+ const prev = item.isFavorite;
67
+ setItem({ ...item, isFavorite: !prev });
68
+ try { await api.toggleFavorite(id); }
69
+ catch { setItem({ ...item, isFavorite: prev }); showErrorToast(); }
70
+ ```
71
+
72
+ Check if the data-fetching library's built-in optimistic mechanisms are being used.
73
+
74
+ ### Instant feedback even without optimistic updates
75
+ Every click/tap should produce immediate visual response: button pressed state, skeleton appearance, item fade-out on delete, shell render on navigation.
76
+
77
+ ---
78
+
79
+ ## Phase 4: Waterfall Elimination
80
+
81
+ ### Find sequential chains that should be parallel
82
+ ```
83
+ // BAD: 650ms serial
84
+ const user = await fetchUser();
85
+ const prefs = await fetchPreferences(user.id);
86
+ const dashboard = await fetchDashboard(user.id);
87
+
88
+ // GOOD: 300ms parallel (prefs + dashboard don't depend on each other)
89
+ const user = await fetchUser();
90
+ const [prefs, dashboard] = await Promise.all([
91
+ fetchPreferences(user.id), fetchDashboard(user.id)
92
+ ]);
93
+ ```
94
+
95
+ **Common waterfalls**: nested component fetches, config → user → data chains, list → per-item detail fetches, auth → route data → component data.
96
+
97
+ ### Fix
98
+ - Lift fetching to route level and fire in parallel.
99
+ - Use `Promise.all`/`Promise.allSettled` for independent requests.
100
+ - Render partially with early data; show skeletons for slow data.
101
+ - Backend: parallelize independent DB/API calls; split slow sub-queries into separate lazy endpoints.
102
+
103
+ ---
104
+
105
+ ## Phase 5: Rendering & Visual Continuity
106
+
107
+ ### Loading state hierarchy (worst → best)
108
+ Blank screen → full-page spinner → skeleton screen → stale-while-revalidate
109
+
110
+ **Fix**: Every page renders its shell instantly. Replace spinners with skeletons or stale content.
111
+
112
+ ### Progressive rendering
113
+ Don't gate entire pages on slowest data. Render fast sections immediately, skeleton the rest.
114
+
115
+ ### Transitions
116
+ - Fix layout shifts: skeleton dimensions must match real content.
117
+ - Route transitions: show destination shell immediately, not blank screen.
118
+ - List mutations: animate add/remove, don't pop.
119
+ - Above-the-fold first; lazy-load below-fold with intersection observer.
120
+ - Large lists (50+ items): consider virtual scrolling.
121
+
122
+ ---
123
+
124
+ ## Phase 6: Caching & Network
125
+
126
+ - **HTTP caching**: Proper `Cache-Control` headers? Static assets with content-hash + long TTL?
127
+ - **Client caching**: `staleTime`/`cacheTime` configured? (Default 0 = always refetch.) Set appropriately: user profile ~5min, catalog ~1min, live feed ~10s.
128
+ - **Deduplication**: Multiple components requesting same data → one request or many?
129
+ - **Batching**: Can many small requests become one batch request?
130
+ - **Cache invalidation**: Do writes update all views displaying that resource?
131
+
132
+ ---
133
+
134
+ ## Phase 7: Startup Speed
135
+
136
+ ### Audit boot sequence
137
+ HTML → CSS (render-blocking?) → JS (bundle size?) → framework hydration → data fetches → first paint → interactive.
138
+
139
+ ### Common blockers
140
+ Render-blocking scripts (missing `async`/`defer`), large unsplit bundles, sequential boot chains (auth → config → data → render), eager non-critical init (analytics, chat widgets).
141
+
142
+ ### Fix
143
+ - Defer non-critical scripts until after first interactive render.
144
+ - Inline critical CSS.
145
+ - Parallelize boot: session + config + page data simultaneously.
146
+ - Consider rendering app shell before auth completes.
147
+
148
+ ---
149
+
150
+ ## Phase 8: Micro-Interactions
151
+
152
+ - **Click/tap feedback**: Eliminate delays. All interactive elements need `:active`/`:hover` states. 150ms ease-out transitions on state changes.
153
+ - **Animation as perception**: Fade/slide content in after load. Animate modals/drawers open (~200ms). Prefer determinate progress bars over indeterminate spinners.
154
+ - **Debounce/throttle**: Search: 150–300ms debounce (not 500ms+). Scroll/resize handlers: throttled/rAF. Auto-save: debounced, no conflict with manual save.
155
+ - **Forms**: Instant confirmation after submit (toast). Inline validation as user types. Re-enable on failure. Prefetch next step in multi-step forms.
156
+
157
+ ---
158
+
159
+ ## Output
160
+
161
+ Save to `audit-reports/26_PERCEIVED_PERFORMANCE_REPORT_[run-number]_[date]_[time in user's local time].md`.
162
+
163
+ ### Report Sections
164
+ 1. **Executive Summary** — Snappiness rating (sluggish → instant-feeling), worst waits, changes made.
165
+ 2. **Critical Path Analysis** — Waterfall diagrams, per-journey wait times, ranked by impact.
166
+ 3. **Prefetching** — Opportunities, implementations, estimated time saved.
167
+ 4. **Optimistic UI** — Mutations audited, which got optimistic treatment, which were too risky.
168
+ 5. **Waterfall Elimination** — Before/after for parallelized chains, time saved.
169
+ 6. **Rendering** — Loading state upgrades, progressive rendering, layout shift fixes.
170
+ 7. **Caching** — Strategy per endpoint, deduplication fixes, header improvements.
171
+ 8. **Startup** — Boot timeline before/after, blockers removed.
172
+ 9. **Micro-Interactions** — Responsiveness, animation, debounce, form UX fixes.
173
+ 10. **Measurements** — Before/after per journey; distinguish real vs. perceived gains.
174
+ 11. **Recommendations** — Priority-ordered remaining work.
175
+
176
+ ### Chat Summary (required)
177
+ Print directly in conversation:
178
+
179
+ 1. **Status** — One sentence: what you did, test status.
180
+ 2. **Key Findings** — Specific, actionable bullets with user impact. (e.g., "Dashboard loads 4 API calls sequentially = 1.2s. Parallelizing → ~400ms.")
181
+ 3. **Changes Made** — What was modified. Skip if read-only run.
182
+ 4. **Recommendations** (if any) — Table:
183
+
184
+ | # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
185
+ |---|---|---|---|---|---|
186
+ | | ≤10 words | What improves | Low–Critical | Yes/Probably/If time | 1–3 sentences |
187
+
188
+ Order by risk descending. Be honest — not everything is worth the engineering time.
189
+
190
+ 5. **Report Location** — Full file path.