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
- # Test Consolidation
2
-
3
- You are running an overnight test consolidation pass. Your job: find every test that is testing the same behavioral path as another test, eliminate the duplicates, and leave the suite smaller, clearer, and no less correct. You are not improving tests — you are removing noise so the real coverage is visible.
4
-
5
- Work on branch `test-consolidation-[date]`.
6
-
7
- ---
8
-
9
- ## Global Rules
10
-
11
- - Run the full test suite before touching anything. Establish a green baseline. If it's already red, stop and document that as a CRITICAL finding — do not consolidate a broken suite.
12
- - Run the full test suite after every consolidation. If tests go red, revert the entire change immediately and document it.
13
- - **Never consolidate tests that cover distinct behavioral sub-cases**, even if they look similar. Two tests with different inputs are only redundant if the behavior under test is identical for both inputs.
14
- - A merged test must be at least as expressive as the originals. If consolidation makes the intent less clear, don't do it.
15
- - When in doubt about whether two tests are truly redundant, they are not. Document them instead.
16
- - Make small, atomic commits — one logical consolidation per commit. Commit format: `test: consolidate duplicate [description] tests in [file]`
17
- - You have all night. Accuracy matters more than speed.
18
-
19
- ---
20
-
21
- ## Phase 1: Baseline & Inventory
22
-
23
- **Step 1: Establish baseline**
24
- Run the full test suite. Record: total test count, pass/fail/skip counts, coverage percentage if available. If any tests are failing, stop and document before proceeding.
25
-
26
- **Step 2: Catalog every test file**
27
- For each file, record: path, framework, test count, and the module it covers. Note files that appear to test the same module from different angles.
28
-
29
- ---
30
-
31
- ## Phase 2: Duplicate Detection
32
-
33
- Work through these categories systematically. For each duplicate group found, document before touching anything.
34
-
35
- ### Category 1: Verbatim and near-verbatim duplicates
36
- - Tests with identical or near-identical bodies under different names
37
- - Tests that differ only in local variable names with no effect on what's asserted
38
- - Copy-paste tests where setup and assertions are structurally identical
39
- - Tests in different files that exercise the exact same code path with the exact same inputs and assert the exact same outputs
40
-
41
- ### Category 2: Redundant happy-path saturation
42
- Find feature areas where multiple tests all exercise the happy path with no meaningful variation — valid inputs, expected outputs, no error conditions, no edge cases. Five tests confirming the same function returns the correct value for five slightly different valid inputs is not coverage breadth; it's noise. Flag every cluster where:
43
- - All tests use valid inputs of the same category
44
- - No test in the group covers a different outcome or code branch
45
- - Removing all but one would leave identical behavioral coverage
46
-
47
- ### Category 3: Parameterizable tests
48
- Tests that are not verbatim duplicates but differ only in input/output values and would be more clearly expressed as a single parameterized test (`it.each` / `test.each` / `@pytest.mark.parametrize` / equivalent). These are not duplicates to delete — they are duplicates to merge into a table-driven test that is more readable and easier to extend.
49
-
50
- Candidates: test blocks that share the same `describe`, have parallel structure, and differ only in their data.
51
-
52
- ### Category 4: Redundant cross-layer testing
53
- Find cases where the exact same specific assertion is verified at multiple test layers — unit, integration, and E2E all asserting the identical return value or behavior. Note: this is not always bad. Cross-layer tests catch different failure modes. Only flag as redundant when the tests are truly checking the same thing at the same fidelity and neither adds what the other doesn't.
54
-
55
- ---
56
-
57
- ## Phase 3: Build the Consolidation Map
58
-
59
- Before changing anything, produce a complete consolidation plan:
60
-
61
- | Group | Files | Test Count | What They All Test | Proposed Action | Tests After | Risk Level |
62
- |---|---|---|---|---|---|---|
63
-
64
- **Proposed actions:**
65
- - **Delete** — Remove all but the best-named instance (verbatim duplicates)
66
- - **Parameterize** — Merge into a single `it.each` / data-driven test
67
- - **Merge into describe** — Consolidate into one well-structured describe block
68
- - **Leave** — Not redundant on closer inspection; document why
69
-
70
- Review this plan in its entirety before executing. The plan is your contract — don't deviate during execution.
71
-
72
- ---
73
-
74
- ## Phase 4: Execute Consolidations
75
-
76
- Work through the plan one group at a time.
77
-
78
- **For each consolidation:**
79
-
80
- 1. Re-read every test in the group to confirm your earlier analysis still holds
81
- 2. Make the change (delete, parameterize, or restructure)
82
- 3. Run the full test suite
83
- 4. If green: commit with a clear message listing what was removed/merged and why
84
- 5. If red: revert the entire change immediately, document what happened, move to the next group
85
-
86
- **Parameterization standards:**
87
- - Each row in the parameter table must be self-documenting — a reader should understand what case it covers without reading the test body
88
- - Use descriptive case labels, not `case1` / `case2`
89
- - The parameterized test must cover every case the originals covered — count assertions before and after
90
-
91
- **Deletion standards:**
92
- - Keep the test with the most descriptive name
93
- - If the tests have different names that each capture something, write a new name that captures both before deleting
94
- - Never delete a test that has a comment explaining non-obvious behavior — preserve that comment
95
-
96
- ---
97
-
98
- ## Phase 5: Post-Consolidation Validation
99
-
100
- After all consolidations are complete:
101
-
102
- 1. Run the full test suite one final time
103
- 2. Record: new total test count, pass/fail/skip counts, coverage percentage
104
- 3. Compare before/after: tests removed, tests parameterized, net change in coverage (should be zero or improved)
105
- 4. Run the linter if the project has one — consolidated files may need formatting fixes
106
-
107
- ---
108
-
109
- ## Output
110
-
111
- Create `audit-reports/` in project root if needed. Save as `audit-reports/05_TEST_CONSOLIDATION_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
112
-
113
- ### Report Structure
114
-
115
- 1. **Executive Summary** — Baseline test count, final test count, tests removed, tests parameterized, coverage before/after, all tests passing.
116
-
117
- 2. **Consolidation Map** — The full plan table from Phase 3, updated with actual outcomes (executed / skipped / reverted).
118
-
119
- 3. **Consolidations Executed** — For each: what was merged, how many tests removed, commit hash, tests passing after.
120
-
121
- 4. **Consolidations Reverted** — What was attempted, what broke, why it couldn't be resolved safely.
122
-
123
- 5. **Consolidations Identified but Not Executed** — Groups that were flagged but left alone: why (ambiguous intent, no safe merge, time constraints).
124
-
125
- 6. **Remaining Redundancy** — Areas of the suite that still have high happy-path saturation, no adversarial coverage, or cross-layer redundancy — flagged here for the Test Quality & Adversarial Coverage run to address.
126
-
127
- 7. **Recommendations** — Conventions to adopt to prevent re-accumulation (parameterized test patterns, code review checklist items, file organization suggestions).
128
-
129
- ---
130
-
131
- ## Chat Output Requirement
132
-
133
- In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish.
134
-
135
- ### 1. Status Line
136
- One sentence: what you did, how long it took, whether all tests still pass, and the before/after test count.
137
-
138
- ### 2. Key Findings
139
- The most important things discovered — specific and actionable.
140
-
141
- **Good:** "Found 34 verbatim duplicate tests across `user.test.ts` and `user.service.test.ts` — all testing the same happy-path token validation with different variable names."
142
- **Bad:** "Found some duplicate tests."
143
-
144
- ### 3. Changes Made
145
- Bullet list of consolidations executed. Skip if nothing was changed.
146
-
147
- ### 4. Recommendations
148
-
149
- 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.
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. Be honest in "Worth Doing?" — not everything flagged is worth the engineering time.
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
+ # Test Consolidation
2
+
3
+ You are running an overnight test consolidation pass. Your job: find every test that is testing the same behavioral path as another test, eliminate the duplicates, and leave the suite smaller, clearer, and no less correct. You are not improving tests — you are removing noise so the real coverage is visible.
4
+
5
+ Work on branch `test-consolidation-[date]`.
6
+
7
+ ---
8
+
9
+ ## Global Rules
10
+
11
+ - Run the full test suite before touching anything. Establish a green baseline. If it's already red, stop and document that as a CRITICAL finding — do not consolidate a broken suite.
12
+ - Run the full test suite after every consolidation. If tests go red, revert the entire change immediately and document it.
13
+ - **Never consolidate tests that cover distinct behavioral sub-cases**, even if they look similar. Two tests with different inputs are only redundant if the behavior under test is identical for both inputs.
14
+ - A merged test must be at least as expressive as the originals. If consolidation makes the intent less clear, don't do it.
15
+ - When in doubt about whether two tests are truly redundant, they are not. Document them instead.
16
+ - Make small, atomic commits — one logical consolidation per commit. Commit format: `test: consolidate duplicate [description] tests in [file]`
17
+ - You have all night. Accuracy matters more than speed.
18
+
19
+ ---
20
+
21
+ ## Phase 1: Baseline & Inventory
22
+
23
+ **Step 1: Establish baseline**
24
+ Run the full test suite. Record: total test count, pass/fail/skip counts, coverage percentage if available. If any tests are failing, stop and document before proceeding.
25
+
26
+ **Step 2: Catalog every test file**
27
+ For each file, record: path, framework, test count, and the module it covers. Note files that appear to test the same module from different angles.
28
+
29
+ ---
30
+
31
+ ## Phase 2: Duplicate Detection
32
+
33
+ Work through these categories systematically. For each duplicate group found, document before touching anything.
34
+
35
+ ### Category 1: Verbatim and near-verbatim duplicates
36
+ - Tests with identical or near-identical bodies under different names
37
+ - Tests that differ only in local variable names with no effect on what's asserted
38
+ - Copy-paste tests where setup and assertions are structurally identical
39
+ - Tests in different files that exercise the exact same code path with the exact same inputs and assert the exact same outputs
40
+
41
+ ### Category 2: Redundant happy-path saturation
42
+ Find feature areas where multiple tests all exercise the happy path with no meaningful variation — valid inputs, expected outputs, no error conditions, no edge cases. Five tests confirming the same function returns the correct value for five slightly different valid inputs is not coverage breadth; it's noise. Flag every cluster where:
43
+ - All tests use valid inputs of the same category
44
+ - No test in the group covers a different outcome or code branch
45
+ - Removing all but one would leave identical behavioral coverage
46
+
47
+ ### Category 3: Parameterizable tests
48
+ Tests that are not verbatim duplicates but differ only in input/output values and would be more clearly expressed as a single parameterized test (`it.each` / `test.each` / `@pytest.mark.parametrize` / equivalent). These are not duplicates to delete — they are duplicates to merge into a table-driven test that is more readable and easier to extend.
49
+
50
+ Candidates: test blocks that share the same `describe`, have parallel structure, and differ only in their data.
51
+
52
+ ### Category 4: Redundant cross-layer testing
53
+ Find cases where the exact same specific assertion is verified at multiple test layers — unit, integration, and E2E all asserting the identical return value or behavior. Note: this is not always bad. Cross-layer tests catch different failure modes. Only flag as redundant when the tests are truly checking the same thing at the same fidelity and neither adds what the other doesn't.
54
+
55
+ ---
56
+
57
+ ## Phase 3: Build the Consolidation Map
58
+
59
+ Before changing anything, produce a complete consolidation plan:
60
+
61
+ | Group | Files | Test Count | What They All Test | Proposed Action | Tests After | Risk Level |
62
+ |---|---|---|---|---|---|---|
63
+
64
+ **Proposed actions:**
65
+ - **Delete** — Remove all but the best-named instance (verbatim duplicates)
66
+ - **Parameterize** — Merge into a single `it.each` / data-driven test
67
+ - **Merge into describe** — Consolidate into one well-structured describe block
68
+ - **Leave** — Not redundant on closer inspection; document why
69
+
70
+ Review this plan in its entirety before executing. The plan is your contract — don't deviate during execution.
71
+
72
+ ---
73
+
74
+ ## Phase 4: Execute Consolidations
75
+
76
+ Work through the plan one group at a time.
77
+
78
+ **For each consolidation:**
79
+
80
+ 1. Re-read every test in the group to confirm your earlier analysis still holds
81
+ 2. Make the change (delete, parameterize, or restructure)
82
+ 3. Run the full test suite
83
+ 4. If green: commit with a clear message listing what was removed/merged and why
84
+ 5. If red: revert the entire change immediately, document what happened, move to the next group
85
+
86
+ **Parameterization standards:**
87
+ - Each row in the parameter table must be self-documenting — a reader should understand what case it covers without reading the test body
88
+ - Use descriptive case labels, not `case1` / `case2`
89
+ - The parameterized test must cover every case the originals covered — count assertions before and after
90
+
91
+ **Deletion standards:**
92
+ - Keep the test with the most descriptive name
93
+ - If the tests have different names that each capture something, write a new name that captures both before deleting
94
+ - Never delete a test that has a comment explaining non-obvious behavior — preserve that comment
95
+
96
+ ---
97
+
98
+ ## Phase 5: Post-Consolidation Validation
99
+
100
+ After all consolidations are complete:
101
+
102
+ 1. Run the full test suite one final time
103
+ 2. Record: new total test count, pass/fail/skip counts, coverage percentage
104
+ 3. Compare before/after: tests removed, tests parameterized, net change in coverage (should be zero or improved)
105
+ 4. Run the linter if the project has one — consolidated files may need formatting fixes
106
+
107
+ ---
108
+
109
+ ## Output
110
+
111
+ Create `audit-reports/` in project root if needed. Save as `audit-reports/05_TEST_CONSOLIDATION_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
112
+
113
+ ### Report Structure
114
+
115
+ 1. **Executive Summary** — Baseline test count, final test count, tests removed, tests parameterized, coverage before/after, all tests passing.
116
+
117
+ 2. **Consolidation Map** — The full plan table from Phase 3, updated with actual outcomes (executed / skipped / reverted).
118
+
119
+ 3. **Consolidations Executed** — For each: what was merged, how many tests removed, commit hash, tests passing after.
120
+
121
+ 4. **Consolidations Reverted** — What was attempted, what broke, why it couldn't be resolved safely.
122
+
123
+ 5. **Consolidations Identified but Not Executed** — Groups that were flagged but left alone: why (ambiguous intent, no safe merge, time constraints).
124
+
125
+ 6. **Remaining Redundancy** — Areas of the suite that still have high happy-path saturation, no adversarial coverage, or cross-layer redundancy — flagged here for the Test Quality & Adversarial Coverage run to address.
126
+
127
+ 7. **Recommendations** — Conventions to adopt to prevent re-accumulation (parameterized test patterns, code review checklist items, file organization suggestions).
128
+
129
+ ---
130
+
131
+ ## Chat Output Requirement
132
+
133
+ In addition to writing the full report file, you MUST print a summary directly in the conversation when you finish.
134
+
135
+ ### 1. Status Line
136
+ One sentence: what you did, how long it took, whether all tests still pass, and the before/after test count.
137
+
138
+ ### 2. Key Findings
139
+ The most important things discovered — specific and actionable.
140
+
141
+ **Good:** "Found 34 verbatim duplicate tests across `user.test.ts` and `user.service.test.ts` — all testing the same happy-path token validation with different variable names."
142
+ **Bad:** "Found some duplicate tests."
143
+
144
+ ### 3. Changes Made
145
+ Bullet list of consolidations executed. Skip if nothing was changed.
146
+
147
+ ### 4. Recommendations
148
+
149
+ 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.
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. Be honest in "Worth Doing?" — not everything flagged is worth the engineering time.
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.