Code Smell Detector and Fixer
Identify code smells in existing code and get refactored versions
Review this code for code smells and refactor it: ``` [PASTE_CODE_TO_REVIEW] ``` For each issue found: 1. **Smell name** — e.g., "Long Method", "Feature Envy", "Primitive Obsession" 2. **Location** — which lines/functions 3. **Why it's a problem** — concrete impact (harder to test, likely to cause bugs, etc.) 4. **Refactored code** — the improved version 5. **Technique used** — e.g., "Extract Method", "Replace Conditional with Polymorphism" Priority order: fix bugs first, then readability issues, then style. Do NOT: - Change working behavior (preserve all existing functionality) - Add features or error handling that didn't exist - Over-abstract (don't create helpers for one-time code) - Change public API signatures without flagging it After refactoring, provide: - A diff summary of what changed and why - Confidence level that the refactoring preserves behavior (High/Medium/Low) - Suggested tests to verify the refactoring didn't break anything
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
Part of 2 Collections
Debug Like a Pro
9 promptsSystematic debugging prompts that help you find root causes faster — from memory leaks to race conditions to performance bottlenecks.
View collection →Clean Code Rescue
8 promptsRefactoring prompts to turn messy codebases into maintainable ones — extract services, simplify conditionals, modernize legacy patterns.
View collection →More Refactoring Prompts
Related refactoring templates from the vault
Switch Statement to Strategy Pattern
Use this prompt to switch statement to strategy pattern with AI assistance
Nested Conditionals Flattener
Use this prompt to nested conditionals flattener with AI assistance
Code Review Prompt
Get a thorough code review with actionable feedback
Extract Shared Hook from Components
Identify duplicated logic across components and extract into a reusable hook
You Might Also Like
Prompts from other categories that share similar tags
Hexagonal Architecture Scaffold
Use this prompt to hexagonal architecture scaffold with AI assistance
Ports and Adapters Generator
Use this prompt to ports and adapters generator with AI assistance
SOLID Principles Refactoring Guide
Use this prompt to solid principles refactoring guide with AI assistance
Onion Architecture Template
Use this prompt to onion architecture template with AI assistance
Keep Exploring the Vault