clean-code

Review and refactor code using naming, function, error handling, and testing principles.

Updated Jun 27, 2026
One-click install
npx skills add https://github.com/rachmadideni/ai-staff-assistant --skill clean-code-rachmadideni
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/rachmadideni/ai-staff-assistant/tree/main/.agents/skills/clean-code
Command: npx skills add https://github.com/rachmadideni/ai-staff-assistant --skill clean-code-rachmadideni

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Code that is hard to read, test, and maintain slows every future change. This Skill provides a disciplined framework for diagnosing readability problems, scoring code quality, and applying targeted fixes for naming, function structure, comments, error handling, and tests. ## Core Features & Use Cases - Code Quality Scoring: Rate any code 0-10 against six clean code disciplines and get specific improvements needed to reach 10/10. - Six Discipline Framework: Covers meaningful naming, small single-purpose functions, comment and formatting discipline, exception-based error handling, clean unit testing (TDD, F.I.R.S.T.), and a code smell catalog with targeted refactorings. - Diagnostic Checklists: Quick diagnostic tables and common-mistake mappings turn vague "cleanup" requests into concrete refactoring actions. - Use Case: When reviewing a pull request with a 200-line function full of flag arguments and magic numbers, use this Skill to identify each smell, score the code, and produce a step-by-step refactoring plan with before/after examples. ## Quick Start Review this function for clean code issues and suggest specific refactorings to improve its readability and testability.

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 function into smaller ones?▼

Apply the extract-till-you-drop technique: pull each identifiable step into its own named function so the original reads as a sequence of calls. Follow the step-down rule so code reads top-down from high-level logic to low-level details, and keep functions under roughly 20 lines with zero to two arguments.

What are the most common code smells to look for in a code review?▼

The highest-impact smells are duplication, functions with too many or flag arguments, misleading or abbreviated names, magic numbers, dead code, and feature envy. Each smell maps to a targeted refactoring such as extracting shared logic, splitting flag-based functions, or moving methods to the class that owns the data.

Should I use exceptions or return codes for error handling?▼

Use exceptions rather than return codes, because return codes force callers to check immediately and clutter the happy path. Provide context in every exception, avoid returning or passing null, and wrap third-party APIs so callers handle one exception type defined by their needs.

When should I write comments in my code?▼

Write comments only to explain why a decision was made, never what the code does. Acceptable comments include legal headers, TODOs with ticket references, warnings of consequences, and explanations of non-obvious constraints; delete redundant, obsolete, and commented-out code since version control preserves history.

What makes a unit test clean and maintainable?▼

Clean tests follow the F.I.R.S.T. principles: Fast, Independent, Repeatable, Self-validating, and Timely. Each test covers one concept using Arrange-Act-Assert structure, has a descriptive name like shouldRejectExpiredToken, and uses builder helpers so the test reads like a specification.