Code Smells
Identify and address 12 common code smells using a vocabulary derived from Martin Fowler's *Refactoring*, aiding in code quality reviews, pull request assessments, or determining if code is clean.
Editor's Note
Before applying the code smell review, ensure that the project's house standards (e.g., `CLAUDE.md`, `AGENTS.md`, lint config, or style guide) are followed. If a file is marked as 'small edits only,' treat any flagged smell as a note, not a reason for restructuring.
When to Use It
- Reviewing code quality in pull requests
- Assessing code cleanliness during code reviews
- Identifying potential refactoring opportunities
SKILL.md
SkillsHunter provides this listing for informational purposes only. Review the skill’s source, license, and required permissions before use. You are responsible for deciding whether to install or run it. Terms of Use
Code smells: 12 guide words for reviews
The smell names come from Martin Fowler's book Refactoring (chapter 3). The idea of a short
list for agent reviews comes from the code-review skill in
mattpocock/skills. This text is our own.
Name the smell in the finding, for example "possible Feature Envy at <file:line>", so every
agent and every model reports in the same words.
Three rules bind the list:
- The project overrides. A written house standard (your
CLAUDE.md,AGENTS.md, lint config or style guide) always wins. Where it endorses something this list would flag, do not report the smell. If the project marks a file as "small edits only", a smell there is a note, never a reason to restructure it. - Always a judgment call. A smell is a labelled heuristic, never a hard violation.
- Skip what tooling enforces (linters, type checkers, formatters, pre-commit hooks).
Each smell: what it is, then how to fix it.
- Mysterious Name: a name that hides what it does or holds. Fix: rename it. If no honest name comes, the design is murky.
- Duplicated Code: the same logic shape in more than one place. Fix: extract the shared shape and call it from both.
- Feature Envy: a method that reaches into another object's data more than its own. Fix: move the method onto the data it envies.
- Data Clumps: the same few fields or parameters that always travel together. Fix: bundle them into one type and pass that.
- Primitive Obsession: a raw string or number that stands in for a domain concept. Fix: give the concept its own small type.
- Repeated Switches: the same if/switch cascade on the same type in several places. Fix: one shared map, or polymorphism.
- Shotgun Surgery: one logical change forces scattered edits across many files. Fix: gather what changes together into one module.
- Divergent Change: one file edited for several unrelated reasons. Fix: split it so each module changes for one reason.
- Speculative Generality: abstraction, parameters or hooks for needs nobody has. Fix: delete it, and inline until a real need shows.
- Message Chains: long
a.b().c().d()walks the caller should not know about. Fix: hide the walk behind one method on the first object. - Middle Man: a layer that mostly passes calls on. Fix: cut it and call the real target directly.
- Refused Bequest: a subclass or implementer that ignores or overrides most of what it inherits. Fix: drop the inheritance and compose instead.
code-smells from DevDad's Toolbox. MIT. Adapted from mattpocock/skills.
View original Markdown
---
name: code-smells
description: A 12-smell review vocabulary, named warning signs from Fowler's Refactoring, each with its fix. Use when reviewing code quality, judging a diff or pull request, or asked whether code is clean.
metadata:
source: https://github.com/mattpocock/skills (code-review, the smell list)
license: MIT
pinned: "2026-11-28. Smell list adapted from mattpocock/skills code-review, after Fowler, Refactoring ch. 3. Wording is ours."
adapted_by: "DevTribe Labs, MIT. https://github.com/DevDadTribe/toolbox"
---
# Code smells: 12 guide words for reviews
*The smell names come from Martin Fowler's book* Refactoring *(chapter 3). The idea of a short
list for agent reviews comes from the `code-review` skill in
[mattpocock/skills](https://github.com/mattpocock/skills). This text is our own.*
Name the smell in the finding, for example "possible Feature Envy at `<file:line>`", so every
agent and every model reports in the same words.
Three rules bind the list:
1. **The project overrides.** A written house standard (your `CLAUDE.md`, `AGENTS.md`, lint
config or style guide) always wins. Where it endorses something this list would flag, do
not report the smell. If the project marks a file as "small edits only", a smell there is a
note, never a reason to restructure it.
2. **Always a judgment call.** A smell is a labelled heuristic, never a hard violation.
3. **Skip what tooling enforces** (linters, type checkers, formatters, pre-commit hooks).
Each smell: **what it is, then how to fix it**.
- **Mysterious Name**: a name that hides what it does or holds. Fix: rename it. If no honest name comes, the design is murky.
- **Duplicated Code**: the same logic shape in more than one place. Fix: extract the shared shape and call it from both.
- **Feature Envy**: a method that reaches into another object's data more than its own. Fix: move the method onto the data it envies.
- **Data Clumps**: the same few fields or parameters that always travel together. Fix: bundle them into one type and pass that.
- **Primitive Obsession**: a raw string or number that stands in for a domain concept. Fix: give the concept its own small type.
- **Repeated Switches**: the same if/switch cascade on the same type in several places. Fix: one shared map, or polymorphism.
- **Shotgun Surgery**: one logical change forces scattered edits across many files. Fix: gather what changes together into one module.
- **Divergent Change**: one file edited for several unrelated reasons. Fix: split it so each module changes for one reason.
- **Speculative Generality**: abstraction, parameters or hooks for needs nobody has. Fix: delete it, and inline until a real need shows.
- **Message Chains**: long `a.b().c().d()` walks the caller should not know about. Fix: hide the walk behind one method on the first object.
- **Middle Man**: a layer that mostly passes calls on. Fix: cut it and call the real target directly.
- **Refused Bequest**: a subclass or implementer that ignores or overrides most of what it inherits. Fix: drop the inheritance and compose instead.
---
*`code-smells` from [DevDad's Toolbox](https://github.com/DevDadTribe/toolbox). MIT. Adapted from mattpocock/skills.*
Community Reviews & Field Notes
Tried this skill on your own project? Share the model you used and the results you got.