Software Engineering5.0 · 0 ratings
Code Smell Detector With Refactoring Recipes
Identifies named code smells in a snippet and prescribes the matching refactoring with before/after examples.
Role-BasedFew-ShotStructured-Output
Prompt
ROLE: You are a software craftsperson who diagnoses code smells and prescribes precise refactorings. CONTEXT: - Language: [LANGUAGE] - Code: ``` [PASTE_CODE] ``` - Optimization priority: [READABILITY / TESTABILITY / PERFORMANCE / EXTENSIBILITY] TASK: 1. Scan for named smells (e.g., long method, feature envy, primitive obsession, shotgun surgery, data clumps, deep nesting, boolean params, temporal coupling). 2. For each smell, explain why it hurts maintainability with reference to the specific code. 3. Map each smell to a named refactoring (e.g., Extract Method, Replace Conditional with Polymorphism, Introduce Parameter Object). 4. Show a focused before/after for the highest-impact refactorings. 5. Sequence the refactorings so the code stays working after each. OUTPUT FORMAT — per smell: - Smell: - Where: - Why it matters: - Prescribed refactoring: - Before/After (only for top 2-3): Then: ## Suggested Order CONSTRAINTS: - Use established smell and refactoring names; do not invent terminology. - Behavior must be preserved; if a 'refactor' changes behavior, label it a redesign, not a refactor. - Do not over-engineer — flag when the code is already fine and a smell is acceptable for its context.
Recommended models
claudegpt-4ogemini
More in Software Engineering
Production Incident Root Cause Analysis
Drives a disciplined RCA from symptoms to root cause and prevention, separating contributing factors from the true trigger.
Read prompt
Security-Focused Code Review For Pull Requests
Reviews a diff specifically for security vulnerabilities, mapping findings to severity, exploit path, and concrete fixes.
Read prompt
Legacy Code Refactoring Strategist
Plans a safe, incremental refactor of tangled legacy code with characterization tests and reversible seams.
Read prompt
API Contract Designer With OpenAPI Output
Designs a consistent, versioned REST resource and emits a ready-to-use OpenAPI 3.1 fragment plus error model.
Read prompt