ワンクリックで
code-smells
Detect code smells based on refactoring.guru catalog - use when analyzing code for anti-patterns and refactoring opportunities
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Detect code smells based on refactoring.guru catalog - use when analyzing code for anti-patterns and refactoring opportunities
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Given a TheRock nightly build (URL or run-id), return the rocm-systems pin_sha used in that build
Check whether a given rocm-systems commit is included in a specific TheRock nightly build
Find the first TheRock nightly build that includes a given rocm-systems commit
Reviews Pull Requests or local diffs with an 8-agent fan-out covering static analysis, dead code, code smells + quality (naming, complexity, single-responsibility, magic numbers), language rules (C++/Python/CMake), architecture, simplification, performance (hot-path classification, allocations, locks, I/O), and undefined behaviour (signed overflow, lifetime, strict aliasing, data races, sanitizer coverage; C/C++/unsafe-Rust only). Use when the user asks to "review this PR", "review the diff", "audit this branch", "/pr-review", or when staging changes before push.
Walk through a PR review interactively, one finding at a time. Generate review via pr-review, then for each issue present analysis + proposed inline comment, let user accept/edit/skip, accumulate into a PENDING GitHub review, submit at end.
Use when user wants to list, analyze, review, or summarize GitHub PR comments on a pull request number or URL
| name | code-smells |
| description | Detect code smells based on refactoring.guru catalog - use when analyzing code for anti-patterns and refactoring opportunities |
Comprehensive catalog of code smells for detecting anti-patterns and identifying refactoring opportunities. Based on the Refactoring.Guru Code Smells Catalog.
This skill is a **reference catalog** for code smell detection. It is used by: - `pr-review` Agent 3 (Code Smells Agent) during PR review - `planning-refactor` when identifying improvement opportunities - Standalone code quality analysisWhen detecting smells, report findings in structured format with:
| Context | Trigger |
|---|---|
| PR Review | Invoked by pr-review Code Smells Agent |
| Refactoring Planning | Before planning-refactor to identify targets |
| Code Quality Audit | User asks to analyze code quality or find anti-patterns |
| Technical Debt Assessment | Identifying areas needing improvement |
| Severity | Score | Impact | Examples |
|---|---|---|---|
| Critical | 100 | Causes bugs, crashes, security issues | Feature Envy causing null dereference |
| Must Fix | 80 | Significantly harms maintainability | God Class, Shotgun Surgery |
| Should Fix | 50 | Reduces code quality | Long Method, Duplicate Code |
| Nitpick | 20 | Minor improvement opportunity | Lazy Class, Comments |
When reporting code smells, use this structured format:
| File:Line | Smell | Category | Severity | Suggested Refactoring |
|-----------|-------|----------|----------|----------------------|
| handler.cpp:120-195 | Long Method (75 lines) | Bloater | Should Fix (50) | Extract Method: split into validateRequest(), processData(), buildResponse() |
| config.cpp:45 | Magic Number | Bloater | Should Fix (50) | Replace Magic Number: `const int MAX_RETRIES = 42;` |
Code that has grown to excessive proportions, making it hard to work with.
Threshold: >10 lines warrants questions, >50 lines is definite smell
Signs:
Why it's bad:
Detection criteria:
- Lines > 50: Should Fix (50)
- Lines > 100: Must Fix (80)
- Method does more than one thing (multiple responsibilities)
- Requires extensive comments to explain
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Method | Split into smaller methods with descriptive names |
| Replace Temp with Query | Local variables interfering with extraction |
| Introduce Parameter Object | Many parameters passed between methods |
| Decompose Conditional | Complex if/else chains |
| Replace Method with Method Object | When extraction is too complex |
Threshold: Too many fields, methods, or lines (>500 lines warrants review)
Signs:
Why it's bad:
Detection criteria:
- Lines > 500: Should Fix (50)
- Lines > 1000: Must Fix (80)
- >10 public methods: Review for SRP violation
- >15 fields: Likely doing too much
- Multiple unrelated method groups
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Class | Separate distinct behavioral components |
| Extract Subclass | Behavior used only in some cases |
| Extract Interface | Define contract for operations |
| Duplicate Observed Data | GUI classes with domain logic |
Signs:
USER_ADMIN_ROLE = 1)int for IDs instead of typed wrapperWhy it's bad:
Detection criteria:
- Multiple functions operating on same primitive group: Should Fix (50)
- Constants simulating types: Should Fix (50)
- No domain objects for business concepts (money, date ranges, coordinates): Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Replace Data Value with Object | Group primitives into dedicated classes |
| Introduce Parameter Object | Primitives in method parameters |
| Preserve Whole Object | Passing extracted values instead of object |
| Replace Type Code with Class/Subclasses/State | Constants simulating types |
| Replace Array with Object | Using arrays with string keys |
Threshold: >3-4 parameters
Signs:
Why it's bad:
Detection criteria:
- 4-5 parameters: Should Fix (50)
- 6+ parameters: Must Fix (80)
- Boolean "flag" parameters: Should Fix (50)
- Parameters from same object: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Replace Parameter with Method Call | Parameter is result of another call |
| Preserve Whole Object | Passing multiple fields from same object |
| Introduce Parameter Object | Group related parameters |
When to ignore: Creating dependencies between classes may be worse than long parameter list.
Signs:
Why it's bad:
Detection criteria:
- Same 3+ parameters in multiple method signatures: Should Fix (50)
- Same fields grouped in multiple classes: Should Fix (50)
- Database connection parameters passed separately: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Class | For class fields |
| Introduce Parameter Object | For method parameters |
| Preserve Whole Object | Pass object instead of extracting values |
Incomplete or incorrect application of object-oriented programming principles.
Signs:
switch operator or if-else chain based on typeWhy it's bad:
switch is hallmark of good OOPDetection criteria:
- Switch on type/enum with behavior: Should Fix (50)
- Same switch in multiple places: Must Fix (80)
- Switch with >5 cases with different behavior: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Replace Conditional with Polymorphism | When switch determines behavior |
| Replace Type Code with Subclasses | Type codes with distinct behavior |
| Replace Type Code with State/Strategy | Behavior varies at runtime |
| Replace Parameter with Explicit Methods | Simple value-based switches |
| Introduce Null Object | Null checks in conditionals |
When to ignore: Factory patterns legitimately use switch to create objects.
Signs:
Why it's bad:
Detection criteria:
- Field used in <25% of methods: Should Fix (50)
- Field only set in one method and used in another: Should Fix (50)
- Fields for algorithm-specific data: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Class | Move field and related code to separate class |
| Replace Method with Method Object | Algorithm needs many temp fields |
| Introduce Null Object | Replace null checks with null object pattern |
Signs:
Why it's bad:
Detection criteria:
- Override methods with empty body or exception: Should Fix (50)
- Subclass ignores >50% of parent interface: Should Fix (50)
- Inheritance for code reuse, not "is-a": Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Replace Inheritance with Delegation | Wrong hierarchy, use composition |
| Extract Superclass | Create proper abstraction for shared behavior |
Signs:
Why it's bad:
Detection criteria:
- Classes with same purpose, different interface: Should Fix (50)
- Duplicate logic in differently-named methods: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Rename Method | Align method names to common interface |
| Move Method | Consolidate implementations |
| Extract Superclass | Share common behavior |
| Delete redundant class | After consolidation |
When to ignore: Classes in different libraries with independent versioning.
Issues that require changes in multiple places when a single change is needed.
Signs:
Why it's bad:
Detection criteria:
- Class changes for >2 unrelated reasons: Should Fix (50)
- Class has distinct "sections" of functionality: Should Fix (50)
- Methods naturally group into separate concerns: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Class | Separate each concern into its own class |
| Extract Superclass/Subclass | When classes share some behavior |
Signs:
Why it's bad:
Detection criteria:
- Feature addition touches 5+ classes: Must Fix (80)
- Single responsibility scattered across classes: Must Fix (80)
- "Overzealous" previous separation causing this: Must Fix (80)
Refactoring:
| Technique | When to Use |
|---|---|
| Move Method/Field | Consolidate scattered responsibility |
| Inline Class | After consolidation, remove empty shells |
Signs:
Why it's bad:
Detection criteria:
- Two hierarchies with matching structures: Should Fix (50)
- Adding to one requires adding to another: Should Fix (50)
- Prefixes like "XHandler/XFactory": Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Move Method/Field | Make one hierarchy reference the other |
| Eliminate redundant hierarchy | After consolidation |
When to ignore: If deduplication makes code uglier, keep the parallel structure.
Pointless and unneeded elements whose absence would make code cleaner.
Signs:
Why it's bad:
Detection criteria:
- Comment explains what code does (not why): Nitpick (20)
- Commented-out code: Should Fix (50)
- Comment contradicts code: Must Fix (80)
- TODOs without ticket references: Nitpick (20)
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Variable | Complex expression needs explanation |
| Extract Method | Use comment text as method name |
| Rename Method | Method name should make comment unnecessary |
| Introduce Assertion | Document required state |
When acceptable: Comments explaining WHY (design decisions, complex algorithms, non-obvious constraints).
Signs:
Why it's bad:
Detection criteria:
- Identical code blocks: Should Fix (50)
- Similar code blocks (>80% same): Should Fix (50)
- Copy-paste with minor modifications: Should Fix (50)
- Same algorithm implemented differently: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Extract Method | Within single class |
| Pull Up Method | In sibling subclasses |
| Form Template Method | Similar but not identical algorithms |
| Extract Superclass | Across unrelated classes |
| Extract Class | When hierarchy inappropriate |
| Consolidate Conditional Expression | Duplicate conditions |
Signs:
Why it's bad:
Detection criteria:
- Class with <3 methods: Nitpick (20)
- Class that just delegates to another: Nitpick (20)
- Subclass with minimal additions: Nitpick (20)
Refactoring:
| Technique | When to Use |
|---|---|
| Inline Class | Merge into another class |
| Collapse Hierarchy | Merge minimal subclass with parent |
When to ignore: Class represents future expansion point.
Signs:
Why it's bad:
Detection criteria:
- Class with only fields + accessors: Should Fix (50)
- No methods operating on own data: Should Fix (50)
- Other classes doing Feature Envy on this class: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Encapsulate Field | Make fields private |
| Encapsulate Collection | For collections |
| Move Method | Bring behavior from clients into class |
| Remove Setting Method | After class gains behavior |
| Hide Method | For overly permissive accessors |
Signs:
Why it's bad:
Detection criteria:
- Unused variable: Nitpick (20)
- Unused method/function: Should Fix (50)
- Unreachable code: Should Fix (50)
- Commented-out code: Should Fix (50)
- Unused class: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Delete | Remove unused code |
| Remove Parameter | Unused parameters |
| Inline Class/Collapse Hierarchy | Unused classes |
Signs:
Why it's bad:
Detection criteria:
- Unused abstraction: Nitpick (20)
- Parameter only used in tests: Nitpick (20)
- Abstract class with single implementation: Nitpick (20)
- Methods that only delegate: Nitpick (20)
Refactoring:
| Technique | When to Use |
|---|---|
| Collapse Hierarchy | Unnecessary abstract classes |
| Inline Class | Unnecessary delegation |
| Inline Method | Unused methods |
| Remove Parameter | Unused parameters |
When to ignore: Framework code where users may need the hooks.
Issues involving excessive coupling between classes or excessive delegation.
Signs:
Why it's bad:
Detection criteria:
- Method uses >3 getters from another object: Should Fix (50)
- Method primarily operates on another class's data: Should Fix (50)
- After data move, operations didn't follow: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Move Method | Move entire method to target class |
| Extract Method | Move only envious part |
When to ignore: Strategy/Visitor patterns intentionally separate behavior from data.
Signs:
Why it's bad:
Detection criteria:
- Classes accessing each other's private/protected: Must Fix (80)
- Bidirectional association: Should Fix (50)
- Deep knowledge of another class's internals: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Move Method/Field | Put code where data lives |
| Extract Class | Separate shared parts |
| Hide Delegate | Reduce direct knowledge |
| Change Bidirectional to Unidirectional | Simplify association |
| Replace Delegation with Inheritance | When intimacy is with subclass |
Signs:
a.b().c().d()Why it's bad:
Detection criteria:
- Chain of 3+ method calls: Should Fix (50)
- Chain navigation through multiple objects: Should Fix (50)
- "Train wreck" code: a.getB().getC().getD(): Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Hide Delegate | Shorten chain at each step |
| Extract Method + Move Method | Get what you need from chain start |
Caution: Overly aggressive hiding creates Middle Man smell.
Signs:
Why it's bad:
Detection criteria:
- Class where >50% methods just delegate: Should Fix (50)
- Class with only pass-through methods: Should Fix (50)
- Gradual functionality migration left empty shell: Should Fix (50)
Refactoring:
| Technique | When to Use |
|---|---|
| Remove Middle Man | Call delegate directly |
When to ignore:
Signs:
Why it's bad:
Detection criteria:
- Multiple workarounds for same library limitation: Should Fix (50)
- Helper functions for library functionality: Nitpick (20)
Refactoring:
| Technique | When to Use |
|---|---|
| Introduce Foreign Method | Add few methods |
| Introduce Local Extension | Add substantial functionality |
| Smell | Threshold | Severity |
|---|---|---|
| Long Method | >50 lines | Should Fix (50) |
| Long Method | >100 lines | Must Fix (80) |
| Large Class | >500 lines | Should Fix (50) |
| Large Class | >1000 lines | Must Fix (80) |
| Long Parameter List | >4 params | Should Fix (50) |
| Long Parameter List | >6 params | Must Fix (80) |
| Deep Nesting | >3 levels | Should Fix (50) |
| Deep Nesting | >5 levels | Must Fix (80) |
| Magic Numbers | Any unexplained literal | Should Fix (50) |
| Duplicate Code | >10 lines identical | Should Fix (50) |
| Feature Envy | >3 external getters | Should Fix (50) |
| Message Chain | >3 calls | Should Fix (50) |
| Shotgun Surgery | >5 classes touched | Must Fix (80) |
| God Class | Multiple responsibilities | Must Fix (80) |
| Scenario | Next Skill |
|---|---|
| Found smells during PR review | Continue pr-review with findings |
| Found smells, need refactoring | Invoke planning-refactor |
| Need to understand code first | Invoke exploration-explore-code |
| Ready to apply specific technique | Invoke refactoring-techniques for step-by-step guidance |
| Ready to fix Long Method | Use Extract Method from refactoring-techniques |
| Ready to fix Feature Envy | Use Move Method from refactoring-techniques |
Cross-Reference: This skill identifies WHAT to fix. The refactoring-techniques skill shows HOW to fix it with 60+ techniques and code examples.