single-responsibility-principle

Enforce single responsibility in classes, modules, and functions during creation or refactoring.

13|2|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/yanko-belov/code-craft --skill single-responsibility-principle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: single-responsibility-principle
Source: https://github.com/yanko-belov/code-craft/tree/main/skills/single-responsibility
Command: npx skills add https://github.com/yanko-belov/code-craft --skill single-responsibility-principle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SRP prevents god classes and tangled code by ensuring a module, class, or function has a single reason to change, improving maintainability and testability.

Core Features & Use Cases

  • Identify multi-responsibility components and extract focused services.
  • Guide refactoring to create smaller, cohesive units.
  • Improve testability and deployment safety by limiting scope.

Quick Start

  1. Identify a class or module that performs multiple responsibilities.
  2. Extract each responsibility into its own focused class or service.
  3. Update call sites and tests to reflect the new structure.

Frequently Asked Questions about single-responsibility-principle

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

FAQPage Schema
How do I refactor a god class that handles multiple responsibilities?

To refactor a god class handling multiple responsibilities, identify each distinct reason to change and extract those duties into focused, cohesive services or modules. This refactoring ensures components have a single responsibility, preventing tangled code.

What is the single responsibility principle in clean code?

The single responsibility principle in clean code ensures a module, class, or function has only one reason to change. This prevents god classes and tangled code, ultimately improving maintainability and testability across the software engineering lifecycle.

When should I apply SRP during software refactoring?

Apply SRP during software refactoring when creating or modifying a component that seems to perform multiple responsibilities. It sets boundaries and guidelines so changes impact only one reason to change, limiting scope and improving deployment safety.

What is the best way to identify multi-responsibility components for refactoring?

The best way to identify multi-responsibility components is to examine a class or module for multiple reasons it might need to change. Once identified, extract each responsibility into its own focused service to create smaller, cohesive units.

Does enforcing a single responsibility per class improve testability?

Enforcing a single responsibility per class directly improves testability by limiting the scope of each component. Smaller, cohesive units with a single reason to change are easier to isolate and test, preventing god classes and tangled code.