single-responsibility_skill

This skill helps you apply the single-responsibility principle by guiding you to split classes and modules, reducing change coupling and maintenance.
  • TypeScript

6

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill yanko-belov/code-craft --skill single-responsibility

  • SKILL.md5.4 KB

Overview

This skill captures the Single Responsibility Principle (SRP) guidance for TypeScript code. It helps you decide when to split classes, modules, or functions so each has exactly one reason to change. Use it to avoid god classes and keep code maintainable and testable.

How this skill works

It inspects design intent and common symptoms: whether a class does multiple things, how many public methods it has, file size, and whether descriptions require "AND". It recommends concrete refactors: extract focused services, avoid adding unrelated methods, and document technical debt when immediate refactoring is impossible. It also gives scripts for resisting pressure to violate SRP.

When to use it

  • Creating a new class, module, or service
  • Adding methods to an existing class
  • Reviewing code that seems to do multiple things
  • When you feel pressure to "just add it here"
  • When a class has multiple reasons to change

Best practices

  • Describe the class in one sentence; if it includes "AND", split it
  • Never add functionality that introduces a second reason to change
  • Extract on touch: when modifying, pull related behavior into a new class
  • Create focused classes even under time or authority pressure and document concerns
  • Use specific names (Avoid vague Manager/Handler/Processor/Service without domain)

Example use cases

  • Refactoring a 500-line OrderService into OrderService, PaymentService, InventoryService, NotificationService
  • Adding email delivery: create NotificationService instead of tacking sendEmail onto UserManager
  • Code review: flag classes with >200 lines or >5–7 public methods for extraction
  • Implementing a new feature: add a new service rather than expanding an unrelated class
  • Handling disputes over design: use the provided script to push back and record decisions

FAQ

Create a focused class for the change—this is usually not slower—and avoid adding unrelated responsibilities to existing classes. If impossible, document the debt and create a ticket to refactor.

How do I start refactoring a god class safely?

Don’t make it worse. When you touch part of the class, extract that part into a new class or service and update callers gradually. Add tests and document remaining work.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational