design-patterns
Skill0 starsChanged 29 days agoMITView on GitHub
Use when solving recurring structural or behavioral design problems — recognizing when code needs a proven pattern like factory, observer, strategy, or repository.
33 other projects use a version of this.
Adopted by
Most recently taken up by
- thistleknot/skillstheir own version, first seen Nov 8, 2026
- gustaferiksson/skillstheir own version, first seen Nov 7, 2026
- alexandrecsp/skillstheir own version, first seen Nov 1, 2026
- cookieMonsterDev/agents-skillstheir own version, first seen Nov 1, 2026
- decebals/claude-code-javatheir own version, first seen Nov 1, 2026
- ralvarez-ai/ralvaskillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use logging-patterns, tdd-rust and 9 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 7 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 6 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
DIL8654Skillapi-contract-review
Review ASP.NET Core Web API contracts for HTTP semantics, versioning, backward compatibility, and response consistency. Use when the user asks to review an API, check endpoints, validate REST behavior, or before releasing contract changes.
Also in 3 projects that use this
zavierSkilljava-code-review
Java代码审查技能,通过比较两个git分支进行自动化代码审查
Also in 3 projects that use this
Other versions33 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 33
- rtk-ai/rtk★ 86ksame 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
23 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 repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/clean-principles.mdcCursor rule
- architecture-principlesSkill
- clarify-before-buildSkill
- clean-codeSkill
- dry-kiss-yagniSkill
- solid-principlesSkill
- testing-principlesSkill
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 32 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 85
Problem: Add behavior without modifying the original class.
“Common” is measured: kept by at least 6 in 10 of the 32 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
Proven solutions to recurring design problems. Use patterns when you recognize the problem — not to show cleverness.
Warning: Patterns add complexity. Only apply when the problem is actually recurring.
Creational — How Objects Are Created
Factory Method
Problem: Caller shouldn't know which concrete class to instantiate.
# Instead of: notification = EmailNotification(msg)
# Use: notification = NotificationFactory.create("email", msg)
class NotificationFactory:
_registry = {"email": EmailNotification, "sms": SMSNotification}
@classmethod
def create(cls, type: str, message: str) -> Notification:
if type not in cls._registry:
raise ValueError(f"Unknown notification type: {type}")
return cls._registry[type](message)Builder
Problem: Object needs many optional parameters (telescoping constructor).
# Instead of: Query(table, cols, where, limit, offset, order, joins)
query = (QueryBuilder("users")
.select("id", "name")
.where("active = true")
.limit(10)
.build())Singleton
Problem: Exactly one instance needed (config, connection pool).
class Config:
_instance = None
def __new__(cls):
if not cls._instance:
cls._instance = super().__new__(cls)
return cls._instance⚠️ The naive implementation above is NOT thread-safe. Use a lock in multi-threaded environments:
import threading
class Config:
_instance = None
_lock = threading.Lock()
def __new__(cls):
with cls._lock:
if not cls._instance:
cls._instance = super().__new__(cls)
return cls._instance⚠️ Avoid for anything testable — singletons make tests order-dependent.
Structural — How Objects Are Composed
Adapter
Problem: Make an incompatible interface work with existing code.
# Legacy system returns dict, new system expects object
class LegacyUserAdapter:
def __init__(self, legacy_dict: dict):
self._data = legacy_dict
@property
def id(self): return self._data["user_id"]
@property
def name(self): return self._data["full_name"]Decorator
Problem: Add behavior without modifying the original class.
class LoggingRepository:
def __init__(self, repo: UserRepository):
self._repo = repo
def find(self, id: int) -> User:
logger.info(f"Finding user {id}")
result = self._repo.find(id)
logger.info(f"Found: {result}")
return resultRepository
Problem: Decouple business logic from data access.
class UserRepository(ABC):
@abstractmethod
def find_by_id(self, id: int) -> User: ...
@abstractmethod
def save(self, user: User) -> None: ...
class SQLUserRepository(UserRepository):
def find_by_id(self, id: int) -> User:
row = self.db.query("SELECT * FROM users WHERE id = ?", id)
return User.from_row(row)Facade
Problem: Callers must coordinate a complex subsystem — simplify behind one interface.
class PaymentFacade:
def charge(self, amount: float, card: Card) -> Receipt:
self.fraud_detector.check(card) # complex internals
receipt = self.stripe.charge(amount, card)
self.audit_logger.log(receipt)
return receipt
# Caller only knows: facade.charge(amount, card)Proxy
Problem: Control access to an object — add caching, auth, or lazy loading transparently.
class CachedUserRepository:
def __init__(self, repo: UserRepository, cache: Cache):
self._repo, self._cache = repo, cache
def find_by_id(self, id: int) -> User:
if user := self._cache.get(f"user:{id}"):
return user
user = self._repo.find_by_id(id)
self._cache.set(f"user:{id}", user)
return userBehavioral — How Objects Communicate
Observer / Event
Problem: Notify multiple objects when state changes, without tight coupling.
class EventBus:
def __init__(self):
self._handlers: dict[str, list[Callable]] = {}
def subscribe(self, event: str, handler: Callable): ...
def publish(self, event: str, data: any): ...
# OrderService doesn't know about EmailService, InventoryService, etc.
event_bus.publish("order.placed", order)Strategy
Problem: Swap algorithms at runtime.
class PaymentProcessor:
def __init__(self, strategy: PaymentStrategy):
self._strategy = strategy
def charge(self, amount: float):
self._strategy.process(amount) # Stripe, PayPal, Crypto — all the same interfaceCommand
Problem: Encapsulate requests as objects (for undo/queue/logging).
class Command(ABC):
@abstractmethod
def execute(self): ...
@abstractmethod
def undo(self): ...
class MoveCommand(Command):
def execute(self): self.piece.move(self.destination)
def undo(self): self.piece.move(self.origin)Template Method
Problem: An algorithm's structure is fixed, but specific steps vary per subclass.
class ReportGenerator(ABC):
def generate(self) -> str: # fixed skeleton — not overridable
data = self.fetch_data()
return self.format(data)
@abstractmethod
def fetch_data(self) -> list: ...
@abstractmethod
def format(self, data: list) -> str: ...
class CSVReport(ReportGenerator):
def fetch_data(self): return db.query("SELECT ...")
def format(self, data): return ",".join(str(r) for r in data)Pattern Selection Guide
| Situation | Pattern |
| Creating objects based on type/condition | Factory Method |
| Complex object construction | Builder |
| Incompatible interface | Adapter |
| Add behavior non-invasively | Decorator |
| Decouple data access | Repository |
| Notify many listeners | Observer |
| Swap algorithms | Strategy |
| Provide simple interface to complex subsystem | Facade |
| Control/cache access to an object | Proxy |
| Fixed algorithm with varying steps | Template Method |
| Undo/queue operations | Command |
When to Refactor TO a Pattern
| Signal in your code | Introduce |
| if/elif grows every time you add a new type | Factory Method |
| Constructor keeps gaining optional parameters | Builder |
| Need to add logging/caching/auth to many classes | Decorator or Proxy |
| Multiple services react to the same event | Observer |
| Same algorithm, varying steps per subclass | Strategy or Template Method |
| Caller must coordinate many subsystem calls | Facade |
| Operations need undo or async queuing | Command |
Anti-Pattern Warning
| Pattern abuse | Sign |
| Factory for 1 type | Just use new |
| Observer with 1 subscriber | Just call the method |
| Singleton everywhere | You're hiding global state |
| Strategy with 1 strategy | Premature flexibility |
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.

