apply-design-patterns
Skill7 starsChanged 15 days agoMITView on GitHub
Use when a design smells — a switch over type, inheritance chosen for configuration, scattered coupling — or a review asks whether a GoF pattern fits. Maps the smell to a pattern, picks the simplest fit, and adapts it to the language's idiom.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/claude-skillsword for word, first seen Nov 1, 2026
- bernard-ng/skillstheir own version, first seen Oct 11, 2026
Other versions2 projects use a version of this.
Word for word · 1
- VelimirMueller/claude-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 1
- bernard-ng/skills★ 4same name
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-principlesSkill
- 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 22
Every smell maps to a *what varies* in patterns-catalogue.md.
≈ “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 Patterns
Turns a design smell into the smallest GoF pattern that removes it, adapted to the stack's idiom. Catalogue, what-varies table and the when-to-use guard: patterns-catalogue.md. Principles behind the choice: engineering-principles.md.
1. Audit (change nothing)
cat .claude/stack-profile.md 2>/dev/null | head -40
grep -rn "switch\|if.*type\|instanceof\|typeof" --include="*.ts" --include="*.rs" --include="*.go" --include="*.py" . 2>/dev/null | head -30Name the smell precisely: a conditional over a type discriminator (→ Strategy/State), a class hierarchy that exists only to vary configuration (→ composition or Bridge), a change that ripples across many files (→ Facade/Mediator), a new-object family (→ Abstract Factory), a one-to-many notification (→ Observer). Every smell maps to a what varies in patterns-catalogue.md.
2. Decide
| Signal | Move |
| The variation is a future maybe, one caller today | Stop: no pattern. A plain function or union. |
| A switch over a closed set of kinds | Discriminated union + one function per kind (Strategy/State in idiom). |
| Two axes vary independently | Bridge, only if both axes are real. |
| A third-party or legacy interface must fit | Adapter as one wrapper function. |
| An object has many optional parts | Builder as a fluent/options object. |
| Undo or audit history is required | Command (+ Memento snapshots for undo). |
3. Apply the idiom
Translate the classic class diagram into the stack's idiom — the GoF book predates first-class functions, generators, structural typing and discriminated unions:
- Strategy = a function type or
Record<Kind, (x) => y>, never an interface + class tree. - Observer = state + effects + TanStack Query, or
useSyncExternalStore; never a subject/observer class. - Iterator = a generator or
[Symbol.iterator]; never a hand-rolled cursor class. - Singleton = a module-level
const; a lazy class factory only when init cost is real. - Adapter/Facade/Proxy = a structural interface plus one wrapper function, not a hierarchy.
- Decorator = a function/HOC for runtime wrapping;
@decorators for metadata only. - Command = closures/thunks or
{type, payload}actions; add{execute, undo}only for real undo.
4. Name the trade-off
State what the pattern buys and what it costs (one extra indirection, one new file, a perf hop) before applying. If the cost exceeds the flexibility gained, leave the simpler version and record the decision.
Verify
The smell is gone: the conditional over the discriminator is a lookup, the change that used to touch N
files touches one, and the new indirection is justified by a second caller or a measured need. A second
pass finds no leftover instanceof/typeof switch that the pattern was meant to replace.
When to deviate
- Throwaway or prototype code: skip the pattern entirely.
- A pattern already exists in the codebase: reuse it, do not add a second spelling of the same idea.
- The framework owns the mechanism (routing, state, DI): use the framework's form, not a hand-built one.
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.

