clean-code

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

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/tayiorbeii/paperclip-factory-kit-hermes --skill clean-code-tayiorbeii
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-code
Source: https://github.com/tayiorbeii/paperclip-factory-kit-hermes/tree/main/skills/paperclip/clean-code
Command: npx skills add https://github.com/tayiorbeii/paperclip-factory-kit-hermes --skill clean-code-tayiorbeii

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Codebases accumulate unreadable functions, misleading names, inconsistent error handling, and missing tests, making every change slower and riskier. This Skill provides a disciplined framework for writing, reviewing, and refactoring code so it communicates intent clearly and welcomes change. ## Core Features & Use Cases - 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 code smell detection with targeted refactorings. - 0-10 Quality Scoring: Rates any code against the framework and lists the specific improvements needed to reach 10/10, making reviews objective and actionable. - Quick Diagnostic Checklist: Audits a codebase with ten yes/no questions covering function length, duplication, magic numbers, test coverage, and error handling separation. - Use Case: When reviewing a pull request with a 200-line function and cryptic variable names, apply the framework to score it, identify smells like flag arguments and feature envy, and produce a concrete refactoring plan with before/after patterns. ## Quick Start Review this pull request using the clean code framework, score it out of 10, and list the specific refactorings needed to reach 10/10.

Frequently Asked Questions about clean-code

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

FAQPage Schema
How do I review code for readability and maintainability?▼

Score the code 0-10 against six disciplines: meaningful names, small single-purpose functions, minimal comments, exception-based error handling, clean tests, and smell detection. Then list the specific gaps between the current score and 10/10 with targeted refactorings.

How to refactor long functions into smaller ones?▼

Apply the extract-till-you-drop technique: pull each identifiable step into a named function so the original reads as a top-down narrative. Replace flag arguments with separate functions, use guard clauses for early returns, and introduce parameter objects when argument counts exceed two.

What are common code smells and how do I fix them?▼

Common smells include duplication, long parameter lists, feature envy, dead code, magic numbers, and shotgun surgery. Each maps to a targeted refactoring: extract shared logic, introduce parameter objects, move methods to the data's class, delete dead code, and name constants.

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

Use exceptions rather than return codes so the happy path stays separate from error handling. Provide context in every exception message, never return or pass null, and apply the Special Case pattern such as empty collections or Optional instead of null returns.

When should I write comments in code?▼

Write comments only to explain why, never what; a comment explaining what code does signals the name or structure should improve instead. Legal headers, TODOs, and public API documentation are acceptable, while commented-out code and changelog comments should be deleted.

What are the limitations of clean code principles?▼

The principles are heuristics, not absolute rules, and mechanical application can over-fragment simple code. Premature refactoring without tests risks regressions, so write characterization tests first and refactor in small verified steps rather than alongside feature work.