Skip to content
NeuralSkills
Refactoring

Code Smell Detector

Identify and fix common code smells like long methods, god objects, and magic numbers with AI.

Intermediate Free Published: April 15, 2026
Compatible Tools claude-codechatgptgeminicopilotcursorwindsurfuniversal

The Problem

Code smells accumulate silently. A function grows to 200 lines, a class takes on seven responsibilities, magic numbers appear everywhere. By the time the codebase feels “heavy,” the smells are so deeply embedded that developers avoid refactoring out of fear of breaking things. Early detection prevents technical debt from compounding.

The Prompt

You are a senior code quality engineer. Analyze the following code for code smells:

CODE:
[paste your code here — a function, class, or module]

LANGUAGE: [e.g., TypeScript, Python, Java]

For each code smell found, provide:
1. **Smell Name**: The official name (e.g., Long Method, Feature Envy, Primitive Obsession)
2. **Location**: Which lines or section
3. **Severity**: High / Medium / Low
4. **Why It Matters**: The concrete risk if left unfixed
5. **Refactoring**: The specific refactoring technique to apply (e.g., Extract Method, Replace Conditional with Polymorphism)
6. **Refactored Code**: Show the improved version of that specific section

Prioritize smells by severity. Only flag genuine issues — do not nitpick style preferences.

Example Output

1. Long Method — processOrder() is 147 lines (lines 23-170)
   Severity: High
   Why: Impossible to test individual steps; any change risks breaking unrelated logic.
   Refactoring: Extract Method — split into validateItems(), calculateTotal(),
   applyDiscounts(), processPayment(), sendConfirmation().

2. Magic Numbers — lines 45, 67, 89
   Severity: Medium
   Why: 0.08 (tax rate?), 500 (free shipping threshold?), 30 (return days?) are
   unclear and duplicated.
   Refactoring: Replace Magic Number with Named Constant.
   const TAX_RATE = 0.08;
   const FREE_SHIPPING_THRESHOLD = 500;
   const RETURN_WINDOW_DAYS = 30;

When to Use

Use this skill during code reviews, before major refactoring efforts, or when onboarding onto a legacy codebase. It is most effective when you paste entire files or classes rather than isolated snippets, because many code smells are about relationships between parts of the code.

Pro Tips

  • Run it on your own code first — it is easier to accept feedback from AI than from a colleague, and you will catch smells before they reach code review.
  • Ask for a prioritized refactoring plan — append “Create a refactoring plan I can execute in 3 one-hour sessions” to get an actionable roadmap instead of an overwhelming list.
  • Pair with tests — ask “Which tests should I write before applying each refactoring?” so you have a safety net before changing anything.