clean-code

Reviews Java code for Clean Code violations and suggests refactoring techniques.

Updated Apr 20, 2020
One-click install
npx skills add https://github.com/UnterrainerInformatik/java-rdb-utils --skill clean-code-unterrainerinformatik
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/UnterrainerInformatik/java-rdb-utils/tree/main/.agents/skills/clean-code
Command: npx skills add https://github.com/UnterrainerInformatik/java-rdb-utils --skill clean-code-unterrainerinformatik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate unreadable methods, duplicated logic, and unclear naming that slow down maintenance and increase bug risk. This Skill applies Clean Code principles to identify code smells and produce concrete refactoring suggestions with Java examples. ## Core Features & Use Cases - Principle Enforcement: Detects violations of DRY, KISS, and YAGNI with before/after Java code examples. - Naming & Function Design: Reviews variable, method, and class naming conventions plus function size, parameter count, and abstraction levels. - Code Smell Detection & Refactoring: Identifies long methods, magic numbers, primitive obsession, and god classes, then maps each smell to a refactoring technique such as Extract Method or Guard Clauses. - Use Case: A developer pastes a 100-line method and asks to refactor it; the Skill flags mixed abstraction levels and duplicated validation, then proposes Extract Method and a parameter object. ## Quick Start Ask the assistant to review your Java method for Clean Code violations and suggest refactorings to improve readability.

Frequently Asked Questions about clean-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a long Java method?▼

Break a long method into small, focused methods using the Extract Method technique, keeping each at a single level of abstraction. Guard clauses can replace deeply nested conditionals, and methods over roughly 20 lines are a common signal to split.

What are the most common Java code smells?▼

Common code smells include long methods, long parameter lists, duplicated code, magic numbers, god classes, feature envy, and primitive obsession. Each maps to a refactoring such as Extract Method, Parameter Object, or introducing value objects.

How should I name variables and methods in Java?▼

Use camelCase nouns for variables, verb-plus-noun names for methods like calculateTotal, and is/has/can prefixes for booleans. Classes use PascalCase nouns, constants use UPPER_SNAKE_CASE, and vague names like Data, Manager, or Helper should be avoided.

When is code duplication acceptable under DRY?▼

Duplication is acceptable when similar-looking code serves different purposes and will evolve independently, such as shipping cost versus insurance cost calculations. Forcing premature abstraction for coincidental similarity creates worse coupling than the duplication itself.

What are the limitations of applying YAGNI strictly?▼

Strict YAGNI means building only methods and interfaces currently needed, avoiding configurable options and abstract layers for hypothetical futures. The tradeoff is that genuinely anticipated requirements may require later refactoring, so judgment is needed for stable, well-understood domains.