solid-principles
Skill7 starsChanged 3 months agoMITView on GitHub
SOLID object-oriented design principles for TypeScript projects. Use when designing or refactoring classes and modules, reviewing code for design smells (rigid, fragile, tightly coupled code), deciding how to split responsibilities or introduce abstractions, or answering "is this good OO design / which SOLID principle applies here" questions. Covers all five principles with idiomatic TypeScript before/after examples and guidance on when applying them helps and when it is over-engineering.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- decebals/claude-code-javatheir own version, first seen Nov 1, 2026
- TheBeardedBearSAS/claude-crafttheir own version, first seen Oct 29, 2026
- Khuirul-Huda/clean-principlestheir own version, first seen Oct 25, 2026
- andr-ca/agentharnesstheir own version, first seen Oct 15, 2026
- nek1987/auto-agent-harnesstheir own version, first seen Oct 11, 2026
- KhaledSaeed18/dotclaudetheir own version, first seen Jul 4, 2026
Used with
Projects with it also use design-patterns.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
ffsshhttiikkSkilldesign-patterns
Practical application and coding skills for Design Patterns
Also in 5 projects that use this
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- decebals/claude-code-java★ 763same name
- TheBeardedBearSAS/claude-craft★ 108same name
- JeremyMorgan/code-review-skills★ 15same name
- KhaledSaeed18/dotclaude★ 5same name
- nek1987/auto-agent-harness★ 4same name
- kayaman/skills★ 3same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- lucsedirae/agent_skill_library★ 2same name
- andr-ca/agentharness★ 1same name
- iCesofT/awesome-ai★ 1same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agent-teamsSkill
- bdd-specsSkill
- design-principlesSkill
- githubSkill
- gof-patternsSkill
- onboardSkill
- postgres-dbaSkill
- security-webSkill
- sqlite-devSkill
- typescript-best-practicesSkill
- user-storiesSkill
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Every rule below earns its keep only if it shrinks the next diff.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SOLID Principles in TypeScript
Five principles of object-oriented design (Robert C. Martin) that keep code flexible, testable, and resistant to rot — adapted to idiomatic TypeScript, where interfaces, structural typing, union types, and plain functions often satisfy a principle without ceremony.
🎯 Why: Design for Change
The goal of writing software is to be able to change it safely. SOLID is the OO toolkit for that goal: SRP limits what changes when a reason to change appears, OCP lets you extend without editing tested code, LSP keeps substitutions safe, ISP keeps consumers from breaking on unrelated changes, DIP lets you swap implementations without rewriting policy. Every rule below earns its keep only if it shrinks the next diff.
How to use this skill
- Match the symptom in the decision guide below to a principle.
- Open
references/principles.mdfor the full before/after TypeScript example and the "when this is over-engineering" note for that principle. - Apply the smallest change that removes the actual pain. SOLID is a response to demonstrated change pressure, not a checklist to apply preemptively. A 30-line app does not need an interface per class.
Reference file
references/principles.md— all five principles (SRP, OCP, LSP, ISP, DIP) with motivation, a bad example, a refactor, TypeScript-specific notes, and when not to apply each.
The five principles
| Letter | Principle | One-line intent |
| S | Single Responsibility | A class/module should have one reason to change. |
| O | Open/Closed | Open for extension, closed for modification. |
| L | Liskov Substitution | Subtypes must be usable wherever their base type is expected. |
| I | Interface Segregation | Many small client-specific interfaces beat one fat one. |
| D | Dependency Inversion | Depend on abstractions, not concretions. |
Decision guide — symptom → principle
| You notice… | Apply | Letter |
| A class changes for unrelated reasons (DB + formatting + business rules) | Single Responsibility | S |
Adding a new "type" means editing a growing switch/if-else | Open/Closed | O |
| A subclass throws on, no-ops, or weakens a method it inherited | Liskov Substitution | L |
| Implementers are forced to stub methods they don't use | Interface Segregation | I |
| Business logic imports a concrete DB/HTTP/SDK client directly | Dependency Inversion | D |
| Unit tests need a real database, network, or clock | Dependency Inversion | D |
| One change ripples across many unrelated files | Single Responsibility | S |
instanceof chains decide behavior | Open/Closed (often Strategy/polymorphism) | O |
TypeScript-specific guidance
- Interfaces are free and structural. You don't need a class to implement
an
interfaceexplicitly — any object with the right shape satisfies it. This makes ISP and DIP cheap. - Prefer narrow function types over fat interfaces. A dependency that is
"something that can
save(user)" can be(user: User) => Promise<void>, not aRepositoryinterface — that is ISP and DIP in one move. - Union types + exhaustive
switchis a valid OCP alternative. When the set of variants is closed and known, a discriminated union with anever-checked switch is often clearer than a class hierarchy. - Constructor injection is the default DIP mechanism. Pass collaborators
in; let a composition root wire concretions. Avoid
new-ing dependencies inside business logic. - Don't abstract on speculation. Introduce an interface when you have a second implementation or a real testing need — not "just in case."
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

