- Home
- Skills
- Code Quality & Review
- Code Review: 22 Code Smells
Code Review: 22 Code Smells
A standardized code review skill that diagnoses technical debt using Martin Fowler's 22 code smells.
Free
Works with the AI Agents you already use
Code Review: 22 Code Smells
Example session with this skill installed
Review this OrderService.process method. It handles database saving, email notifications, and has a 10-case switch statement for shipping logic.
- Read your context and instructions
- Compiled the code review
I have completed the structural diagnosis of OrderService.process. The method exhibits high divergent change and conditional complexity.
🔍 代码审查报告
一、 总体评价
代码实现了基础业务功能,但存在局部圈复杂度过高、职责未分离的坏味道,建议按以下方案分步重构。
二、 发现的坏味道与缺陷
-
【Major】3.5 Divergent Change (发散式变化)
- 位置:
OrderService.java第 12-45 行 - 问题:
OrderService既负责持久化逻辑,又处理邮件通知细节。当数据库架构或邮件模板改变时,该类都需要修改,违反了单一职责原则 (SRP)。 - 推荐手法: 采用
Extract Class (7.3)提炼出独立的NotificationService和OrderRepository。
- 位置:
-
【Major】3.10 Switch Statements (条件分支惊悚现身)
- 位置:
calculateShipping()内部 - 问题: 使用 10 路 switch 语句根据运输类型计算费用。每当增加新的快递商时,必须修改此逻辑,容易引发回归错误。
- 推荐手法: 采用
Replace Conditional with Polymorphism (9.6),将各运输逻辑抽象为策略子类。
- 位置:
-
【Minor】3.4 Long Parameter List (过长参数列)
- 位置:
saveOrder(id, name, addr, zip, city, country, phone, email) - 推荐手法: 采用
Introduce Parameter Object (10.9)引入ShippingAddress和CustomerContact对象。
- 位置:
Next steps
- Extract the database logic into a dedicated repository class.
- Apply the Strategy pattern to the shipping calculation switch statement.
- Group the address-related parameters into a single Data Transfer Object (DTO).
Connects securely to your tools. The creator never sees your data.
About this skill
Manual code reviews often miss deep structural flaws, focusing instead on surface-level syntax. This skill implements a systematic diagnosis workflow based on Martin Fowler's 22 code smells to identify technical debt before it merges.
What it does
- Code Smell Detection scans source code for the 22 specific "bad smells" defined in the Refactoring standard, including God Objects and Shotgun Surgery.
- Architectural Auditing evaluates adherence to Single Responsibility Principle (SRP), dependency health, and coupling issues like Feature Envy.
- Testability Assessment identifies hidden side effects and global states that make unit testing difficult or impossible.
- Structured Reporting generates categorized findings labeled by severity (Blocker, Major, Minor) with precise file and line references.
- Refactoring Strategy maps every identified flaw to a specific remediation pattern, such as Extract Class or Replace Conditional with Polymorphism.
How it works
- Input Phase accepts source code snippets or entire modules for quality evaluation.
- Diagnosis Phase executes a three-stage workflow covering code smells, design compliance, and severity grading.
- Synthesis Phase compiles findings into a standardized report template.
- Remediation Phase provides exact chapter-and-verse refactoring techniques for each detected issue.
Frameworks & tools
This skill is language-agnostic but optimized for object-oriented patterns in Java, C#, TypeScript, and Python. It follows the industry-standard methodologies established in Martin Fowler's "Refactoring: Improving the Design of Existing Code."
Why this beats prompting it yourself
Generic prompts often yield vague advice like "make this cleaner." This skill uses a formal checklist and a specific taxonomy of 22 smells, ensuring you get actionable, textbook-accurate refactoring patterns rather than subjective opinions.
Use cases
- Pre-Merge Audits to catch Divergent Change or Feature Envy before code hits the main branch.
- Legacy Debt Diagnosis to identify the best entry points for refactoring a large, messy class.
- Junior Mentorship by providing objective, standard-based feedback on pull requests.
- Complexity Analysis for flattening nested Switch Statements and Long Parameter Lists.
Known limitations
Does not perform runtime performance profiling or security vulnerability scanning. Focuses strictly on maintainability and structural design.
Does not perform runtime performance profiling or security vulnerability scanning. Focuses strictly on maintainability and structural design.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 13 days ago
- Free with an Agensi account