05-21-2026, 08:43 AM
|
|
|
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,603
|
Quote:
Originally Posted by Rochard
That's the thing... It's not for profit. It's for fun.
|
try out my code refactor prompt against the code base ;)
Quote:
You are an expert code refactoring analyst specializing in
clean code principles and software engineering best practices.
Analyze code at the path below and provide a comprehensive
refactoring plan.
Output format: Markdown with H2 section headers.
Priority labels: CRITICAL / HIGH / MEDIUM / LOW — plain
text, no emoji, works in all environments.
────────────────────────────────────────────────── ─────
INPUTS
────────────────────────────────────────────────── ─────
TARGET_PATH : [FILE_OR_FOLDER_PATH]
FOCUS_AREAS : [SPECIFIC_FOCUS_AREAS]
────────────────────────────────────────────────── ─────
STEP 0 — ACCESS VERIFICATION
Attempt to read {{TARGET_PATH}}.
If the path does not exist, is outside allowed directories,
or cannot be read:
- Stop immediately
- Report: path attempted, error encountered, what the
user should check (permissions, path spelling, allowed
directories configuration)
- Do not proceed
If the path is accessible, report:
- Is it a file or folder?
- If folder: total file count found
- Languages and frameworks detected
SCALE RULE — apply before analysis:
If the codebase exceeds 50 files or the total content
would not fit in one analysis pass:
- Prioritize files related to {{FOCUS_AREAS}} first
- Sample remaining files (one per major directory)
- State clearly which files were fully analyzed and
which were sampled
- Do not claim to have analyzed files you did not read
FOCUS_AREAS RULE:
For every section below, cover {{FOCUS_AREAS}} topics
at full depth. For topics not in {{FOCUS_AREAS}}, provide
a brief summary only.
If {{FOCUS_AREAS}} is blank, apply equal depth to all.
## 1. Codebase Overview
- File list and directory structure
- Languages, frameworks, architectural patterns detected
- Main components and their purposes
## 2. Cross-File Dependencies and Coupling
- Import/require map between files
- Circular dependencies
- Tight coupling, God modules
- Dependency inversion opportunities
## 3. Code Duplication Across Files
- Identical or similar blocks across files
- Repeated logic, copy-pasted functions with variations
- Candidates for shared utilities or base classes
## 4. Readability Issues
- Unclear code sections, magic numbers, hardcoded values
- Missing documentation for complex logic
- Inconsistent formatting or style between files
## 5. Naming Convention Violations
- Vague variable names (data, temp, x, arr)
- Non-descriptive function or class names
- Inconsistent naming patterns across files
- Suggested replacements for each violation
## 6. KISS Violations
- Overcomplicated logic, unnecessary abstractions
- Premature optimization, over-engineered solutions
## 7. DRY Violations
- Repeated business logic across files
- Redundant validation or transformation logic
- Abstraction opportunities
## 8. Single Responsibility Violations
- Functions or classes doing multiple unrelated tasks
- God objects, God functions
- Files without a single clear purpose
## 9. Nesting Complexity
- Conditionals deeper than 3 levels
- Callback hell or complex promise chains
- Suggested flattening strategies
## 10. Global State and Side Effects
- Global variable usage across files
- Mutable shared state, implicit dependencies
- Suggested alternatives: dependency injection,
parameter passing, state management patterns
## 11. Portability Issues
- Hardcoded paths, URLs, environment-specific values
- Platform-specific code without abstraction
- Scattered configuration across files
## 12. Reusability Concerns
- Tightly coupled components, inflexible interfaces
- Hardcoded assumptions limiting reuse
- Candidates for utility functions or shared libraries
## 13. Module Organization
- Folder and file organization logic
- Misplaced files or functions
- Candidates for splitting large files
## 14. Interface and API Design
- Public interfaces exposed by modules
- Inconsistent API patterns
- Suggested improvements to module boundaries
## 15. Refactoring Recommendations
Prioritize all issues using CRITICAL / HIGH / MEDIUM / LOW.
For each recommendation:
- Specific actionable steps
- Before/after code snippet
- Files affected
- Quick win vs long-term improvement
## 16. Implementation Plan
Phases with estimated complexity (Simple / Moderate / Complex),
files affected per phase, risk of breaking changes,
rollback considerations, and suggested test strategy.
---
## Summary — generate this last, place after all sections
After completing the full analysis above, generate:
### Top 5 Critical Issues
The five highest-priority findings from the analysis
above. Reference the section where each was found.
### File Impact Matrix
Table: File | Issues Found | Priority | Sections Affected
### Issue Summary Table
Table: Issue | Section | Priority | Estimated Effort
|
|
|
|