apply-design-principles
Skill7 starsChanged 16 days agoMITView on GitHub
Use when writing or reviewing class or module design — encapsulate what varies, program to an interface, favor composition over inheritance, keep class and type distinct, and obey the Law of Demeter and the Hollywood Principle.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/claude-skillsword for word, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 1
- VelimirMueller/claude-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
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 repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-fastapi-serviceSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- set-up-supabaseSkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-solidSkill
- choose-data-structureSkill
- debug-systematicallySkill
- enforce-dependency-ruleSkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- optimize-performanceSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- set-up-feature-flagsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
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 54
Every principle has a "when to break" line.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apply Design Principles
The durable object-oriented rules behind every pattern, as a review checklist. They are the "why" the patterns exist. Catalogue of the patterns themselves: patterns-catalogue.md.
The principles
- Encapsulate what varies. Identify the part that changes and isolate it behind a boundary; change to that part no longer ripples. Ask of every new module: what here will change, and is it fenced off.
- Program to an interface, not a concrete class. Depend on the behaviour you need, not the specific type that happens to provide it. A function that takes a shape instead of a class stays usable with any compatible shape.
- Favor composition over inheritance. Composition is black-box reuse (runtime, keeps encapsulation); inheritance is white-box reuse (compile-time, breaks encapsulation). Prefer "has-a" over "is-a"; reach for inheritance only for a genuine subtype relationship.
- Class ≠ type. A class is one implementation; a type is the interface it satisfies. Two classes can share a type without sharing code. Under structural typing any object with the compatible shape satisfies the interface — no subclass required.
- Principle of Least Knowledge (Law of Demeter). Talk only to immediate friends. A method should
call methods on its own object, its arguments, and objects it creates — never the friends of a friend
(
a.b.c.d()). This keeps coupling shallow and change local. - Hollywood Principle (Inversion of Control). "Don't call us, we'll call you." High-level policy calls the low-level detail, not the reverse. Let the framework/host drive; supply the hook.
- Open/Closed. Open for extension, closed for modification: add new behaviour by adding code, not by editing existing code, so the stable part stops accumulating churn.
- Dependency Inversion. Depend on abstractions, not concretions; high-level policy never depends on low-level details, both depend on abstractions. Details (DB, web, framework) point inward toward policy.
1. Audit (change nothing)
cat .claude/stack-profile.md 2>/dev/null | head -20
grep -rn "extends\|class.*extends\|a\.b\.c\." --include="*.ts" --include="*.rs" --include="*.go" --include="*.py" . 2>/dev/null | head -30Find the violation first: an inheritance chain that exists for reuse, a chain of method calls through three collaborators, a module that imports a concrete vendor type everywhere, a policy that imports a framework.
2. Apply the smallest fix
- A type that changes together → one module that owns it (encapsulate what varies).
- A parameter typed to a concrete class → type it to the interface/shape it uses.
- A subclass used only for reuse → a composed field or a function.
- A
a.b.c()chain → a method on the friend that owns the traversal.
3. State the exception
Every principle has a "when to break" line. Record why the violation is the honest choice (performance, the framework's own convention, a throwaway) instead of silently leaving it.
Verify
The change that used to touch many files now touches one; a second subclass was added without editing the base; the import of a vendor SDK is confined to one seam. State the trade-off in the review note.
When to deviate
- A tiny, stable, single-author codebase where a principle's ceremony outweighs its benefit.
- The language or framework idiom contradicts the classic form (structural typing, DI containers, composition-over-inheritance in Rust) — follow the idiom, keep the intent.
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.

