clean-code

Applies Robert C. Martin's Clean Code principles to write, review, and refactor source code.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/balajirags/aifsd-kit --skill clean-code-balajirags
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/balajirags/aifsd-kit/tree/main/docs/skills/clean-code
Command: npx skills add https://github.com/balajirags/aifsd-kit --skill clean-code-balajirags

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code that merely works often becomes hard to read, maintain, and extend over time. This Skill provides a structured set of Clean Code principles and heuristics so developers can systematically turn working code into readable, maintainable code. ## Core Features & Use Cases - Naming, Function, and Class Guidelines: Enforces intention-revealing names, small single-purpose functions, and single-responsibility classes. - Code Smell Detection: Identifies rigidity, fragility, immobility, and needless complexity during reviews and refactoring. - Testing and Error Handling Standards: Applies the Three Laws of TDD, F.I.R.S.T. test principles, and exception-based error handling. - Use Case: While reviewing a pull request, use this Skill to give principle-based feedback on long functions, unclear names, and missing unit tests instead of vague style comments. ## Quick Start Review the attached module using Clean Code principles and list every code smell with a suggested refactoring.

Frequently Asked Questions about clean-code

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

FAQPage Schema
How do I refactor legacy code using Clean Code principles?

Start by identifying code smells such as long functions, unclear names, and duplicated logic. Then apply small, safe refactorings: extract functions that do one thing, rename variables to reveal intent, and add unit tests before changing behavior.

How to give better feedback in code reviews?

Base feedback on concrete principles rather than personal taste: flag functions doing more than one thing, non-searchable names, hidden side effects, and missing tests. Citing a principle like SRP or the Law of Demeter makes feedback objective and actionable.

What are the rules for writing clean functions?

Functions should be small, do exactly one thing, and operate at a single level of abstraction. Keep arguments to zero or one where possible, avoid side effects on global state, and use descriptive verb-based names like postPayment.

When should I write comments in code?

Prefer expressing intent in code over comments; most comments signal unclear code. Reserve comments for legal notices, clarifying external library behavior, explaining regex intent, and TODOs, and avoid redundant or misleading commentary.

What are the limitations of Clean Code principles?

These principles are guidelines, not substitutes for environment-specific validation, testing, or expert review. Rules like maximum function length or argument counts require judgment, and strict application may not fit every codebase or performance constraint.