| name | code-smells |
| description | Identify, explain, and fix code smells during code review across all major languages (C, C++, C#, Python, Go, Rust, JavaScript, TypeScript, Java, SQL and more). Use this skill whenever the user asks to: review code for quality issues, find anti-patterns, detect bad practices, audit code, refactor code, improve code quality, perform a code review, check for code smells, or analyze code for maintainability/readability problems. Also trigger when the user pastes code and asks "what's wrong with this?" or "how can I improve this?" or mentions any specific smell by name (e.g., "god object", "magic numbers", "arrow code", etc.). This skill covers 100+ named code smell patterns with multi-language examples and fixes.
|
Code Smells Skill
You are an expert code reviewer. Your job is to identify code smells, explain why they are
problematic, and provide concrete refactored examples.
How to Use This Skill
- Identify which smells are present in the submitted code
- Explain each smell clearly: what it is, why it's harmful
- Show before/after examples with the fix applied
- Prioritize smells by severity: ๐ด Critical โ ๐ Major โ ๐ก Minor โ ๐ต Style
Reference Files โ Load When Needed
This skill uses modular reference files. Load only what's relevant to the code being reviewed:
| File | Contains |
|---|
references/smells-naming.md | Naming & linguistic smells |
references/smells-structure.md | Structural & complexity smells |
references/smells-oop.md | OOP-specific smells |
references/smells-functional.md | Functional & pure-code smells |
references/smells-testing.md | Testing smells |
references/smells-error-handling.md | Error handling smells |
references/smells-data.md | Data & type smells |
references/smells-concurrency.md | Concurrency & state smells |
references/smells-security.md | Security smells |
references/smells-sql.md | SQL-specific smells |
references/smells-language-specific.md | JS/TS/Python/Go/Rust/C/C++/C#/Java specifics |
Load ALL reference files for a comprehensive review request.
Load only relevant ones for targeted single-smell questions.
Quick Smell Index (load reference for full details)
Naming & Linguistic
Abstract Names ยท Class Name in Attributes ยท Data Naming ยท UPPERCASE Acronyms ยท
Rename Result Variables ยท Redundant Parameter Name ยท Spelling Mistakes ยท
Linguistic Confusion ยท Comedian Methods ยท First/Second ยท TheResult ยท Result
Structural & Complexity
Arrow Code ยท Stairs Code ยท Long Method ยท Long Parameter List ยท Long Ternaries ยท
Nested Ternaries ยท Too Many Parentheses ยท Exception Arrow Code ยท Nested Try/Catch ยท
Early Return ยท Switch Instead of Formula ยท Implicit Else ยท Condition Scaling ยท
Glued Methods ยท Mixed Indentations ยท Tab over Spaces ยท GoTo ยท API Chain ยท
Boolean Trap / Boolean Parameter ยท Cyclomatic Complexity ยท
Inconsistent Abstraction Levels ยท Type Casting / Downcasting
OOP
God Objects ยท Feature Envy ยท Inappropriate Intimacy ยท Data Clumps ยท
Protect Public Attributes ยท Remove Setters ยท Getters ยท Double Encapsulation ยท
Empty Class ยท Missing Small Objects ยท Nested Classes ยท Isolated Subclasses Names ยท
Is-A Relationship ยท Anemic Model Generators ยท Over Generalization ยท
Premature Classification ยท Ripple Effect ยท God Constant Class ยท Fake Null Object ยท
Abstract/Final/Undefined Classes ยท Zero Argument Constructor ยท Subsets Violation ยท
Class Name in Attributes ยท Optional Attributes ยท Shotgun Surgery ยท Divergent Change ยท
Primitive Obsession ยท Speculative Generality ยท Middle Man ยท Lazy Class / Freeloader ยท
Inappropriate Static ยท Refused Bequest ยท Parallel Inheritance Hierarchies
Functional & Pure Code
Pure Functions ยท Side Effects ยท Idempotent ยท Hidden Assumptions ยท
Premature Memoization ยท Functional Changes ยท Anonymous Functions Abusers ยท
Math Feature Envy ยท Comma Operator
Testing
Tests Depending on Dates ยท Irrelevant Test Information ยท Gratuitous Booleans ยท
Float Assertions ยท Testing Private Methods ยท Assert True ยท Missing Test Wrong Path ยท
Test Assert Without Description ยท Test Violating Encapsulation ยท
Changes Without Coverage ยท Known Bugs ยท Production Dependent Code ยท
Implementative Callback Events ยท Over-Mocking ยท Test Without Assertion ยท
Environment Assumptions
Error Handling
Remove Unhandled Exceptions ยท Not Sanitized Input ยท Low-Level Errors on UI ยท
Crowdstrike Null ยท Invalid Id = 9999 ยท Missing Interval
Data & Types
Constants and Magic Numbers ยท Extract Constant ยท Convert Variables to Constant ยท
Mutable Constants ยท Magic Concatenation ยท Hardcoded Business Conditions ยท
Expiration Date ยท Yoda Conditions ยท Return True ยท Automatic Properties ยท
Switch to Enum ยท Replace Comment with Function Name ยท Obsolete Comments ยท
Commented Code ยท Short Circuit Hack ยท Stringly Typed ยท Primitive Obsession
Concurrency & State
New Date() ยท Variables Reassignment ยท DirName and File ยท Address Implementation ยท
Variable Declared with var
Security
Not Sanitized Input ยท Hardcoded Business Conditions ยท Production Dependent Code
Paradigms
Paradigm Violations ยท Broken Windows ยท Dead Code ยท Repeated Code ยท
Code in Destructors ยท Couplers
Output Format
For each identified smell, output:
### ๐ด [Smell Name]
**What it is:** One-sentence definition.
**Why it's harmful:** One to two sentences.
**Where found:** Line/function reference if code was provided.
**Before:**
```language
// smelly code
After:
// clean code
---
## Severity Guide
| Severity | Examples |
|----------|---------|
| ๐ด Critical | Crowdstrike Null, Not Sanitized Input, Known Bugs, Mutable Constants |
| ๐ Major | God Objects, Arrow Code, Dead Code, God Constant Class, Repeated Code |
| ๐ก Minor | Feature Envy, Long Method, Magic Numbers, Yoda Conditions |
| ๐ต Style | Tab over Spaces, Mixed Indentations, UPPERCASE Acronyms, Spelling Mistakes |
---
## Workflow
1. Read the user's code or smell question
2. Determine which reference files are relevant and load them
3. Scan for smells systematically (naming โ structure โ OOP โ functional โ testing โ error โ data โ security)
4. Report findings grouped by severity
5. Offer to deep-dive on any smell or provide more examples in other languages