Skip to content
Back to skills

Code Smell Detection

ASecurity

Scans a diff or folder for long methods, feature envy and god classes, and proposes the smallest change that removes each smell. It reports before editing.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
ai-agentsgorefactoringgit

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill code-smell-detection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Smell Detection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Smell Detection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-code-smell-detection/badge)](https://www.skillsdirectory.com/skills/workspace-templates-code-smell-detection)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-smell-detection
description: Scans a diff or folder for long methods, feature envy and god classes, and proposes the smallest change that removes each smell. It reports before editing.
---

# Code smell detection

Look at changed code first; scan the rest only if asked. Report evidence, not taste.

## Steps

1. Get the scope: `git diff main...HEAD --stat` for a branch, or the folder the user named. Read each changed file in full.
2. Check for these, with the threshold that makes each a finding:
   - Long method: over about 40 lines, or more than one level of abstraction in one body.
   - Feature envy: a method that reads another object's fields more than its own.
   - God class: many unrelated fields and methods, or a name ending in Manager or Helper that everything depends on.
   - Long parameter list: more than four, or booleans that switch behavior.
   - Shotgun surgery: one change forcing edits in many files.
   - Primitive obsession: the same string or number pair passed around with rules attached.
3. For every finding, locate the exact lines and pick the smallest fix: extract method, move method, introduce parameter object, replace flag with two functions.
4. Rank by how often the code changes (use `git log --oneline -- <file>` to count). A smell in cold code is low priority.
5. Do not edit. Present the list and ask which items to apply. Apply only the ones approved, one at a time, running tests after each.

## Rules

- Never propose a smell without a line reference.
- Do not flag style, naming or formatting.
- Behavior stays identical; if tests are missing, say so before refactoring.

## Report

A ranked list: location, smell, why it hurts here, smallest fix, estimated risk (low, medium, high).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.