design-patterns
Skill1 starsChanged 2 months agoMITView on GitHub
Use when recognizing a recurring design problem. Covers GoF patterns: Factory, Builder, Strategy, Observer, Command, Template Method, Decorator, Repository, Facade — when to apply each and when not to.
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 30 edited versions we read keep these.
2
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 19
Create objects without knowing the concrete class.
- Distinctive: line 115
Add behavior to an object without modifying its class.
“Common” is measured: kept by at least 6 in 10 of the 30 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
Design Patterns (GoF Reference)
Patterns solve recurring design problems. Don't introduce a pattern to a problem that doesn't exist yet.
Creational — Object Creation
Factory Method
Create objects without knowing the concrete class.
class NotificationFactory:
@staticmethod
def create(channel: str) -> Notification:
match channel:
case "email": return EmailNotification()
case "sms": return SmsNotification()
case _: raise ValueError(f"Unknown channel: {channel}")Use when: the exact type to create is determined at runtime, or varies by environment.
Builder
Construct complex objects step by step, separating construction from representation.
const email = new EmailBuilder()
.to("alice@example.com")
.subject("Hello")
.body("World")
.build();Use when: constructors would have 4+ parameters, especially optional ones.
Behavioral — Object Communication
Strategy
Define a family of algorithms and make them interchangeable at runtime.
class Sorter:
def __init__(self, strategy: SortStrategy) -> None:
self._strategy = strategy
def sort(self, data: list) -> list:
return self._strategy.sort(data)Use when: you have multiple ways to do something and want to switch them. Replace if/elif chains.
Observer (Event / Pub-Sub)
One object notifies many dependents without knowing who they are.
class EventEmitter<T> {
private listeners = new Set<(event: T) => void>();
on(fn: (event: T) => void) { this.listeners.add(fn); }
emit(event: T) { this.listeners.forEach(fn => fn(event)); }
}Use when: one thing changing should trigger reactions in multiple places, without tight coupling.
Command
Encapsulate a request as an object to support undo, logging, or queuing.
@dataclass
class CreateOrderCommand:
user_id: str
items: list[OrderItem]
class CommandHandler:
def handle(self, cmd: CreateOrderCommand) -> Order: ...Use when: you need undo/redo, request queuing, audit trails, or to decouple request sender from executor.
Template Method
Define the skeleton of an algorithm; let subclasses fill in specific steps.
class DataProcessor(ABC):
def process(self, data): # template
raw = self.read(data)
parsed = self.parse(raw)
return self.write(parsed)
@abstractmethod
def read(self, data): ...
@abstractmethod
def write(self, data): ...Use when: multiple classes share an algorithm structure but differ in specific steps.
Structural — Object Composition
Decorator
Add behavior to an object without modifying its class.
class LoggingRepository:
def __init__(self, inner: UserRepository, logger: Logger) -> None:
self._inner = inner
self._logger = logger
def find(self, id: str) -> User:
self._logger.info(f"find {id}")
return self._inner.find(id)Use when: you need to add concerns (logging, caching, validation) without subclassing.
Repository
Abstract the data layer behind a domain-focused interface.
class UserRepository(Protocol):
def find_by_id(self, id: str) -> User | None: ...
def save(self, user: User) -> None: ...
def find_active(self) -> list[User]: ...Use when: domain logic should not know about SQL/ORM/HTTP details.
Facade
Provide a simple interface to a complex subsystem.
class PaymentFacade {
constructor(
private stripe: StripeClient,
private fraud: FraudDetector,
private audit: AuditLogger
) {}
async charge(user: User, amount: Money): Promise<Receipt> {
await this.fraud.check(user, amount);
const charge = await this.stripe.charge(user.card, amount);
await this.audit.log(charge);
return new Receipt(charge);
}
}Use when: a subsystem has many steps that callers shouldn't orchestrate directly.
Anti-Patterns to Avoid
| Anti-pattern | Instead |
| God object — one class does everything | Split by SRP |
| Singleton abuse — global mutable state | Inject dependencies |
| Premature abstraction — interface with one implementation | Wait until you have two |
| Inheritance for code reuse | Prefer composition (Strategy, Decorator) |
See Also
patterns/design-patterns/README.md— pattern directory entry.claude/skills/solid-principles/SKILL.md— principles that patterns implement.claude/skills/clean-architecture/SKILL.md— how patterns combine into architectures
Other versions31 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 31
- rtk-ai/rtk★ 85ksame name
- piomin/claude-ai-spring-boot★ 1.4ksame name
- decebals/claude-code-java★ 763same name
- waybarrios/opencode-power-pack★ 547same name
- FlorianBruniaux/ccboard★ 94same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- DIL8654/claude-code-dotnet-template★ 8same name
- tstapler/dotfiles★ 8same name
- cookieMonsterDev/agents-skills★ 7same name
- piomin/claude-ai-quarkus★ 7same name
21 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.
Used alongsideProjects with it also use logging-patterns, tdd-rust and 8 more.
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.
DIL8654Skilllogging-patterns
Keep logs structured, correlated, low-noise, and safe for production support. Use when adding operational logging, reviewing observability, or improving diagnostics in .NET services.
Also in 6 projects that use this
FlorianBruniauxSkilltdd-rust
Also in 3 projects that use this
mstuder-slalomSkilljpa-patterns
JPA/Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.
Also in 5 projects that use this
ufodev-ioSkillsecurity-guardian
Comprehensive security layer for all interactions with Claude: audits code, dependencies, commands, configs, and AI-generated output for vulnerabilities. Protects against prompt injection, data leaks, unsafe advice, and social engineering. Works in Cursor, Claude Code, claude.ai, and API contexts. Use always as a background security protocol in any Claude-powered environment.
Also in 3 projects that use this
tossSkillpr-triage
Classify and summarize a PR for efficient review
Also in 3 projects that use this
LangChainSkilltesting-patterns
Unit testing and integration testing best practices
Also in 3 projects that use this
In this repository77 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/accessibility.mdcCursor rule
- .cursor/rules/agentharness-router.mdcCursor rule
- .cursor/rules/agentic-loops.mdcCursor rule
- .cursor/rules/api-design.mdcCursor rule
- .cursor/rules/audit-review-followup.mdcCursor rule
- .cursor/rules/big-work-plan-review.mdcCursor rule
- .cursor/rules/branching.mdcCursor rule
- .cursor/rules/clean-architecture.mdcCursor rule
- .cursor/rules/code-review-api.mdcCursor rule
- .cursor/rules/code-review-db.mdcCursor rule
- .cursor/rules/code-review.mdcCursor rule
- .cursor/rules/code-review-ui.mdcCursor rule
- .cursor/rules/committing.mdcCursor rule
- .cursor/rules/database-conventions.mdcCursor rule
- .cursor/rules/dependency-audit.mdcCursor rule
- .cursor/rules/dependency-injection.mdcCursor rule
- .cursor/rules/design-patterns.mdcCursor rule
- .cursor/rules/docker-conventions.mdcCursor rule
- .cursor/rules/error-handling.mdcCursor rule
- .cursor/rules/file-placement-policy.mdcCursor rule
- .cursor/rules/github-issue-triage.mdcCursor rule
- .cursor/rules/go-conventions.mdcCursor rule
- .cursor/rules/harness-feedback.mdcCursor rule
- .cursor/rules/logging.mdcCursor rule
- .cursor/rules/multi-agent-coordination.mdcCursor rule
- .cursor/rules/mutation-testing.mdcCursor rule
- .cursor/rules/performance-profiling.mdcCursor rule
- .cursor/rules/planning-with-files.mdcCursor rule
- .cursor/rules/port-agent-config.mdcCursor rule
- .cursor/rules/project-bootstrap.mdcCursor rule
- .cursor/rules/python-conventions.mdcCursor rule
- .cursor/rules/react-best-practices.mdcCursor rule
- .cursor/rules/refactoring.mdcCursor rule
- .cursor/rules/requirements-clarification.mdcCursor rule
- .cursor/rules/security-review.mdcCursor rule
- .cursor/rules/solid-principles.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/typescript-conventions.mdcCursor rule
- accessibilitySkill
- agentic-loopsSkill
- api-designSkill
- audit-review-followupSkill
- big-work-plan-reviewSkill
- branchingSkill
- clean-architectureSkill
- code-review-apiSkill
- code-review-dbSkill
- code-reviewSkill
- code-review-uiSkill
- committingSkill
- database-conventionsSkill
- dependency-auditSkill
- dependency-injectionSkill
- docker-conventionsSkill
- error-handlingSkill
- file-placement-policySkill
- github-issue-triageSkill
- The first 60 shown.
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.

