clean-code-ch03-functions

Enforce clean-code function practices including size limits and single responsibility.

4|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/hatlesswizard/clean-code-skills --skill clean-code-ch03-functions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-code-ch03-functions
Source: https://github.com/hatlesswizard/clean-code-skills/tree/main/ch03-functions
Command: npx skills add https://github.com/hatlesswizard/clean-code-skills --skill clean-code-ch03-functions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Functions often become bloated, hard to read, and difficult to maintain as codebases grow. This skill provides a practical, checklist-driven approach to enforce small size, single responsibility, proper abstraction, and other best practices from Clean Code Ch3.

Core Features & Use Cases

  • Size & SRP enforcement: checks for 20 lines or fewer and a single responsibility.
  • Abstraction & naming discipline: ensures consistent abstraction levels and descriptive names.
  • CQS & error handling patterns: guidance on command-query separation and exception-based error handling.
  • Code review & refactoring support: provides a repeatable process for code reviews and incremental improvements.
  • Use case: When reviewing a function in PRs, apply the checklist to decide if it is clean or needs refactoring.

Quick Start

Run the function-quality-checks tool on a target codebase and follow the on-screen checklist prompts.

Frequently Asked Questions about clean-code-ch03-functions

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

FAQPage Schema
How do I check if a function follows clean code best practices during a code review?

To check clean code best practices during code review, validate function size limits, single responsibility, abstraction levels, argument count, side effects, command-query separation, error handling, and DRY principles. Use a checklist-driven approach to enforce these rules incrementally.

What is the maximum number of lines a clean function should have?

A clean function should ideally be 20 lines or fewer. Keeping functions small ensures they remain readable, focused on a single responsibility, and easier to maintain as the codebase grows.

How do I refactor a large function that mixes multiple responsibilities?

Refactor large functions by enforcing single responsibility principle (SRP) and extracting blended logic into smaller, focused units. Apply abstraction level discipline, reduce argument count, eliminate side effects, and ensure command-query separation.

Can I use this clean code checklist for onboarding new developers?

Yes, you can use this clean code checklist for onboarding. It provides a repeatable process for evaluating function quality, helping new developers understand size limits, SRP, naming discipline, CQS, and error handling patterns through practical code reviews.

Why does my function cause unexpected side effects in my codebase?

Functions cause unexpected side effects when they violate command-query separation or blend responsibilities. Enforcing clean code principles like SRP, proper abstraction levels, and exception-based error handling prevents hidden state modifications and improves predictability.

What's the best way to enforce command-query separation and DRY in function refactoring?

The best way to enforce command-query separation and DRY during refactoring is applying a checklist that ensures functions either perform actions or return data, not both, while eliminating duplicated logic through extraction and consistent abstraction levels.