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.
npx agentmods add rules/dasomel/oh-my-cursor/refactoring-patternsgit clone --depth 1 https://github.com/dasomel/oh-my-cursorWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00817 |
| Opus 5 | $0.00000 | $0.00409 |
| Sonnet 5 | $0.00000 | $0.00163 |
| Haiku 4.5 | $0.00000 | $0.00082 |
Grade A, and why
refactoring-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 2d 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.
How it starts
The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactoring Patterns
A catalog of refactoring patterns organized by category. Apply these when improving code structure without changing behavior.
1. Code Smells (Triggers for Refactoring)
| Smell | Symptom | Primary Fix |
|---|---|---|
| Long Method | Function > 20 lines | Extract Method |
| Duplicate Code | Same logic in 2+ places | Extract Method / Extract Class |
| Feature Envy | Method uses another class's data more than its own | Move Method |
| Shotgun Surgery | One change requires editing many files | Move Method / Inline Class |
| Divergent Change | One class modified for many different reasons | Extract Class |
| Primitive Obsession | Using primitives instead of domain types | Replace Data Value with Object |
| Long Parameter List | Function takes > 4 parameters | Introduce Parameter Object |
| Data Clumps | Same group of data appears together repeatedly | Extract Class |
2. Composing Methods
Break large methods into smaller, intention-revealing pieces:
- Extract Method — Move code fragment into a named method
- Inline Method — Replace a method call with the method's body (when name adds nothing)
- Replace Temp with Query — Extract expression into a method, replace temp variable
- Split Temporary Variable — One variable for one purpose
- Replace Method with Method Object — Turn long method into its own class
3. Moving Features Between Objects
Redistribute responsibilities:
- Move Method — Method uses more features of another class
- Move Field — Field used more by another class
- Extract Class — Class doing work of two → split it
- Inline Class — Class doing almost nothing → merge it
- Hide Delegate — Client calls through a chain → add wrapper
- Remove Middle Man — Too many delegating methods → expose delegate
4. Organizing Data
- Replace Magic Number with Constant — Named constants over raw numbers
- Replace Data Value with Object — Primitive → domain type
- Encapsulate Field — Public field → getter/setter
- Encapsulate Collection — Return unmodifiable view
- Replace Type Code with Subclass/Strategy — Type codes → polymorphism
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.
- 2d ago First seen · 94 lines · 0 tokens per session scan A cbec4c57674e
refactoring-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 817 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.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.