Resource Gathering
General Refactoring Sub use cases:
When/Why we refactor:
Improve Code Readability
Makes the code easier to understand for current and future developers.
Uses clearer variable names, breaks up large functions, and simplifies logic.
Reduce Technical Debt
Cleans up "quick fixes" or poor design decisions made under time pressure.
Prevents future bugs and development slowdowns.
Make Code Easier to Test
Encourages separation of concerns and modularity.
Refactored code is often more unit-testable and reliable.
Enable Reuse and Scalability
Extracts duplicated logic into reusable components or utilities.
Makes it easier to extend features without breaking existing functionality.
Improve Performance
Identifies and removes inefficient logic, memory leaks, or unnecessary computations.
Not always the primary goal, but often a beneficial side effect.
Prepare for New Features
Refactoring before adding features ensures the architecture supports expansion.
Helps avoid “spaghetti code” when introducing complexity.
Fix Hidden Bugs or Prevent Future Ones
Cleaning up messy or unclear code can reveal logic errors.
Refactoring can proactively prevent bugs caused by unclear logic paths.
Sub-use cases of Refactoring:
Partial refactor and Recommendations
General refactor of parts of the application (for the reasons listed above)
Complete rewrite
to a new language
Update framework/dependency versions
Scale measures
Scale | Description |
|---|---|
0 | Could not perform task at all |
1 | Could perform task with a lot of guiding, context, and errors. Does not follow best practices, has multiple errors that must be resolved. Has all of the following: errors, organization issues, lack cleanliness, etc. |
2 | Could perform task with a large amount assistance and guiding. Has errors and bugs. Has most of the following: errors, organization issues, lack cleanliness, etc. |
3 | Could perform task well with a fair amount of guiding. Has some errors/bugs, but they can be resolved somewhat easily. Has several of the following: errors, organization issues, lack cleanliness, etc. |
4 | Could perform task easily with some guiding but still has some outstanding issues. May have some of the following: errors, organization issues, lack cleanliness, etc, but not all of those issues exist. |
5 | Could preform task with minimal difficulty/guiding, follows best practices, organized code, and correct typing. May have one of the following: errors, organization issues, lack cleanliness, etc. |
Tools
Tool | Description | Links | Rating |
|---|---|---|---|
Copilot with Claude and GPT,
| The VSCode addon we know and love. This is a great tool that has the ability to get the full context of the codebase since it is in VSCode |
| |
Q Developer (CodeWhisperer)
| Can be used in-line and has a right-click menu, similar to Copilot. Uses Claude. Can have rules added directly from the sidebar, and context adding is simple.
|
| |
SonarQube
|
|
| |
CodeBuddy
|
|
| |
Cursor
|
|
| |
Aider | Terminal based pair programming |
| |
GPT-Migrate | Python app that runs in Docker. |
| |
CLine |
|
|
Codebases for POC:
Staffing App
Status Reports
Angular Place My Order app?
React Native PMO?
Paths to consider
Measuring code quality with Code analysis tools
Identifying technical debt, and recommending changes
Custom GPT (There is already a devops one)
Complete rewrites: How to take a codebase in React and rewrite it in React Native (or insert two other frameworks here)
For this, I think it’s important first to understand the codebase.
🧠✍️ Content idea: Understand a codebase with AI and then rewrite it with AI
Content for ideas:
Good for giving AI context before having it add new features https://www.youtube.com/watch?v=weaal3xZomc
“Explore the entire repository to understand the codebase from multiple angles: as a software architect, software developer, and product manager. Compile your findings into a very extensive Markdown document in the root of the repository. For describing technical concepts, use Mermaid diagrams in the Markdown file.”
Add the markdown file in the
user > settings.jsonfile.`
"github.copilot.chat.codeGeneration.instructions": [ { "file": "CODEBASE_ANALYSIS.md" }, { "text": "Always add a comment: 'Generated by Copilot'." } ]“Act as a Product Manager for theStaffing App. We need an Advanced Analytics Dashboard page with visulizations (heat maps, skill demand trends, capacity forecasting), drill down capabilities (high level metrics to individual employee details), and export functionality (pdf reports, csv data exports). Do not code anything yet, instead, deeply think about which requirements we need and how the page should operate and describe the user stories in detail in a Product Requirements Document”
fully implement the PRD as an MVP that, for now, just uses static frontend data.
Prompt formatting ideas, and parellel agents with Claude Code: https://github.com/disler/benchy/blob/main/specs/ui-revamp.md , https://www.youtube.com/watch?v=f8RnRuaxee8
Workflow sample: https://www.reddit.com/r/ChatGPTCoding/comments/1kxjtjm/my_ai_coding_workflow_thats_actually_working_not/
Workflow sample (CLine): https://www.reddit.com/r/CLine/comments/1kgikrs/help_with_best_practices_for_refactoring_code/
AI build sample (Potpie): https://www.reddit.com/r/AI_Agents/comments/1isimqr/i_built_an_ai_agent_that_makes_your_project/
Example of something WE DON’T WANT: https://www.youtube.com/watch?v=JWgyoX8ZCi8
General Refactoring
Approaches
Basic approach without giving full context: “Refactor this component to improve readability” in Copilot
GPT4
Removes
eslintcomments, but does not fix missing dependency.
Claude Sonnet 4
ignores existing
eslintcomments to keep a dependency out of auseEffectunless explicitly asked to keep.
The context builder:
Ask LLM to scan entire codebase, creating a Markdown document that explains the codebase in enough detail for a developer to understand.
Use that document for the LLM to reference as you begin prompting. The idea is that the LLM can reference the doc instead of the entire codebase each time.
Insights
Copilot has greater context for the code as it’s an extension of VS Code.
How to get LLMs appropriate context.
Add rules for LLMs to follow while refactoring
Takeaways
Copilot does a great job of taking reusability, separation of concerns, scalability, and readability into consideration.
Web-based Claude creates separate files, which is a nice feature.
Code may be over-engineered.
ignores existing
eslintcomments to keep a dependency out of auseEffectunless explicitly asked to keep.
Copilot can be good for adding features, and writing up user stories/PRD when given context.
Need to make sure that with any refactor work, the LLM has sufficient context to complete the task. Workflows should include initial context set up, rules configuration, and THEN attempts at problem solving, followed by tuning/refining the results.