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,189 +1,189 @@
|
|
|
1
|
-
# The Codebase Cleanup (Updated)
|
|
2
|
-
|
|
3
|
-
## Prompt
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
You are running an overnight codebase cleanup. You have several hours — be thorough and methodical. Unlike a security audit, you will actually be making changes to the code. Every change must keep tests passing.
|
|
7
|
-
|
|
8
|
-
## Your Mission
|
|
9
|
-
|
|
10
|
-
Conduct a comprehensive codebase cleanup covering five areas. Work on a branch called `codebase-cleanup-[date]`. After EVERY meaningful change, run the test suite. If tests break, revert and document the issue instead of shipping the broken change.
|
|
11
|
-
|
|
12
|
-
### Phase 1: Dead Code Elimination
|
|
13
|
-
Systematically identify and remove:
|
|
14
|
-
- **Unused exports**: Functions, classes, constants, and types that are exported but never imported anywhere
|
|
15
|
-
- **Unused imports**: Imports that exist but aren't referenced in the file
|
|
16
|
-
- **Unreachable code**: Code after return/throw statements, permanently false conditionals, disabled feature flags that will never be re-enabled
|
|
17
|
-
- **Orphaned files**: Files that are never imported or referenced by any other file (be careful — check for dynamic imports, config references, and script entries)
|
|
18
|
-
- **Unused dependencies**: Packages in package.json (or equivalent) that are never imported in the source code
|
|
19
|
-
- **Commented-out code blocks**: Large blocks of commented-out code (not explanatory comments — actual dead code that's been commented out). If it's in version control, it doesn't need to be preserved as comments.
|
|
20
|
-
|
|
21
|
-
**Process for each removal:**
|
|
22
|
-
1. Identify the dead code
|
|
23
|
-
2. Verify it's truly unused (search for dynamic references, string-based imports, reflection, etc.)
|
|
24
|
-
3. Remove it
|
|
25
|
-
4. Run tests
|
|
26
|
-
5. If tests pass, commit with a clear message: `chore: remove unused [description]`
|
|
27
|
-
6. If tests fail, revert and note it in the report as "appears unused but tests depend on it — investigate"
|
|
28
|
-
|
|
29
|
-
### Phase 2: Code Duplication Reduction
|
|
30
|
-
- Scan for duplicated or near-duplicated logic (functions that do roughly the same thing with minor variations)
|
|
31
|
-
- Focus on:
|
|
32
|
-
- Copy-pasted utility functions that exist in multiple files
|
|
33
|
-
- Similar data transformation logic repeated across modules
|
|
34
|
-
- Repeated validation patterns that could be a shared validator
|
|
35
|
-
- Similar API call patterns that could be a shared client method
|
|
36
|
-
- For each instance of significant duplication:
|
|
37
|
-
- If the fix is low-risk (extracting a shared utility, creating a helper function): implement it, run tests, commit
|
|
38
|
-
- If the fix is higher-risk (refactoring core patterns): document it in the report with a proposed approach, but don't implement
|
|
39
|
-
|
|
40
|
-
### Phase 3: Consistency Enforcement
|
|
41
|
-
Scan for and fix inconsistencies in:
|
|
42
|
-
- **Naming conventions**: Mixed camelCase/snake_case in the same language, inconsistent file naming patterns, inconsistent component naming
|
|
43
|
-
- **Import ordering**: Standardize to a consistent pattern (external deps → internal modules → relative imports → types)
|
|
44
|
-
- **Error handling patterns**: Some functions throw, some return null, some return Result types — document the dominant pattern and flag deviations
|
|
45
|
-
- **Async patterns**: Mixed callbacks/promises/async-await for the same kind of operation — modernize to the dominant (usually best) pattern
|
|
46
|
-
- **String quotes**: Mixed single/double quotes (respect existing linter config if present)
|
|
47
|
-
|
|
48
|
-
**Important**: Only fix inconsistencies where there's a clear "right way" already dominant in the codebase. Don't impose a new convention — reinforce the existing one. If it's genuinely 50/50, document it in the report and let the team decide.
|
|
49
|
-
|
|
50
|
-
### Phase 4: Configuration & Feature Flag Hygiene
|
|
51
|
-
|
|
52
|
-
This phase combines stale feature flag cleanup, TODO inventory, and comprehensive configuration hygiene.
|
|
53
|
-
|
|
54
|
-
**Step 1: Feature flag inventory and cleanup**
|
|
55
|
-
- Find every feature flag in the codebase (environment variables, config files, LaunchDarkly/Flagsmith/etc. references, hardcoded boolean switches)
|
|
56
|
-
- For each flag, document:
|
|
57
|
-
- Name and location
|
|
58
|
-
- Current value (always true, always false, dynamic, or unknown)
|
|
59
|
-
- **Owner**: Who likely owns this flag? (Infer from git blame, module ownership, or comments)
|
|
60
|
-
- **Age**: When was it introduced? (Check git history)
|
|
61
|
-
- **Type**: Is this a temporary rollout flag, a permanent operational toggle, or a kill switch?
|
|
62
|
-
- For always-true flags: remove the flag and keep the code
|
|
63
|
-
- For always-false flags: remove the flag AND the dead code it guards
|
|
64
|
-
- For rollout flags older than 6 months that are always-on: these are almost certainly safe to remove. Remove the flag, keep the code.
|
|
65
|
-
- Run tests after each removal. Commit: `chore: remove stale feature flag [name]`
|
|
66
|
-
|
|
67
|
-
**Step 2: Flag coupling analysis**
|
|
68
|
-
- Identify flags that depend on other flags (nested conditionals, compound flag checks)
|
|
69
|
-
- Document the combinatorial complexity: how many distinct code paths do the current flags create?
|
|
70
|
-
- Flag any combinations that are likely untested (e.g., if Flag A and Flag B are both "sometimes on," is the (A=true, B=false) path ever tested?)
|
|
71
|
-
- Document these in the report — don't try to fix flag coupling overnight
|
|
72
|
-
|
|
73
|
-
**Step 3: Configuration sprawl audit**
|
|
74
|
-
- Find every configuration value in the codebase (constants, config files, environment variable reads, settings objects)
|
|
75
|
-
- Identify configuration that is:
|
|
76
|
-
- **Set but never varied**: Config values that have only ever been set to one value across all environments. These might be candidates for becoming constants.
|
|
77
|
-
- **Undocumented**: Config values that have no comment, no README entry, and no `.env.example` entry explaining what they do or what valid values are
|
|
78
|
-
- **Duplicated**: The same conceptual setting defined in multiple places (a timeout defined in both a config file and a hardcoded fallback, with different values)
|
|
79
|
-
- **Unused**: Config values defined but never read by application code
|
|
80
|
-
- For clearly unused config: remove it. Run tests. Commit: `chore: remove unused config [name]`
|
|
81
|
-
- For undocumented config: add clear comments explaining what it controls, valid values, and default behavior
|
|
82
|
-
- For duplicated config: consolidate to a single source of truth where safe
|
|
83
|
-
|
|
84
|
-
**Step 4: Default value audit**
|
|
85
|
-
- For every configuration value with a default, evaluate whether the default is appropriate:
|
|
86
|
-
- Are there defaults appropriate for development that would be dangerous in production? (Debug mode on by default, permissive CORS by default, short token expiry in dev but what about prod?)
|
|
87
|
-
- Are there defaults that silently degrade behavior? (A cache TTL defaulting to 0, effectively disabling caching)
|
|
88
|
-
- Are there missing defaults that cause crashes if the config isn't explicitly set?
|
|
89
|
-
- Document concerns in the report. Fix defaults that are clearly wrong and safe to change.
|
|
90
|
-
|
|
91
|
-
**Step 5: TODO/FIXME/HACK inventory** (unchanged from original)
|
|
92
|
-
- Find every TODO, FIXME, HACK, XXX, and TEMP comment in the codebase. For each one:
|
|
93
|
-
- Categorize: bug, tech debt, feature request, optimization, or obsolete
|
|
94
|
-
- If it's clearly obsolete (references old code that no longer exists, mentions completed work): remove it
|
|
95
|
-
- For the rest: include in the report with file, line, category, and your assessment of priority
|
|
96
|
-
|
|
97
|
-
### Phase 5: Quick Wins
|
|
98
|
-
As you work through the phases above, you'll notice small improvements that don't fit neatly into a category. Fix them as you go:
|
|
99
|
-
- Simplifying overly complex conditionals
|
|
100
|
-
- Replacing deprecated API usage with modern equivalents
|
|
101
|
-
- Removing unnecessary type assertions (TypeScript)
|
|
102
|
-
- Converting var to const/let where applicable
|
|
103
|
-
- Removing empty files, empty constructors, or no-op overrides
|
|
104
|
-
- Fixing obvious typos in variable names or comments
|
|
105
|
-
|
|
106
|
-
Commit these as `chore: misc cleanup in [module/file]`
|
|
107
|
-
|
|
108
|
-
## Output Requirements
|
|
109
|
-
|
|
110
|
-
Create the `audit-reports/` directory in the project root if it doesn't already exist. Save the report as `audit-reports/10_CODEBASE_CLEANUP_REPORT_[run-number]_[date]_[time in user's local time].md` (e.g., `10_CODEBASE_CLEANUP_REPORT_01_2026-02-16_2129.md`). Increment the run number based on any existing reports with the same name prefix in that folder.
|
|
111
|
-
|
|
112
|
-
### Report Structure
|
|
113
|
-
|
|
114
|
-
1. **Summary**
|
|
115
|
-
- Total files modified
|
|
116
|
-
- Lines of code removed (net)
|
|
117
|
-
- Unused dependencies removed
|
|
118
|
-
- Number of commits made
|
|
119
|
-
- Any tests that were affected
|
|
120
|
-
|
|
121
|
-
2. **Dead Code Removed** — list everything you removed and why you're confident it was dead
|
|
122
|
-
|
|
123
|
-
3. **Duplication Reduced** — what you consolidated, plus higher-risk duplications you documented but didn't touch
|
|
124
|
-
|
|
125
|
-
4. **Consistency Changes** — what patterns you enforced and where
|
|
126
|
-
|
|
127
|
-
5. **Configuration & Feature Flags** (expanded from original)
|
|
128
|
-
- Flags removed: table with | Flag | Type | Age | Value | Action Taken |
|
|
129
|
-
- Flag coupling map (which flags interact and the combinatorial paths created)
|
|
130
|
-
- Configuration sprawl findings: table with | Config | Location | Issue | Action |
|
|
131
|
-
- Default value concerns: table with | Config | Default | Concern | Recommendation |
|
|
132
|
-
- Full TODO/FIXME inventory table: | File | Line | Comment | Category | Priority | Recommendation |
|
|
133
|
-
|
|
134
|
-
6. **Couldn't Touch** — things you wanted to fix but couldn't because:
|
|
135
|
-
- Tests broke when you tried
|
|
136
|
-
- The change was too risky without team input
|
|
137
|
-
- You weren't sure about the intended behavior
|
|
138
|
-
|
|
139
|
-
7. **Recommendations** — larger refactoring opportunities you noticed that deserve their own effort
|
|
140
|
-
|
|
141
|
-
## Rules
|
|
142
|
-
- Branch: `codebase-cleanup-[date]`
|
|
143
|
-
- Run tests after EVERY change. No exceptions.
|
|
144
|
-
- If tests fail, revert immediately and document why
|
|
145
|
-
- Make small, atomic commits — one logical change per commit
|
|
146
|
-
- Commit messages should start with `chore:` and clearly describe what was done
|
|
147
|
-
- DO NOT change any business logic. If you're unsure whether something is dead code or intentional, leave it and document it
|
|
148
|
-
- DO NOT refactor working code just because you'd write it differently. Only fix actual issues: dead code, duplication, inconsistency.
|
|
149
|
-
- When in doubt, document rather than change. Conservative changes that keep tests green are infinitely more valuable than aggressive changes that might break things.
|
|
150
|
-
- You have all night. Be thorough. Check every directory.
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Chat Output Requirement
|
|
154
|
-
|
|
155
|
-
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:
|
|
156
|
-
|
|
157
|
-
### 1. Status Line
|
|
158
|
-
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
159
|
-
|
|
160
|
-
### 2. Key Findings
|
|
161
|
-
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
162
|
-
|
|
163
|
-
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
164
|
-
**Bad:** "Found some issues with backups."
|
|
165
|
-
|
|
166
|
-
### 3. Changes Made (if applicable)
|
|
167
|
-
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
168
|
-
|
|
169
|
-
### 4. Recommendations
|
|
170
|
-
|
|
171
|
-
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.
|
|
172
|
-
|
|
173
|
-
When recommendations exist, use this table format:
|
|
174
|
-
|
|
175
|
-
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
176
|
-
|---|---|---|---|---|---|
|
|
177
|
-
| *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* |
|
|
178
|
-
|
|
179
|
-
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.
|
|
180
|
-
|
|
181
|
-
### 5. Report Location
|
|
182
|
-
State the full path to the detailed report file for deeper review.
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
**Formatting rules for chat output:**
|
|
187
|
-
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
188
|
-
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
189
|
-
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
1
|
+
# The Codebase Cleanup (Updated)
|
|
2
|
+
|
|
3
|
+
## Prompt
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
You are running an overnight codebase cleanup. You have several hours — be thorough and methodical. Unlike a security audit, you will actually be making changes to the code. Every change must keep tests passing.
|
|
7
|
+
|
|
8
|
+
## Your Mission
|
|
9
|
+
|
|
10
|
+
Conduct a comprehensive codebase cleanup covering five areas. Work on a branch called `codebase-cleanup-[date]`. After EVERY meaningful change, run the test suite. If tests break, revert and document the issue instead of shipping the broken change.
|
|
11
|
+
|
|
12
|
+
### Phase 1: Dead Code Elimination
|
|
13
|
+
Systematically identify and remove:
|
|
14
|
+
- **Unused exports**: Functions, classes, constants, and types that are exported but never imported anywhere
|
|
15
|
+
- **Unused imports**: Imports that exist but aren't referenced in the file
|
|
16
|
+
- **Unreachable code**: Code after return/throw statements, permanently false conditionals, disabled feature flags that will never be re-enabled
|
|
17
|
+
- **Orphaned files**: Files that are never imported or referenced by any other file (be careful — check for dynamic imports, config references, and script entries)
|
|
18
|
+
- **Unused dependencies**: Packages in package.json (or equivalent) that are never imported in the source code
|
|
19
|
+
- **Commented-out code blocks**: Large blocks of commented-out code (not explanatory comments — actual dead code that's been commented out). If it's in version control, it doesn't need to be preserved as comments.
|
|
20
|
+
|
|
21
|
+
**Process for each removal:**
|
|
22
|
+
1. Identify the dead code
|
|
23
|
+
2. Verify it's truly unused (search for dynamic references, string-based imports, reflection, etc.)
|
|
24
|
+
3. Remove it
|
|
25
|
+
4. Run tests
|
|
26
|
+
5. If tests pass, commit with a clear message: `chore: remove unused [description]`
|
|
27
|
+
6. If tests fail, revert and note it in the report as "appears unused but tests depend on it — investigate"
|
|
28
|
+
|
|
29
|
+
### Phase 2: Code Duplication Reduction
|
|
30
|
+
- Scan for duplicated or near-duplicated logic (functions that do roughly the same thing with minor variations)
|
|
31
|
+
- Focus on:
|
|
32
|
+
- Copy-pasted utility functions that exist in multiple files
|
|
33
|
+
- Similar data transformation logic repeated across modules
|
|
34
|
+
- Repeated validation patterns that could be a shared validator
|
|
35
|
+
- Similar API call patterns that could be a shared client method
|
|
36
|
+
- For each instance of significant duplication:
|
|
37
|
+
- If the fix is low-risk (extracting a shared utility, creating a helper function): implement it, run tests, commit
|
|
38
|
+
- If the fix is higher-risk (refactoring core patterns): document it in the report with a proposed approach, but don't implement
|
|
39
|
+
|
|
40
|
+
### Phase 3: Consistency Enforcement
|
|
41
|
+
Scan for and fix inconsistencies in:
|
|
42
|
+
- **Naming conventions**: Mixed camelCase/snake_case in the same language, inconsistent file naming patterns, inconsistent component naming
|
|
43
|
+
- **Import ordering**: Standardize to a consistent pattern (external deps → internal modules → relative imports → types)
|
|
44
|
+
- **Error handling patterns**: Some functions throw, some return null, some return Result types — document the dominant pattern and flag deviations
|
|
45
|
+
- **Async patterns**: Mixed callbacks/promises/async-await for the same kind of operation — modernize to the dominant (usually best) pattern
|
|
46
|
+
- **String quotes**: Mixed single/double quotes (respect existing linter config if present)
|
|
47
|
+
|
|
48
|
+
**Important**: Only fix inconsistencies where there's a clear "right way" already dominant in the codebase. Don't impose a new convention — reinforce the existing one. If it's genuinely 50/50, document it in the report and let the team decide.
|
|
49
|
+
|
|
50
|
+
### Phase 4: Configuration & Feature Flag Hygiene
|
|
51
|
+
|
|
52
|
+
This phase combines stale feature flag cleanup, TODO inventory, and comprehensive configuration hygiene.
|
|
53
|
+
|
|
54
|
+
**Step 1: Feature flag inventory and cleanup**
|
|
55
|
+
- Find every feature flag in the codebase (environment variables, config files, LaunchDarkly/Flagsmith/etc. references, hardcoded boolean switches)
|
|
56
|
+
- For each flag, document:
|
|
57
|
+
- Name and location
|
|
58
|
+
- Current value (always true, always false, dynamic, or unknown)
|
|
59
|
+
- **Owner**: Who likely owns this flag? (Infer from git blame, module ownership, or comments)
|
|
60
|
+
- **Age**: When was it introduced? (Check git history)
|
|
61
|
+
- **Type**: Is this a temporary rollout flag, a permanent operational toggle, or a kill switch?
|
|
62
|
+
- For always-true flags: remove the flag and keep the code
|
|
63
|
+
- For always-false flags: remove the flag AND the dead code it guards
|
|
64
|
+
- For rollout flags older than 6 months that are always-on: these are almost certainly safe to remove. Remove the flag, keep the code.
|
|
65
|
+
- Run tests after each removal. Commit: `chore: remove stale feature flag [name]`
|
|
66
|
+
|
|
67
|
+
**Step 2: Flag coupling analysis**
|
|
68
|
+
- Identify flags that depend on other flags (nested conditionals, compound flag checks)
|
|
69
|
+
- Document the combinatorial complexity: how many distinct code paths do the current flags create?
|
|
70
|
+
- Flag any combinations that are likely untested (e.g., if Flag A and Flag B are both "sometimes on," is the (A=true, B=false) path ever tested?)
|
|
71
|
+
- Document these in the report — don't try to fix flag coupling overnight
|
|
72
|
+
|
|
73
|
+
**Step 3: Configuration sprawl audit**
|
|
74
|
+
- Find every configuration value in the codebase (constants, config files, environment variable reads, settings objects)
|
|
75
|
+
- Identify configuration that is:
|
|
76
|
+
- **Set but never varied**: Config values that have only ever been set to one value across all environments. These might be candidates for becoming constants.
|
|
77
|
+
- **Undocumented**: Config values that have no comment, no README entry, and no `.env.example` entry explaining what they do or what valid values are
|
|
78
|
+
- **Duplicated**: The same conceptual setting defined in multiple places (a timeout defined in both a config file and a hardcoded fallback, with different values)
|
|
79
|
+
- **Unused**: Config values defined but never read by application code
|
|
80
|
+
- For clearly unused config: remove it. Run tests. Commit: `chore: remove unused config [name]`
|
|
81
|
+
- For undocumented config: add clear comments explaining what it controls, valid values, and default behavior
|
|
82
|
+
- For duplicated config: consolidate to a single source of truth where safe
|
|
83
|
+
|
|
84
|
+
**Step 4: Default value audit**
|
|
85
|
+
- For every configuration value with a default, evaluate whether the default is appropriate:
|
|
86
|
+
- Are there defaults appropriate for development that would be dangerous in production? (Debug mode on by default, permissive CORS by default, short token expiry in dev but what about prod?)
|
|
87
|
+
- Are there defaults that silently degrade behavior? (A cache TTL defaulting to 0, effectively disabling caching)
|
|
88
|
+
- Are there missing defaults that cause crashes if the config isn't explicitly set?
|
|
89
|
+
- Document concerns in the report. Fix defaults that are clearly wrong and safe to change.
|
|
90
|
+
|
|
91
|
+
**Step 5: TODO/FIXME/HACK inventory** (unchanged from original)
|
|
92
|
+
- Find every TODO, FIXME, HACK, XXX, and TEMP comment in the codebase. For each one:
|
|
93
|
+
- Categorize: bug, tech debt, feature request, optimization, or obsolete
|
|
94
|
+
- If it's clearly obsolete (references old code that no longer exists, mentions completed work): remove it
|
|
95
|
+
- For the rest: include in the report with file, line, category, and your assessment of priority
|
|
96
|
+
|
|
97
|
+
### Phase 5: Quick Wins
|
|
98
|
+
As you work through the phases above, you'll notice small improvements that don't fit neatly into a category. Fix them as you go:
|
|
99
|
+
- Simplifying overly complex conditionals
|
|
100
|
+
- Replacing deprecated API usage with modern equivalents
|
|
101
|
+
- Removing unnecessary type assertions (TypeScript)
|
|
102
|
+
- Converting var to const/let where applicable
|
|
103
|
+
- Removing empty files, empty constructors, or no-op overrides
|
|
104
|
+
- Fixing obvious typos in variable names or comments
|
|
105
|
+
|
|
106
|
+
Commit these as `chore: misc cleanup in [module/file]`
|
|
107
|
+
|
|
108
|
+
## Output Requirements
|
|
109
|
+
|
|
110
|
+
Create the `audit-reports/` directory in the project root if it doesn't already exist. Save the report as `audit-reports/10_CODEBASE_CLEANUP_REPORT_[run-number]_[date]_[time in user's local time].md` (e.g., `10_CODEBASE_CLEANUP_REPORT_01_2026-02-16_2129.md`). Increment the run number based on any existing reports with the same name prefix in that folder.
|
|
111
|
+
|
|
112
|
+
### Report Structure
|
|
113
|
+
|
|
114
|
+
1. **Summary**
|
|
115
|
+
- Total files modified
|
|
116
|
+
- Lines of code removed (net)
|
|
117
|
+
- Unused dependencies removed
|
|
118
|
+
- Number of commits made
|
|
119
|
+
- Any tests that were affected
|
|
120
|
+
|
|
121
|
+
2. **Dead Code Removed** — list everything you removed and why you're confident it was dead
|
|
122
|
+
|
|
123
|
+
3. **Duplication Reduced** — what you consolidated, plus higher-risk duplications you documented but didn't touch
|
|
124
|
+
|
|
125
|
+
4. **Consistency Changes** — what patterns you enforced and where
|
|
126
|
+
|
|
127
|
+
5. **Configuration & Feature Flags** (expanded from original)
|
|
128
|
+
- Flags removed: table with | Flag | Type | Age | Value | Action Taken |
|
|
129
|
+
- Flag coupling map (which flags interact and the combinatorial paths created)
|
|
130
|
+
- Configuration sprawl findings: table with | Config | Location | Issue | Action |
|
|
131
|
+
- Default value concerns: table with | Config | Default | Concern | Recommendation |
|
|
132
|
+
- Full TODO/FIXME inventory table: | File | Line | Comment | Category | Priority | Recommendation |
|
|
133
|
+
|
|
134
|
+
6. **Couldn't Touch** — things you wanted to fix but couldn't because:
|
|
135
|
+
- Tests broke when you tried
|
|
136
|
+
- The change was too risky without team input
|
|
137
|
+
- You weren't sure about the intended behavior
|
|
138
|
+
|
|
139
|
+
7. **Recommendations** — larger refactoring opportunities you noticed that deserve their own effort
|
|
140
|
+
|
|
141
|
+
## Rules
|
|
142
|
+
- Branch: `codebase-cleanup-[date]`
|
|
143
|
+
- Run tests after EVERY change. No exceptions.
|
|
144
|
+
- If tests fail, revert immediately and document why
|
|
145
|
+
- Make small, atomic commits — one logical change per commit
|
|
146
|
+
- Commit messages should start with `chore:` and clearly describe what was done
|
|
147
|
+
- DO NOT change any business logic. If you're unsure whether something is dead code or intentional, leave it and document it
|
|
148
|
+
- DO NOT refactor working code just because you'd write it differently. Only fix actual issues: dead code, duplication, inconsistency.
|
|
149
|
+
- When in doubt, document rather than change. Conservative changes that keep tests green are infinitely more valuable than aggressive changes that might break things.
|
|
150
|
+
- You have all night. Be thorough. Check every directory.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Chat Output Requirement
|
|
154
|
+
|
|
155
|
+
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:
|
|
156
|
+
|
|
157
|
+
### 1. Status Line
|
|
158
|
+
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
159
|
+
|
|
160
|
+
### 2. Key Findings
|
|
161
|
+
The most important things discovered — bugs, risks, wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with severity or impact.
|
|
162
|
+
|
|
163
|
+
**Good:** "CRITICAL: No backup configuration found for the primary Postgres database — total data loss risk."
|
|
164
|
+
**Bad:** "Found some issues with backups."
|
|
165
|
+
|
|
166
|
+
### 3. Changes Made (if applicable)
|
|
167
|
+
Bullet list of what was actually modified, added, or removed. Skip this section for read-only analysis runs.
|
|
168
|
+
|
|
169
|
+
### 4. Recommendations
|
|
170
|
+
|
|
171
|
+
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.
|
|
172
|
+
|
|
173
|
+
When recommendations exist, use this table format:
|
|
174
|
+
|
|
175
|
+
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
176
|
+
|---|---|---|---|---|---|
|
|
177
|
+
| *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* |
|
|
178
|
+
|
|
179
|
+
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.
|
|
180
|
+
|
|
181
|
+
### 5. Report Location
|
|
182
|
+
State the full path to the detailed report file for deeper review.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
**Formatting rules for chat output:**
|
|
187
|
+
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
188
|
+
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
189
|
+
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|