design-patterns

design-patterns is a cursor rule for coding agents from dasomel/oh-my-cursor. It costs 0 tokens per session (725 once invoked), scanned A, original, MIT.

A guide to common software design patterns, which are reusable approaches for organizing code when a recurring design problem justifies them.

In plain words
What is it for?
Use it when deciding how to create objects, connect incompatible interfaces, simplify subsystems, add behavior, or select among algorithms.
Why use it?
It explains when patterns fit and when they add needless complexity, helping developers avoid forcing a pattern onto simple code.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/dasomel/oh-my-cursor/design-patterns
Clone the repo
git clone --depth 1 https://github.com/dasomel/oh-my-cursor

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for design-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/dasomel/oh-my-cursor/design-patterns.svg)](https://agentmods.dev/rules/dasomel/oh-my-cursor/design-patterns)
Your own site
<a href="https://agentmods.dev/rules/dasomel/oh-my-cursor/design-patterns"><img src="https://agentmods.dev/badge/rules/dasomel/oh-my-cursor/design-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 725 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00725
Opus 5 $0.00000 $0.00362
Sonnet 5 $0.00000 $0.00145
Haiku 4.5 $0.00000 $0.00072

Measured 3d ago against content hash 24584739bca2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

design-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/practices/design-patterns.mdc · 115 lines

How it starts

The opening of the file, as written. The whole thing — 115 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Design Patterns

Apply patterns that solve genuine problems. Prefer composition over inheritance. Don't force patterns where simple code suffices.

Creational Patterns

Factory

Create objects without specifying exact classes.

Use when: Object creation logic is complex or varies by context
Avoid when: A simple constructor call is sufficient

Builder

Construct complex objects step by step.

Use when: Object has many optional parameters or complex construction
Avoid when: Object has few parameters (use constructor or factory)

Structural Patterns

Adapter

Make incompatible interfaces work together.

Use when: Integrating third-party libraries with different interfaces
Avoid when: You control both sides — just align the interfaces

Facade

Simplify complex subsystems with a unified interface.

Use when: A subsystem has too many entry points for the caller
Avoid when: The subsystem is already simple

Decorator

Add responsibilities dynamically without modifying the original.

Use when: Need to add behavior to objects at runtime
Avoid when: A simple inheritance hierarchy is clearer

Behavioral Patterns

Strategy

Define a family of algorithms, make them interchangeable.

Use when: Multiple algorithms for the same task, selected at runtime
Avoid when: Only one algorithm exists (premature abstraction)

Observer

One-to-many dependency for event notification.

Use when: Multiple components need to react to state changes
Avoid when: Simple callback is sufficient

Repository

Abstract data access from business logic.

Use when: Business logic should be independent of data source
Avoid when: Simple scripts with direct database access

Dependency Injection

Invert control by injecting dependencies.

Use when: Components should be testable and loosely coupled
Avoid when: Global state is acceptable (scripts, CLIs)

Anti-Patterns to Avoid

Anti-Pattern Problem Fix
God Object One class does everything Extract classes by responsibility
Singleton Abuse Global state disguised as pattern Use DI instead
Premature Abstraction Pattern for one use case Wait for 2-3 uses before abstracting
Golden Hammer Applying favorite pattern everywhere Choose pattern that fits the problem
Lava Flow Dead code kept "just in case" Delete it; git has history

Read the full file on GitHub · 115 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 115 lines · 0 tokens per session scan A 24584739bca2

Subscribe to this mod's changes

design-patterns is a cursor rule published in the GitHub repository dasomel/oh-my-cursor (2 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 725 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.