clean-code

Explains DRY, KISS, YAGNI principles and suggests refactoring techniques for Java code.

70|22|Updated Jun 10, 2020
One-click install
npx skills add https://github.com/piomin/spring-boot-istio --skill clean-code-piomin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/piomin/spring-boot-istio/tree/main/.claude/skills/clean-code
Command: npx skills add https://github.com/piomin/spring-boot-istio --skill clean-code-piomin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write cleaner, more readable, and maintainable code by applying established principles and identifying common code smells.

Core Features & Use Cases

  • Principle Guidance: Explains and demonstrates DRY, KISS, YAGNI principles.
  • Naming Conventions: Provides best practices for naming variables, methods, and classes.
  • Code Smell Detection: Identifies and suggests refactoring for common issues like long methods or magic numbers.
  • Refactoring Techniques: Offers quick reference for common refactoring patterns like Extract Method and Guard Clauses.
  • Use Case: A developer has a long, complex method and needs help simplifying it. They can ask the skill to refactor it using Extract Method and Guard Clauses.

Quick Start

Use the clean-code skill to refactor a method that is too long.

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 method in Java to improve code maintainability?

Refactor long Java methods by applying Extract Method and Guard Clauses techniques to reduce complexity and improve maintainability. This breaks down large code blocks into smaller, well-named functions that are easier to read and modify.

What do DRY, KISS, and YAGNI principles mean for clean code?

DRY, KISS, and YAGNI are clean code principles that improve maintainability by reducing duplication, keeping implementations simple, and avoiding unnecessary features. Applying these principles ensures software design stays focused and readable.

How do I identify and fix common code smells like magic numbers?

Identify code smells like magic numbers by locating unexplained raw values in logic, then fix them by extracting them into named constants. This refactoring technique replaces confusing literals with descriptive names to enhance code readability.

What are the best practices for naming variables and methods in Java?

Best practices for naming variables and methods in Java involve using descriptive, intention-revealing names that clearly express what the code does. Proper naming conventions eliminate the need for extra comments and make the codebase self-documenting.

When should I use Guard Clauses to reduce code complexity?

Use Guard Clauses to reduce code complexity when a method has deep nested conditional logic. By checking for invalid conditions early and returning immediately, you flatten the structure and make the main logic easier to follow.

Does this clean code guidance apply to languages other than Java?

While the practical application examples focus on Java, the underlying clean code principles like DRY and KISS apply universally to any programming language. Naming conventions and refactoring techniques are standard software design practices.