Skip to content
Back to skills

Solid Principles

ASecurity

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).

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsc#shellexpresstestingcode-review

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add k4ndev/claude-code-dotnet --skill solid-principles --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Solid Principles?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Solid Principles
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/k4ndev-solid-principles/badge)](https://www.skillsdirectory.com/skills/k4ndev-solid-principles)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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`.

Files in this skill

  • SKILL.md3.6 KB
  • examples.md1.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.