Applies SOLID principles pragmatically to C# responsibilities, substitutability, consumer-focused interfaces, extension points, and dependency inversion. Use when design pressure is concrete; do not use as a mechanical checklist or for project-layer architecture (use clean-architecture).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Solid Principles?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/k4ndev-solid-principles)
---
name: solid-principles
description: Applies SOLID principles pragmatically to C# responsibilities, substitutability, consumer-focused interfaces, extension points, and dependency inversion. Use when design pressure is concrete; do not use as a mechanical checklist or for project-layer architecture (use clean-architecture).
---
# SOLID Principles
## Purpose
Use SOLID to explain and reduce demonstrated change amplification, behavioral surprises, or testing friction—not to score code against slogans.
## Scope
Class/module responsibilities, behavioral contracts, interfaces, extension points, and dependencies in C#.
## When to use
- The user asks whether a type has too many responsibilities, whether an interface is useful, or how to support real variants.
- A design has measurable coupling or substitutability problems.
## Do not use for
- Project-level dependency architecture: use `clean-architecture`.
- Pattern selection where a named composition mechanism may help: use `design-patterns`.
- Full guideline review: use `dotnet-code-review`.
## Required context
Identify consumers, implementations, behavior invariants, likely change sources, test boundaries, and the actual cost of current coupling. Method count alone is not evidence.
## Workflow
1. State the concrete change or failure pressure before naming a principle.
2. Map responsibilities to reasons to change (SRP); preserve stable behavior while adding likely variation (OCP).
3. Compare implementation behavior with the abstraction's preconditions/postconditions (LSP).
4. Check whether each consumer depends only on operations it uses (ISP).
5. Check whether policy depends on a stable abstraction rather than a volatile detail, and whether inversion pays for itself (DIP).
6. Recommend the smallest refactor, preserving public contracts and adding behavior tests for changed invariants.
## Decision rules
- Report a violation only with a concrete consequence such as unrelated release coupling, runtime contract breakage, unnecessary mock setup, or risky conditional growth.
- An interface is useful when it represents a consumer-owned boundary or multiple meaningful implementations—not merely for mocking.
- A class with many methods may still have one cohesive responsibility; a tiny class may still violate a behavioral contract.
## Expected output format
Name the principle only after explaining the evidence, propose a small before/after design, and state tests that protect the contract. Avoid principle-only criticism.
## Common mistakes
- “Too many lines” as proof of SRP failure, interface-per-class policies, hypothetical plugins, or violating OCP to avoid all conditionals.
- Using inheritance where composition or explicit variants are clearer.
## Edge cases
- Functional core/imperative shell and straightforward switch expressions can be simpler than a hierarchy.
- A sealed implementation may still need an interface if it is a meaningful architectural boundary; conversely tests alone do not mandate one.
- LSP concerns behavior, including exceptions and side effects, not only matching method signatures.
## Examples
See [SOLID examples](examples.md) for a consumer-focused strategy abstraction and an unjustified abstraction.
## Test scenarios
- Positive: “Adding payment providers keeps breaking the same checkout method; propose the smallest extensible seam.”
- Negative: “How do I use `DateOnly`?” routes to `csharp-best-practices`.
- Boundary: “Should repositories be in Infrastructure or Application?” routes to `clean-architecture`.
## Related skills
`clean-architecture`, `design-patterns`, `csharp-best-practices`, `testing-quality`, `dotnet-code-review`.