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,329 +1,329 @@
|
|
|
1
|
-
# Code Elegance & Abstraction Refinement
|
|
2
|
-
|
|
3
|
-
You are running an overnight code elegance and abstraction refinement pass. Your job: make the codebase something a senior developer would be proud to open. Untangle spaghetti, put logic in the right layers, simplify the convoluted, and make the code read like well-written prose — all without changing a single behavior.
|
|
4
|
-
|
|
5
|
-
This is the highest-risk overnight run. Every change must preserve exact behavior. Move slowly. Verify obsessively. When in doubt, don't touch it.
|
|
6
|
-
|
|
7
|
-
Work on branch `code-elegance-[date]`.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Global Rules
|
|
12
|
-
|
|
13
|
-
- **Behavior preservation is sacred.** Every refactor must produce identical inputs → identical outputs, identical side effects, identical error behavior. "It works the same but better" is the only acceptable outcome.
|
|
14
|
-
- Run the FULL test suite after every refactor. Not just related tests.
|
|
15
|
-
- Run the build after every refactor.
|
|
16
|
-
- If tests or build fail, revert the ENTIRE change immediately. Do not debug — document what you attempted and move on.
|
|
17
|
-
- **One refactor at a time.** Refactor, test, commit. Then next refactor. Never batch multiple refactors into one commit.
|
|
18
|
-
- Commit format: `refactor: [what you improved] in [file/module]`
|
|
19
|
-
- DO NOT refactor files with less than 60% test coverage unless you write characterization tests first (Phase 1).
|
|
20
|
-
- DO NOT refactor code you don't fully understand. If you can't explain what every line does and why, document it as "needs team review" and skip it.
|
|
21
|
-
- DO NOT rename public API endpoints, exported function signatures, database columns, or environment variables. Internal names are fair game.
|
|
22
|
-
- DO NOT change error messages, log messages, or user-facing strings. Those are behavior.
|
|
23
|
-
- You have all night. Quality of each refactor matters infinitely more than quantity.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Phase 1: Characterization Testing (Safety Net First)
|
|
28
|
-
|
|
29
|
-
Before refactoring anything, you need confidence that existing behavior is captured by tests. This phase builds that safety net for the code you're about to touch.
|
|
30
|
-
|
|
31
|
-
**Step 1: Identify refactoring candidates (quick scan)**
|
|
32
|
-
Do a fast pass through the codebase to identify the ~10-20 files/modules most in need of elegance work (you'll refine this list in Phase 2). Look for:
|
|
33
|
-
- Functions over 50 lines
|
|
34
|
-
- Deeply nested conditionals (3+ levels)
|
|
35
|
-
- Functions with 5+ parameters
|
|
36
|
-
- God classes/modules that do everything
|
|
37
|
-
- Logic that's clearly in the wrong layer (DB queries in route handlers, business rules in UI components, formatting in data models)
|
|
38
|
-
- Copy-paste code with slight variations
|
|
39
|
-
- Overly clever code that requires mental gymnastics to follow
|
|
40
|
-
- Long chains of if/else or switch statements that could be data-driven
|
|
41
|
-
- Callback hell or deeply nested promise chains
|
|
42
|
-
- Functions that mix multiple levels of abstraction (high-level orchestration interleaved with low-level details)
|
|
43
|
-
|
|
44
|
-
**Step 2: Assess test coverage for each candidate**
|
|
45
|
-
For each candidate file/module:
|
|
46
|
-
- What tests exist? What do they cover?
|
|
47
|
-
- Run coverage if tooling exists — what percentage of the code you want to refactor is exercised?
|
|
48
|
-
- Are the tests testing behavior (inputs → outputs, side effects) or implementation details?
|
|
49
|
-
|
|
50
|
-
**Step 3: Write characterization tests where needed**
|
|
51
|
-
For any refactoring candidate with less than 60% coverage on the code you plan to change:
|
|
52
|
-
|
|
53
|
-
- **Characterization tests capture current behavior, not intended behavior.** If the code has a bug, the characterization test should assert the buggy behavior. You're creating a snapshot of "what it does right now" so you'll know if your refactor changes anything.
|
|
54
|
-
- For pure functions: test with a variety of inputs including edge cases. Assert exact outputs.
|
|
55
|
-
- For functions with side effects: mock dependencies, assert the exact sequence of calls with exact arguments.
|
|
56
|
-
- For stateful code: test state transitions with exact before/after snapshots.
|
|
57
|
-
- For error paths: trigger every error condition and assert the exact error type, message, and any side effects.
|
|
58
|
-
- Name these tests clearly: `describe('[function] — characterization tests (pre-refactor)')`
|
|
59
|
-
- Commit: `test: add characterization tests for [module] before refactoring`
|
|
60
|
-
|
|
61
|
-
**DO NOT proceed to Phase 2 for any module until you're confident its behavior is captured by tests.**
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Phase 2: Code Audit & Refactoring Plan
|
|
66
|
-
|
|
67
|
-
Now do a thorough analysis. For each file/module in the codebase, evaluate against these code quality dimensions:
|
|
68
|
-
|
|
69
|
-
### Dimension 1: Single Responsibility
|
|
70
|
-
- Does this function/class/module do ONE thing?
|
|
71
|
-
- Can you describe what it does in one sentence without using "and"?
|
|
72
|
-
- If a function is named `processOrder`, does it ONLY process the order, or does it also send emails, update analytics, and log audit trails?
|
|
73
|
-
|
|
74
|
-
### Dimension 2: Right Level of Abstraction
|
|
75
|
-
- Is high-level orchestration mixed with low-level details? A function that coordinates a workflow should call well-named subfunctions — not contain raw SQL, string parsing, and HTTP calls inline.
|
|
76
|
-
- Is the code at a consistent level of abstraction within each function? (Not mixing "createUser" with "buffer.toString('base64')" in the same block)
|
|
77
|
-
- Are things in the right architectural layer?
|
|
78
|
-
- Route handlers should: validate input, call service layer, format response. Nothing else.
|
|
79
|
-
- Service layer should: orchestrate business logic, coordinate between data sources. No HTTP concepts, no response formatting.
|
|
80
|
-
- Data layer should: query and persist data. No business rules, no formatting.
|
|
81
|
-
- UI components should: render and handle user interaction. No direct API calls, no business logic.
|
|
82
|
-
|
|
83
|
-
### Dimension 3: Readability & Clarity
|
|
84
|
-
- Can a new developer understand this code without tribal knowledge?
|
|
85
|
-
- Are variable/function names descriptive and accurate? (`data` → `unprocessedOrders`, `temp` → `formattedAddress`, `flag` → `isEligibleForDiscount`)
|
|
86
|
-
- Are there magic numbers or strings that should be named constants?
|
|
87
|
-
- Is control flow straightforward, or does it require a flowchart to follow?
|
|
88
|
-
- Are there unnecessary intermediate variables, or conversely, overly long expressions that should be broken up?
|
|
89
|
-
- Are comments explaining "what" (the code should speak for itself) instead of "why" (which is valuable)?
|
|
90
|
-
|
|
91
|
-
### Dimension 4: Simplicity
|
|
92
|
-
- Is there a simpler way to achieve the same result?
|
|
93
|
-
- Are there unnecessary abstractions? (A factory that only creates one type, an interface with one implementation, a wrapper that adds nothing)
|
|
94
|
-
- Are there over-engineered patterns? (Strategy pattern for two cases, observer pattern for one subscriber, dependency injection for something with no tests and no alternate implementations)
|
|
95
|
-
- Conversely, are there missing abstractions? (The same 5-line pattern repeated 12 times that should be a function)
|
|
96
|
-
|
|
97
|
-
### Dimension 5: Function Design
|
|
98
|
-
- Do functions have reasonable parameter counts? (>3 is a smell; >5 is almost always wrong)
|
|
99
|
-
- Could long parameter lists be replaced with an options/config object?
|
|
100
|
-
- Are there boolean "flag" parameters that make the function do two different things? (Split into two functions)
|
|
101
|
-
- Do functions have a single return type, or do they sometimes return a string, sometimes null, sometimes undefined, sometimes an object?
|
|
102
|
-
- Are functions a reasonable length? (>30 lines = usually doing too much)
|
|
103
|
-
|
|
104
|
-
### Create the refactoring plan
|
|
105
|
-
|
|
106
|
-
For each issue found, document:
|
|
107
|
-
- **File and location**
|
|
108
|
-
- **What's wrong** (which dimension, specific description)
|
|
109
|
-
- **Proposed refactor** (exactly what you plan to do)
|
|
110
|
-
- **Risk level**: Low (rename, extract function, simplify conditional) / Medium (restructure module, change abstraction layer) / High (redesign data flow, split god class)
|
|
111
|
-
- **Test coverage**: Adequate / Needs characterization tests first
|
|
112
|
-
|
|
113
|
-
**Priority order for execution:**
|
|
114
|
-
1. Low-risk, high-readability-impact (quick wins that make the code dramatically clearer)
|
|
115
|
-
2. Medium-risk, high-impact (abstraction fixes, layer corrections)
|
|
116
|
-
3. Low-risk, medium-impact (naming, simplification, constant extraction)
|
|
117
|
-
4. High-risk items — document only, do not implement overnight
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## Phase 3: Execute Refactors
|
|
122
|
-
|
|
123
|
-
Work through your plan in priority order. For each refactor:
|
|
124
|
-
|
|
125
|
-
### Before touching code:
|
|
126
|
-
- Re-read the function/module completely
|
|
127
|
-
- Verify you understand every code path, including error paths
|
|
128
|
-
- Verify test coverage is adequate (if not, go back to Phase 1)
|
|
129
|
-
- State to yourself: "This refactor changes the structure but not the behavior because: [reason]"
|
|
130
|
-
|
|
131
|
-
### Refactoring Techniques (use as appropriate):
|
|
132
|
-
|
|
133
|
-
**Extract Function** — The workhorse refactor. When a block of code inside a function does a distinct sub-task:
|
|
134
|
-
- Give it a descriptive name that says what it does, not how
|
|
135
|
-
- Pass only what it needs as parameters
|
|
136
|
-
- Return only what the caller needs
|
|
137
|
-
- The calling function should now read like a high-level summary
|
|
138
|
-
|
|
139
|
-
**Extract Constant / Config** — Replace magic numbers and strings:
|
|
140
|
-
- `if (retries > 3)` → `if (retries > MAX_RETRY_ATTEMPTS)`
|
|
141
|
-
- `role === 'admin'` → `role === ROLES.ADMIN` (if roles are used in multiple places)
|
|
142
|
-
- Group related constants in a well-named object or enum
|
|
143
|
-
|
|
144
|
-
**Simplify Conditionals:**
|
|
145
|
-
- Replace nested if/else with early returns (guard clauses)
|
|
146
|
-
- Replace long if/else chains with lookup objects/maps when mapping input → output
|
|
147
|
-
- Replace boolean flag parameters with separate, well-named functions
|
|
148
|
-
- Replace complex boolean expressions with descriptively named variables: `const isEligible = age >= 18 && hasVerifiedEmail && !isBanned;`
|
|
149
|
-
- Invert negative conditions for readability: `if (!isNotReady)` → `if (isReady)`
|
|
150
|
-
|
|
151
|
-
**Flatten Nesting:**
|
|
152
|
-
- Replace `if (condition) { ...lots of code... }` with `if (!condition) return;` followed by the code at the top level
|
|
153
|
-
- Replace nested callbacks with async/await
|
|
154
|
-
- Replace nested loops with helper functions or appropriate array methods
|
|
155
|
-
|
|
156
|
-
**Improve Naming:**
|
|
157
|
-
- Variables should describe what they hold, not their type: `userList` → `activeUsers`, `str` → `serializedPayload`
|
|
158
|
-
- Functions should describe what they do as a verb phrase: `process()` → `calculateShippingCost()`, `handle()` → `routeIncomingWebhook()`
|
|
159
|
-
- Booleans should read as questions: `valid` → `isValid`, `enabled` → `isFeatureEnabled`, `check` → `hasPermission`
|
|
160
|
-
- Match the domain language. If the team says "workspace" not "organization," use "workspace" in code.
|
|
161
|
-
|
|
162
|
-
**Fix Abstraction Layers:**
|
|
163
|
-
- Move database queries out of route handlers into a data/repository layer
|
|
164
|
-
- Move business rules out of UI components into a service/logic layer
|
|
165
|
-
- Move HTTP/response formatting out of business logic into the controller/handler layer
|
|
166
|
-
- Move validation to the input boundary (where data enters the system)
|
|
167
|
-
- Each layer should only know about the layer directly below it
|
|
168
|
-
|
|
169
|
-
**Simplify Over-Engineering:**
|
|
170
|
-
- If a class has one method, it should probably be a function
|
|
171
|
-
- If a factory creates one type, it should probably be a constructor call
|
|
172
|
-
- If an abstraction has one implementation and no tests use an alternate, it may not need to be an abstraction
|
|
173
|
-
- If a config option has never been changed from its default, it might just be a constant
|
|
174
|
-
- Remove dead abstractions — interfaces nobody implements, base classes with one child, strategies with one strategy
|
|
175
|
-
|
|
176
|
-
**Replace Imperative with Declarative (where clearer):**
|
|
177
|
-
- `for` loops building arrays → `map`, `filter`, `reduce` (but only when it's actually clearer — don't force it)
|
|
178
|
-
- Manual object construction from another object → spread/destructuring
|
|
179
|
-
- Repeated conditional checks → lookup tables/maps
|
|
180
|
-
- **Don't over-do this.** A simple `for` loop is sometimes more readable than a clever reduce chain. Readability wins over cleverness every time.
|
|
181
|
-
|
|
182
|
-
### After each refactor:
|
|
183
|
-
1. Run the full test suite
|
|
184
|
-
2. Run the build
|
|
185
|
-
3. Manually verify: does this code do the exact same thing as before? Trace through mentally.
|
|
186
|
-
4. If everything passes: commit with a clear message explaining what was improved and why
|
|
187
|
-
5. If anything fails: revert immediately, document what went wrong, move to next item
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
|
|
191
|
-
## Phase 4: Structural Improvements (Conservative)
|
|
192
|
-
|
|
193
|
-
After individual refactors are complete, look for broader structural improvements. **Only implement low-risk structural changes. Document the rest.**
|
|
194
|
-
|
|
195
|
-
### Safe to implement:
|
|
196
|
-
- Moving a helper function from a file where it doesn't belong to one where it does (update all imports, test, commit)
|
|
197
|
-
- Grouping related functions that are scattered across a file into a logical order
|
|
198
|
-
- Adding section comments to long files that organize code into logical groups
|
|
199
|
-
- Creating a shared utility function from duplicated logic (only if the duplication is exact or near-exact)
|
|
200
|
-
|
|
201
|
-
### Document only — do not implement:
|
|
202
|
-
- Splitting god modules into focused sub-modules (use the File Decomposition prompt for this)
|
|
203
|
-
- Introducing new architectural patterns (repository pattern, service layer, etc.)
|
|
204
|
-
- Changing the project's directory structure
|
|
205
|
-
- Creating new abstraction layers that don't currently exist
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Phase 5: Code Quality Assessment
|
|
210
|
-
|
|
211
|
-
After all refactors are complete, do a final assessment:
|
|
212
|
-
|
|
213
|
-
**Step 1: Before/after comparison**
|
|
214
|
-
For each file you touched, compare:
|
|
215
|
-
- Line count before and after
|
|
216
|
-
- Deepest nesting level before and after
|
|
217
|
-
- Longest function before and after
|
|
218
|
-
- Number of parameters on the most complex function before and after
|
|
219
|
-
- Subjective readability score (1-5) before and after
|
|
220
|
-
|
|
221
|
-
**Step 2: Remaining issues**
|
|
222
|
-
What couldn't you fix, and why?
|
|
223
|
-
- Too risky for overnight
|
|
224
|
-
- Insufficient test coverage
|
|
225
|
-
- Requires team input on intended design
|
|
226
|
-
- Requires broader architectural changes
|
|
227
|
-
|
|
228
|
-
**Step 3: Patterns observed**
|
|
229
|
-
What recurring anti-patterns did you see? These inform team conventions:
|
|
230
|
-
- "Business logic is frequently found in route handlers — the team should adopt a service layer pattern"
|
|
231
|
-
- "Functions regularly mix abstraction levels — consider a team convention of extract-function for anything below the main function's abstraction level"
|
|
232
|
-
- "Magic numbers are pervasive — consider a project-wide constants file or enum convention"
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
## Output
|
|
237
|
-
|
|
238
|
-
Create `audit-reports/` in project root if needed. Save as `audit-reports/13_CODE_ELEGANCE_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
|
|
239
|
-
|
|
240
|
-
### Report Structure
|
|
241
|
-
|
|
242
|
-
1. **Executive Summary** — Files analyzed, refactors executed, refactors reverted, tests still passing, overall assessment of code quality improvement.
|
|
243
|
-
|
|
244
|
-
2. **Characterization Tests Written** — Table: | File/Module | Tests Added | Coverage Before | Coverage After | Purpose |. These tests have value beyond this refactoring pass — they document current behavior.
|
|
245
|
-
|
|
246
|
-
3. **Refactors Executed** — For each refactor:
|
|
247
|
-
| File | What Changed | Technique Used | Risk Level | Before (metrics) | After (metrics) |
|
|
248
|
-
|
|
249
|
-
Plus a brief description of what was improved and why for non-obvious changes.
|
|
250
|
-
|
|
251
|
-
4. **Refactors Attempted but Reverted** — What you tried, what broke, and your assessment of why.
|
|
252
|
-
|
|
253
|
-
5. **Refactors Identified but Not Attempted** — The backlog. For each:
|
|
254
|
-
| File | Issue | Proposed Refactor | Risk Level | Why Not Attempted | Priority for Next Run |
|
|
255
|
-
|
|
256
|
-
6. **Code Quality Metrics** — Before/after summary:
|
|
257
|
-
- Longest function (lines): before → after
|
|
258
|
-
- Deepest nesting level: before → after
|
|
259
|
-
- Largest parameter count: before → after
|
|
260
|
-
- Functions over 50 lines: before → after
|
|
261
|
-
- Files with mixed abstraction layers: before → after
|
|
262
|
-
|
|
263
|
-
7. **Anti-Pattern Inventory** — Recurring patterns the team should address as conventions:
|
|
264
|
-
| Pattern | Frequency | Where It Appears | Recommended Convention |
|
|
265
|
-
|
|
266
|
-
8. **Abstraction Layer Assessment** — Current state of architectural layering:
|
|
267
|
-
- Which layers exist and are respected?
|
|
268
|
-
- Which layers are violated and where?
|
|
269
|
-
- Recommended layer boundaries for this project
|
|
270
|
-
|
|
271
|
-
9. **Recommendations** — Priority-ordered next steps:
|
|
272
|
-
- Refactors to attempt in the next run (from the backlog)
|
|
273
|
-
- Conventions to adopt to prevent new code from regressing
|
|
274
|
-
- Architectural improvements that would benefit the codebase
|
|
275
|
-
- Areas needing team discussion before refactoring
|
|
276
|
-
|
|
277
|
-
## Rules
|
|
278
|
-
- Branch: `code-elegance-[date]`
|
|
279
|
-
- ONE REFACTOR AT A TIME. Refactor, test, commit. Then next.
|
|
280
|
-
- Run FULL test suite AND build after every refactor.
|
|
281
|
-
- If tests or build fail, revert the entire change immediately. Do not debug.
|
|
282
|
-
- DO NOT refactor code with insufficient test coverage — write characterization tests first.
|
|
283
|
-
- DO NOT change behavior. Not even "slightly better" behavior. Behavior changes are a separate task.
|
|
284
|
-
- DO NOT change public APIs, exported interfaces, database schemas, or environment variables.
|
|
285
|
-
- DO NOT introduce new libraries or dependencies.
|
|
286
|
-
- DO NOT refactor test files (they serve a different purpose).
|
|
287
|
-
- DO NOT over-abstract. Removing unnecessary abstraction is just as valid as adding necessary abstraction. The goal is the RIGHT level of abstraction, not MORE abstraction.
|
|
288
|
-
- Readability beats cleverness. Always. If the "elegant" version is harder to understand, keep the simple version.
|
|
289
|
-
- Prefer small, obvious improvements over ambitious restructuring. Ten small refactors that each clearly improve one thing are worth more than one large refactor that tries to fix everything.
|
|
290
|
-
- If you're unsure whether a refactor preserves behavior, it's too risky. Document it and move on.
|
|
291
|
-
- You have all night. Take your time. Every refactor should make a developer smile when they read the diff.
|
|
292
|
-
|
|
293
|
-
## Chat Output Requirement
|
|
294
|
-
|
|
295
|
-
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:
|
|
296
|
-
|
|
297
|
-
### 1. Status Line
|
|
298
|
-
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
299
|
-
|
|
300
|
-
### 2. Key Findings
|
|
301
|
-
The most important things discovered — anti-patterns, structural issues, code quality wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with impact.
|
|
302
|
-
|
|
303
|
-
**Good:** "The `OrderService` class (847 lines) handles order creation, payment processing, email sending, inventory management, and analytics — splitting this into focused services would dramatically improve maintainability."
|
|
304
|
-
**Bad:** "Found some long files."
|
|
305
|
-
|
|
306
|
-
### 3. Changes Made
|
|
307
|
-
Bullet list of what was refactored, with before/after metrics where meaningful.
|
|
308
|
-
|
|
309
|
-
### 4. Recommendations
|
|
310
|
-
|
|
311
|
-
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.
|
|
312
|
-
|
|
313
|
-
When recommendations exist, use this table format:
|
|
314
|
-
|
|
315
|
-
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
316
|
-
|---|---|---|---|---|---|
|
|
317
|
-
| *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* |
|
|
318
|
-
|
|
319
|
-
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.
|
|
320
|
-
|
|
321
|
-
### 5. Report Location
|
|
322
|
-
State the full path to the detailed report file for deeper review.
|
|
323
|
-
|
|
324
|
-
---
|
|
325
|
-
|
|
326
|
-
**Formatting rules for chat output:**
|
|
327
|
-
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
328
|
-
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
329
|
-
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|
|
1
|
+
# Code Elegance & Abstraction Refinement
|
|
2
|
+
|
|
3
|
+
You are running an overnight code elegance and abstraction refinement pass. Your job: make the codebase something a senior developer would be proud to open. Untangle spaghetti, put logic in the right layers, simplify the convoluted, and make the code read like well-written prose — all without changing a single behavior.
|
|
4
|
+
|
|
5
|
+
This is the highest-risk overnight run. Every change must preserve exact behavior. Move slowly. Verify obsessively. When in doubt, don't touch it.
|
|
6
|
+
|
|
7
|
+
Work on branch `code-elegance-[date]`.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Global Rules
|
|
12
|
+
|
|
13
|
+
- **Behavior preservation is sacred.** Every refactor must produce identical inputs → identical outputs, identical side effects, identical error behavior. "It works the same but better" is the only acceptable outcome.
|
|
14
|
+
- Run the FULL test suite after every refactor. Not just related tests.
|
|
15
|
+
- Run the build after every refactor.
|
|
16
|
+
- If tests or build fail, revert the ENTIRE change immediately. Do not debug — document what you attempted and move on.
|
|
17
|
+
- **One refactor at a time.** Refactor, test, commit. Then next refactor. Never batch multiple refactors into one commit.
|
|
18
|
+
- Commit format: `refactor: [what you improved] in [file/module]`
|
|
19
|
+
- DO NOT refactor files with less than 60% test coverage unless you write characterization tests first (Phase 1).
|
|
20
|
+
- DO NOT refactor code you don't fully understand. If you can't explain what every line does and why, document it as "needs team review" and skip it.
|
|
21
|
+
- DO NOT rename public API endpoints, exported function signatures, database columns, or environment variables. Internal names are fair game.
|
|
22
|
+
- DO NOT change error messages, log messages, or user-facing strings. Those are behavior.
|
|
23
|
+
- You have all night. Quality of each refactor matters infinitely more than quantity.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Phase 1: Characterization Testing (Safety Net First)
|
|
28
|
+
|
|
29
|
+
Before refactoring anything, you need confidence that existing behavior is captured by tests. This phase builds that safety net for the code you're about to touch.
|
|
30
|
+
|
|
31
|
+
**Step 1: Identify refactoring candidates (quick scan)**
|
|
32
|
+
Do a fast pass through the codebase to identify the ~10-20 files/modules most in need of elegance work (you'll refine this list in Phase 2). Look for:
|
|
33
|
+
- Functions over 50 lines
|
|
34
|
+
- Deeply nested conditionals (3+ levels)
|
|
35
|
+
- Functions with 5+ parameters
|
|
36
|
+
- God classes/modules that do everything
|
|
37
|
+
- Logic that's clearly in the wrong layer (DB queries in route handlers, business rules in UI components, formatting in data models)
|
|
38
|
+
- Copy-paste code with slight variations
|
|
39
|
+
- Overly clever code that requires mental gymnastics to follow
|
|
40
|
+
- Long chains of if/else or switch statements that could be data-driven
|
|
41
|
+
- Callback hell or deeply nested promise chains
|
|
42
|
+
- Functions that mix multiple levels of abstraction (high-level orchestration interleaved with low-level details)
|
|
43
|
+
|
|
44
|
+
**Step 2: Assess test coverage for each candidate**
|
|
45
|
+
For each candidate file/module:
|
|
46
|
+
- What tests exist? What do they cover?
|
|
47
|
+
- Run coverage if tooling exists — what percentage of the code you want to refactor is exercised?
|
|
48
|
+
- Are the tests testing behavior (inputs → outputs, side effects) or implementation details?
|
|
49
|
+
|
|
50
|
+
**Step 3: Write characterization tests where needed**
|
|
51
|
+
For any refactoring candidate with less than 60% coverage on the code you plan to change:
|
|
52
|
+
|
|
53
|
+
- **Characterization tests capture current behavior, not intended behavior.** If the code has a bug, the characterization test should assert the buggy behavior. You're creating a snapshot of "what it does right now" so you'll know if your refactor changes anything.
|
|
54
|
+
- For pure functions: test with a variety of inputs including edge cases. Assert exact outputs.
|
|
55
|
+
- For functions with side effects: mock dependencies, assert the exact sequence of calls with exact arguments.
|
|
56
|
+
- For stateful code: test state transitions with exact before/after snapshots.
|
|
57
|
+
- For error paths: trigger every error condition and assert the exact error type, message, and any side effects.
|
|
58
|
+
- Name these tests clearly: `describe('[function] — characterization tests (pre-refactor)')`
|
|
59
|
+
- Commit: `test: add characterization tests for [module] before refactoring`
|
|
60
|
+
|
|
61
|
+
**DO NOT proceed to Phase 2 for any module until you're confident its behavior is captured by tests.**
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Phase 2: Code Audit & Refactoring Plan
|
|
66
|
+
|
|
67
|
+
Now do a thorough analysis. For each file/module in the codebase, evaluate against these code quality dimensions:
|
|
68
|
+
|
|
69
|
+
### Dimension 1: Single Responsibility
|
|
70
|
+
- Does this function/class/module do ONE thing?
|
|
71
|
+
- Can you describe what it does in one sentence without using "and"?
|
|
72
|
+
- If a function is named `processOrder`, does it ONLY process the order, or does it also send emails, update analytics, and log audit trails?
|
|
73
|
+
|
|
74
|
+
### Dimension 2: Right Level of Abstraction
|
|
75
|
+
- Is high-level orchestration mixed with low-level details? A function that coordinates a workflow should call well-named subfunctions — not contain raw SQL, string parsing, and HTTP calls inline.
|
|
76
|
+
- Is the code at a consistent level of abstraction within each function? (Not mixing "createUser" with "buffer.toString('base64')" in the same block)
|
|
77
|
+
- Are things in the right architectural layer?
|
|
78
|
+
- Route handlers should: validate input, call service layer, format response. Nothing else.
|
|
79
|
+
- Service layer should: orchestrate business logic, coordinate between data sources. No HTTP concepts, no response formatting.
|
|
80
|
+
- Data layer should: query and persist data. No business rules, no formatting.
|
|
81
|
+
- UI components should: render and handle user interaction. No direct API calls, no business logic.
|
|
82
|
+
|
|
83
|
+
### Dimension 3: Readability & Clarity
|
|
84
|
+
- Can a new developer understand this code without tribal knowledge?
|
|
85
|
+
- Are variable/function names descriptive and accurate? (`data` → `unprocessedOrders`, `temp` → `formattedAddress`, `flag` → `isEligibleForDiscount`)
|
|
86
|
+
- Are there magic numbers or strings that should be named constants?
|
|
87
|
+
- Is control flow straightforward, or does it require a flowchart to follow?
|
|
88
|
+
- Are there unnecessary intermediate variables, or conversely, overly long expressions that should be broken up?
|
|
89
|
+
- Are comments explaining "what" (the code should speak for itself) instead of "why" (which is valuable)?
|
|
90
|
+
|
|
91
|
+
### Dimension 4: Simplicity
|
|
92
|
+
- Is there a simpler way to achieve the same result?
|
|
93
|
+
- Are there unnecessary abstractions? (A factory that only creates one type, an interface with one implementation, a wrapper that adds nothing)
|
|
94
|
+
- Are there over-engineered patterns? (Strategy pattern for two cases, observer pattern for one subscriber, dependency injection for something with no tests and no alternate implementations)
|
|
95
|
+
- Conversely, are there missing abstractions? (The same 5-line pattern repeated 12 times that should be a function)
|
|
96
|
+
|
|
97
|
+
### Dimension 5: Function Design
|
|
98
|
+
- Do functions have reasonable parameter counts? (>3 is a smell; >5 is almost always wrong)
|
|
99
|
+
- Could long parameter lists be replaced with an options/config object?
|
|
100
|
+
- Are there boolean "flag" parameters that make the function do two different things? (Split into two functions)
|
|
101
|
+
- Do functions have a single return type, or do they sometimes return a string, sometimes null, sometimes undefined, sometimes an object?
|
|
102
|
+
- Are functions a reasonable length? (>30 lines = usually doing too much)
|
|
103
|
+
|
|
104
|
+
### Create the refactoring plan
|
|
105
|
+
|
|
106
|
+
For each issue found, document:
|
|
107
|
+
- **File and location**
|
|
108
|
+
- **What's wrong** (which dimension, specific description)
|
|
109
|
+
- **Proposed refactor** (exactly what you plan to do)
|
|
110
|
+
- **Risk level**: Low (rename, extract function, simplify conditional) / Medium (restructure module, change abstraction layer) / High (redesign data flow, split god class)
|
|
111
|
+
- **Test coverage**: Adequate / Needs characterization tests first
|
|
112
|
+
|
|
113
|
+
**Priority order for execution:**
|
|
114
|
+
1. Low-risk, high-readability-impact (quick wins that make the code dramatically clearer)
|
|
115
|
+
2. Medium-risk, high-impact (abstraction fixes, layer corrections)
|
|
116
|
+
3. Low-risk, medium-impact (naming, simplification, constant extraction)
|
|
117
|
+
4. High-risk items — document only, do not implement overnight
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Phase 3: Execute Refactors
|
|
122
|
+
|
|
123
|
+
Work through your plan in priority order. For each refactor:
|
|
124
|
+
|
|
125
|
+
### Before touching code:
|
|
126
|
+
- Re-read the function/module completely
|
|
127
|
+
- Verify you understand every code path, including error paths
|
|
128
|
+
- Verify test coverage is adequate (if not, go back to Phase 1)
|
|
129
|
+
- State to yourself: "This refactor changes the structure but not the behavior because: [reason]"
|
|
130
|
+
|
|
131
|
+
### Refactoring Techniques (use as appropriate):
|
|
132
|
+
|
|
133
|
+
**Extract Function** — The workhorse refactor. When a block of code inside a function does a distinct sub-task:
|
|
134
|
+
- Give it a descriptive name that says what it does, not how
|
|
135
|
+
- Pass only what it needs as parameters
|
|
136
|
+
- Return only what the caller needs
|
|
137
|
+
- The calling function should now read like a high-level summary
|
|
138
|
+
|
|
139
|
+
**Extract Constant / Config** — Replace magic numbers and strings:
|
|
140
|
+
- `if (retries > 3)` → `if (retries > MAX_RETRY_ATTEMPTS)`
|
|
141
|
+
- `role === 'admin'` → `role === ROLES.ADMIN` (if roles are used in multiple places)
|
|
142
|
+
- Group related constants in a well-named object or enum
|
|
143
|
+
|
|
144
|
+
**Simplify Conditionals:**
|
|
145
|
+
- Replace nested if/else with early returns (guard clauses)
|
|
146
|
+
- Replace long if/else chains with lookup objects/maps when mapping input → output
|
|
147
|
+
- Replace boolean flag parameters with separate, well-named functions
|
|
148
|
+
- Replace complex boolean expressions with descriptively named variables: `const isEligible = age >= 18 && hasVerifiedEmail && !isBanned;`
|
|
149
|
+
- Invert negative conditions for readability: `if (!isNotReady)` → `if (isReady)`
|
|
150
|
+
|
|
151
|
+
**Flatten Nesting:**
|
|
152
|
+
- Replace `if (condition) { ...lots of code... }` with `if (!condition) return;` followed by the code at the top level
|
|
153
|
+
- Replace nested callbacks with async/await
|
|
154
|
+
- Replace nested loops with helper functions or appropriate array methods
|
|
155
|
+
|
|
156
|
+
**Improve Naming:**
|
|
157
|
+
- Variables should describe what they hold, not their type: `userList` → `activeUsers`, `str` → `serializedPayload`
|
|
158
|
+
- Functions should describe what they do as a verb phrase: `process()` → `calculateShippingCost()`, `handle()` → `routeIncomingWebhook()`
|
|
159
|
+
- Booleans should read as questions: `valid` → `isValid`, `enabled` → `isFeatureEnabled`, `check` → `hasPermission`
|
|
160
|
+
- Match the domain language. If the team says "workspace" not "organization," use "workspace" in code.
|
|
161
|
+
|
|
162
|
+
**Fix Abstraction Layers:**
|
|
163
|
+
- Move database queries out of route handlers into a data/repository layer
|
|
164
|
+
- Move business rules out of UI components into a service/logic layer
|
|
165
|
+
- Move HTTP/response formatting out of business logic into the controller/handler layer
|
|
166
|
+
- Move validation to the input boundary (where data enters the system)
|
|
167
|
+
- Each layer should only know about the layer directly below it
|
|
168
|
+
|
|
169
|
+
**Simplify Over-Engineering:**
|
|
170
|
+
- If a class has one method, it should probably be a function
|
|
171
|
+
- If a factory creates one type, it should probably be a constructor call
|
|
172
|
+
- If an abstraction has one implementation and no tests use an alternate, it may not need to be an abstraction
|
|
173
|
+
- If a config option has never been changed from its default, it might just be a constant
|
|
174
|
+
- Remove dead abstractions — interfaces nobody implements, base classes with one child, strategies with one strategy
|
|
175
|
+
|
|
176
|
+
**Replace Imperative with Declarative (where clearer):**
|
|
177
|
+
- `for` loops building arrays → `map`, `filter`, `reduce` (but only when it's actually clearer — don't force it)
|
|
178
|
+
- Manual object construction from another object → spread/destructuring
|
|
179
|
+
- Repeated conditional checks → lookup tables/maps
|
|
180
|
+
- **Don't over-do this.** A simple `for` loop is sometimes more readable than a clever reduce chain. Readability wins over cleverness every time.
|
|
181
|
+
|
|
182
|
+
### After each refactor:
|
|
183
|
+
1. Run the full test suite
|
|
184
|
+
2. Run the build
|
|
185
|
+
3. Manually verify: does this code do the exact same thing as before? Trace through mentally.
|
|
186
|
+
4. If everything passes: commit with a clear message explaining what was improved and why
|
|
187
|
+
5. If anything fails: revert immediately, document what went wrong, move to next item
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Phase 4: Structural Improvements (Conservative)
|
|
192
|
+
|
|
193
|
+
After individual refactors are complete, look for broader structural improvements. **Only implement low-risk structural changes. Document the rest.**
|
|
194
|
+
|
|
195
|
+
### Safe to implement:
|
|
196
|
+
- Moving a helper function from a file where it doesn't belong to one where it does (update all imports, test, commit)
|
|
197
|
+
- Grouping related functions that are scattered across a file into a logical order
|
|
198
|
+
- Adding section comments to long files that organize code into logical groups
|
|
199
|
+
- Creating a shared utility function from duplicated logic (only if the duplication is exact or near-exact)
|
|
200
|
+
|
|
201
|
+
### Document only — do not implement:
|
|
202
|
+
- Splitting god modules into focused sub-modules (use the File Decomposition prompt for this)
|
|
203
|
+
- Introducing new architectural patterns (repository pattern, service layer, etc.)
|
|
204
|
+
- Changing the project's directory structure
|
|
205
|
+
- Creating new abstraction layers that don't currently exist
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Phase 5: Code Quality Assessment
|
|
210
|
+
|
|
211
|
+
After all refactors are complete, do a final assessment:
|
|
212
|
+
|
|
213
|
+
**Step 1: Before/after comparison**
|
|
214
|
+
For each file you touched, compare:
|
|
215
|
+
- Line count before and after
|
|
216
|
+
- Deepest nesting level before and after
|
|
217
|
+
- Longest function before and after
|
|
218
|
+
- Number of parameters on the most complex function before and after
|
|
219
|
+
- Subjective readability score (1-5) before and after
|
|
220
|
+
|
|
221
|
+
**Step 2: Remaining issues**
|
|
222
|
+
What couldn't you fix, and why?
|
|
223
|
+
- Too risky for overnight
|
|
224
|
+
- Insufficient test coverage
|
|
225
|
+
- Requires team input on intended design
|
|
226
|
+
- Requires broader architectural changes
|
|
227
|
+
|
|
228
|
+
**Step 3: Patterns observed**
|
|
229
|
+
What recurring anti-patterns did you see? These inform team conventions:
|
|
230
|
+
- "Business logic is frequently found in route handlers — the team should adopt a service layer pattern"
|
|
231
|
+
- "Functions regularly mix abstraction levels — consider a team convention of extract-function for anything below the main function's abstraction level"
|
|
232
|
+
- "Magic numbers are pervasive — consider a project-wide constants file or enum convention"
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Output
|
|
237
|
+
|
|
238
|
+
Create `audit-reports/` in project root if needed. Save as `audit-reports/13_CODE_ELEGANCE_REPORT_[run-number]_[date]_[time in user's local time].md`, incrementing run number based on existing reports.
|
|
239
|
+
|
|
240
|
+
### Report Structure
|
|
241
|
+
|
|
242
|
+
1. **Executive Summary** — Files analyzed, refactors executed, refactors reverted, tests still passing, overall assessment of code quality improvement.
|
|
243
|
+
|
|
244
|
+
2. **Characterization Tests Written** — Table: | File/Module | Tests Added | Coverage Before | Coverage After | Purpose |. These tests have value beyond this refactoring pass — they document current behavior.
|
|
245
|
+
|
|
246
|
+
3. **Refactors Executed** — For each refactor:
|
|
247
|
+
| File | What Changed | Technique Used | Risk Level | Before (metrics) | After (metrics) |
|
|
248
|
+
|
|
249
|
+
Plus a brief description of what was improved and why for non-obvious changes.
|
|
250
|
+
|
|
251
|
+
4. **Refactors Attempted but Reverted** — What you tried, what broke, and your assessment of why.
|
|
252
|
+
|
|
253
|
+
5. **Refactors Identified but Not Attempted** — The backlog. For each:
|
|
254
|
+
| File | Issue | Proposed Refactor | Risk Level | Why Not Attempted | Priority for Next Run |
|
|
255
|
+
|
|
256
|
+
6. **Code Quality Metrics** — Before/after summary:
|
|
257
|
+
- Longest function (lines): before → after
|
|
258
|
+
- Deepest nesting level: before → after
|
|
259
|
+
- Largest parameter count: before → after
|
|
260
|
+
- Functions over 50 lines: before → after
|
|
261
|
+
- Files with mixed abstraction layers: before → after
|
|
262
|
+
|
|
263
|
+
7. **Anti-Pattern Inventory** — Recurring patterns the team should address as conventions:
|
|
264
|
+
| Pattern | Frequency | Where It Appears | Recommended Convention |
|
|
265
|
+
|
|
266
|
+
8. **Abstraction Layer Assessment** — Current state of architectural layering:
|
|
267
|
+
- Which layers exist and are respected?
|
|
268
|
+
- Which layers are violated and where?
|
|
269
|
+
- Recommended layer boundaries for this project
|
|
270
|
+
|
|
271
|
+
9. **Recommendations** — Priority-ordered next steps:
|
|
272
|
+
- Refactors to attempt in the next run (from the backlog)
|
|
273
|
+
- Conventions to adopt to prevent new code from regressing
|
|
274
|
+
- Architectural improvements that would benefit the codebase
|
|
275
|
+
- Areas needing team discussion before refactoring
|
|
276
|
+
|
|
277
|
+
## Rules
|
|
278
|
+
- Branch: `code-elegance-[date]`
|
|
279
|
+
- ONE REFACTOR AT A TIME. Refactor, test, commit. Then next.
|
|
280
|
+
- Run FULL test suite AND build after every refactor.
|
|
281
|
+
- If tests or build fail, revert the entire change immediately. Do not debug.
|
|
282
|
+
- DO NOT refactor code with insufficient test coverage — write characterization tests first.
|
|
283
|
+
- DO NOT change behavior. Not even "slightly better" behavior. Behavior changes are a separate task.
|
|
284
|
+
- DO NOT change public APIs, exported interfaces, database schemas, or environment variables.
|
|
285
|
+
- DO NOT introduce new libraries or dependencies.
|
|
286
|
+
- DO NOT refactor test files (they serve a different purpose).
|
|
287
|
+
- DO NOT over-abstract. Removing unnecessary abstraction is just as valid as adding necessary abstraction. The goal is the RIGHT level of abstraction, not MORE abstraction.
|
|
288
|
+
- Readability beats cleverness. Always. If the "elegant" version is harder to understand, keep the simple version.
|
|
289
|
+
- Prefer small, obvious improvements over ambitious restructuring. Ten small refactors that each clearly improve one thing are worth more than one large refactor that tries to fix everything.
|
|
290
|
+
- If you're unsure whether a refactor preserves behavior, it's too risky. Document it and move on.
|
|
291
|
+
- You have all night. Take your time. Every refactor should make a developer smile when they read the diff.
|
|
292
|
+
|
|
293
|
+
## Chat Output Requirement
|
|
294
|
+
|
|
295
|
+
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:
|
|
296
|
+
|
|
297
|
+
### 1. Status Line
|
|
298
|
+
One sentence: what you did, how long it took, and whether all tests still pass.
|
|
299
|
+
|
|
300
|
+
### 2. Key Findings
|
|
301
|
+
The most important things discovered — anti-patterns, structural issues, code quality wins, or surprises. Each bullet should be specific and actionable, not vague. Lead with impact.
|
|
302
|
+
|
|
303
|
+
**Good:** "The `OrderService` class (847 lines) handles order creation, payment processing, email sending, inventory management, and analytics — splitting this into focused services would dramatically improve maintainability."
|
|
304
|
+
**Bad:** "Found some long files."
|
|
305
|
+
|
|
306
|
+
### 3. Changes Made
|
|
307
|
+
Bullet list of what was refactored, with before/after metrics where meaningful.
|
|
308
|
+
|
|
309
|
+
### 4. Recommendations
|
|
310
|
+
|
|
311
|
+
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.
|
|
312
|
+
|
|
313
|
+
When recommendations exist, use this table format:
|
|
314
|
+
|
|
315
|
+
| # | Recommendation | Impact | Risk if Ignored | Worth Doing? | Details |
|
|
316
|
+
|---|---|---|---|---|---|
|
|
317
|
+
| *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* |
|
|
318
|
+
|
|
319
|
+
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.
|
|
320
|
+
|
|
321
|
+
### 5. Report Location
|
|
322
|
+
State the full path to the detailed report file for deeper review.
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
**Formatting rules for chat output:**
|
|
327
|
+
- Use markdown headers, bold for severity labels, and bullet points for scannability.
|
|
328
|
+
- Do not duplicate the full report contents — just the highlights and recommendations.
|
|
329
|
+
- If you made zero findings in a phase, say so in one line rather than omitting it silently.
|