Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

solid-principles

/solid-principles

Stosuje zasady SOLID (SRP, OCP, LSP, ISP, DIP) w taktycznym projektowaniu klas, wydzielaniu metod i definiowaniu interfejsów, przy przeglądzie klas i refaktoryzacji dla łatwiejszego utrzymania.

Repozytorium
tekhne ↗
Licencja
MIT
Ostatnia zmiana repozytorium
21.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
32
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
2
Przestarzałość

Brak sygnałów. Repozytorium zmienione 21.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Stosuje zasady SOLID (SRP, OCP, LSP, ISP, DIP) w taktycznym projektowaniu klas, wydzielaniu metod i definiowaniu interfejsów, przy przeglądzie klas i refaktoryzacji dla łatwiejszego utrzymania.

Oryginalny opis (EN)

Apply SOLID principles (SRP, OCP, LSP, ISP, DIP) for tactical class design, method extraction, and interface definition. Use when reviewing class design, refactoring code for maintainability, or designing interfaces and abstractions.

Jak działa

  1. When to Use
  2. When Not to Use
  3. SOLID Checklist
  4. Workflow
  5. Quick Commands
  6. Anti-Patterns
  7. References
Sekcje z nagłówków SKILL.md, w oryginale · 170 linii, 952 słów
Podgląd SKILL.md
---
name: solid-principles
description: Apply SOLID principles (SRP, OCP, LSP, ISP, DIP) for tactical class design, method extraction, and interface definition. Use when reviewing class design, refactoring code for maintainability, or designing interfaces and abstractions.
---

# SOLID Principles

Tactical design principles for class-level decisions, interface design, and dependency management.

## When to Use

- Reviewing class design for single responsibility violations
- Evaluating interface design and client dependencies
- Refactoring code with tight coupling or poor testability
- Designing new classes, methods, or abstractions
- Assessing whether to extend or modify existing code

## When Not to Use

- Architectural decisions about service boundaries or module structure (use clean-architecture)
- Choosing structural design patterns (use design-patterns)
- Configuring testing strategies (use testable-design)

## SOLID Checklist

Apply during code review or design:

| Principle | Check | Refactor Signal |
| --- | --- | --- |
| **SRP** | Does this class have one reason to change? | Multiple concerns → split into focused classes |
| **OCP** | Can you extend behavior without modifying existing code? | Adding features requires editing stable code → use abstraction |
| **LSP** | Do subtypes preserve base behavior contracts? | Subtype breaks parent assumptions → redesign hierarchy |
| **ISP** | Do clients depend only on methods they use? | Clients ignore many interface methods → split interface |
| **DIP** | Do you depend on abstractions, not concrete details? | Direct concrete coupling → introduce interface/port |

## Workflow

### Step 1: Identify SRP Violations

**Output:** List of classes with multiple reasons to change.

Ask for each class:

- Does it handle more than one concern (e.g., business logic + persistence + notifications)?
- Would changes to different features require editing this class?

**Example:**

```text
SRP violation: UserService handles auth, persistence, and notifications.
Refactor: Extract NotificationService and PersistenceGateway.
Validation: Each class now has one reason to change.
```

### Step 2: Check Open-Closed Compliance

**Output:** List of areas where new features require modifying stable code.

Ask:

- Do new features require editing existing code?
- Could abstraction/polymorphism eliminate the modification?

**Example:**

```text
OCP violation: Adding payment processor requires editing PaymentService.
Refactor: Extract PaymentProcessor interface + implementations.
Validation: New processors added without touching existing code.
```

### Step 3: Validate Liskov Substitution

**Output:** Subtypes that break base type contracts.

Check:

- Do subtypes strengthen preconditions or weaken postconditions?
- Do clients need to check types before using them?

**Example:**

```text
LSP violation: CachedRepository.save() throws exception when cache is full.
Refactor: Base Repository contract promises no exceptions; use Result type instead.
```

### Step 4: Segregate Interfaces

**Output:** Interfaces split by client needs.

Check:

- Do clients depend on methods they never call?
- Are there multiple unrelated method groups in one interface?

**Example:**

```text
ISP violation: IUserRepository has save(), find(), and sendNotification().
Refactor: Split into IUserRepository and INotificationService.
```

### Step 5: Invert Dependencies

**Output:** Abstractions introduced at module boundaries.

Check:

- Do high-level modules depend on low-level modules?
- Are concrete types instantiated in business logic?

**Example:**

```text
DIP violation: OrderService instantiates PostgresRepository.
Refactor: OrderService depends on IOrderRepository interface.
Injection: Container provides PostgresRepository implementation.
```

## Quick Commands

```bash
# Find SRP violations (multiple concerns)
rg -n "class.*Service.*Repository|class.*Manager.*Handler" src
```

```bash
# Find OCP violations (type checks)
rg -n "instanceof|typeof.*==|switch.*type" src
```

```bash
# Find DIP violations (concrete instantiation)
rg -n "new [A-Z].*Repository\(|new [A-Z].*Service\(" src
```

## Anti-Patterns

### NEVER apply SOLID as a mechanical checklist to every class

- **WHY**: SOLID principles are design guidelines, not mandates; applying them without judgment creates unnecessary abstraction layers and over-engineered code in simple domains where change pressure does not exist.
- **BAD**: Extract an interface for every class because "you should always program to interfaces" (misapplied DIP), resulting in one-implementation interfaces that add indirection with no benefit.
- **GOOD**: Apply SOLID principles where the design is causing pain — tight coupling, frequent change in one direction, difficulty testing — not as a universal rule regardless of context.

### NEVER create God Classes to avoid "too many files"

- **WHY**: Condensing multiple responsibilities into one class saves file count but creates high coupling, low cohesion, and fragile code where unrelated changes break each other.
- **BAD**: A `UserManager` class that handles authentication, profile editing, email notifications, and audit logging — violating SRP by having four distinct reasons to change.
- **GOOD**: Split into `AuthService`, `UserProfileService`, `NotificationService`, and `AuditLog` with clear single responsibilities and independent change trajectories.

### NEVER confuse ISP with "one method per interface"

- **WHY**: The Interface Segregation Principle says clients should not depend on methods they do not use; it does not mean every interface must have exactly one method, which leads to over-granularization and interface explosion.
- **BAD**: Creating dozens of single-method interfaces for every operation (`ICanSave`, `ICanFind`, `ICanDelete`) that are always implemented and injected together.
- **GOOD**: Group cohesive method sets into role-specific interfaces that represent a single role or behavior contract used by a specific type of client.

### NEVER use deep inheritance to satisfy OCP when composition achieves the same result

- **WHY**: Deep inheritance hierarchies are fragile; subclass changes ripple up the chain, LSP violations are common, and the Open/Closed Principle is better achieved through composition and dependency injection.
- **BAD**: `class PremiumUser extends AuthenticatedUser extends User extends BaseUser` to add behavior, creating a four-level hierarchy where changing any layer risks breaking all subclasses.
- **GOOD**: Inject behavior through composition: `new User(new PremiumFeatureSet())` — open for extension by adding new feature sets, closed for modification of the `User` class itself.

## References

| Topic | Reference | When to Use |
| --- | --- | --- |
| Step-by-step review questions, output format and candidate searches | [references/review-checklist.md](references/review-checklist.md) | Running a full SOLID review |

SOLID principles are tactical class-level design rules. For architectural decisions (boundaries, modules, dependencies), use the clean-architecture skill.

- [Martin Fowler on SOLID](https://martinfowler.com/bliki/BeckDesignRules.html)
- [Uncle Bob SOLID Papers](https://fi.ort.edu.uy/innovaportal/file/2032/1/design_principles.pdf)
Pliki w paczce (32)
  • SKILL.md 7 KB
  • .audits/latest 1 KB
  • .audits/2026-03-04/analysis.md 1 KB
  • .audits/2026-03-04/audit.json 1 KB
  • .audits/2026-03-04/remediation-plan.md 3 KB
  • .audits/2026-10-02/Analysis.md 1 KB
  • .audits/2026-10-02/Remediation.md 2 KB
  • .audits/2026-10-02/audit.json 1 KB
  • evals/instructions.json 3 KB
  • evals/summary.json 1 KB
  • evals/scenario-1/capability.txt 1 KB
  • evals/scenario-1/criteria.json 2 KB
  • evals/scenario-1/task.md 1 KB
  • evals/scenario-2/capability.txt 1 KB
  • evals/scenario-2/criteria.json 3 KB
  • evals/scenario-2/task.md 1 KB
  • evals/scenario-3/capability.txt 1 KB
  • evals/scenario-3/criteria.json 3 KB
  • evals/scenario-3/task.md 1 KB
  • evals/scenario-4/capability.txt 1 KB
  • evals/scenario-4/criteria.json 3 KB
  • evals/scenario-4/task.md 1 KB
  • evals/scenario-5/capability.txt 1 KB
  • evals/scenario-5/criteria.json 3 KB
  • evals/scenario-5/task.md 1 KB
  • evals/scenario-6/capability.txt 1 KB
  • evals/scenario-6/criteria.json 2 KB
  • evals/scenario-6/task.md 1 KB
  • evals/scenario-7/capability.txt 1 KB
  • evals/scenario-7/criteria.json 2 KB
  • evals/scenario-7/task.md 1 KB
  • references/review-checklist.md 2 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · pantheon-org/tekhne100MIT
claude-dev-suite/claude-dev-suite100MIT
florianbuetow/claude-code100MIT
jeremymorgan/code-review-skills100CC0-1.0
decebals/claude-code-java95MIT
khaledsaeed18/dotclaude90MIT
joeblackwaslike/agent-skills87MIT

Migawka bazy z 13.11.2026 · wersja paczki 00191e31584c (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90SOLID Principles Code Review
    Przegląda kod Pythona pod kątem zasad SOLID (SRP, OCP, LSP, ISP, DIP) w kontekście utrzymywalności, testowalności i jakości projektu.
  • 100solid-review
    Przegląda plik, katalog lub glob pod kątem zasad SOLID, bez zmian w kodzie, i zwraca raport projektowy.
  • 90solid
    Przegląda kod pod kątem zasad SOLID: rozróżnia realne problemy projektu od gustu, cytuje je i ocenia wagę.
  • 100clean-code-principles
    Omawia zasady SOLID, wzorce projektowe, DRY i KISS przy przeglądzie architektury, ocenie jakości kodu i refaktoryzacji.
  • 100solid
    Opisuje zasady SOLID w projektowaniu obiektowym, z wykrywaniem naruszeń, poprawkami i kompromisami dla każdej zasady, przy przeglądzie projektu klas, zmniejszaniu sprzężeń i poprawie rozszerzalności.
  • 100solid
    Stosuje i ocenia zasady SOLID w projektowaniu obiektowym (pojedyncza odpowiedzialność, otwarte-zamknięte, podstawienie Liskov, segregacja interfejsów, odwrócenie zależności), przy projektowaniu klas i interfejsów oraz redukcji sprzężeń.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.