refactor-design-patterns
Refactor Design Patterns
Use this skill to make design-pattern suggestions practical, incremental, and grounded in the code that already exists.
Start with references/refactoring-workflow.md.
Use references/catalog.md to route by problem type:
references/creational/index.mdfor creation and configuration problemsreferences/structural/index.mdfor composition, wrapping, interoperability, or simplification problemsreferences/behavioral/index.mdfor control flow, runtime behavior, communication, or orchestration problems
Use references/agent-mappings.md only when an AI-agent analogy would clarify the recommendation.
Working style
Anchor every recommendation in the current codebase and the user's actual pain points.
Prefer the smallest useful refactor. The goal is not to force a pattern into the design; the goal is to decide whether a pattern makes the code easier to change, easier to test, or easier to understand.
When reviewing a feature:
- Identify the concrete design pressure.
- Decide whether the problem is mainly creational, structural, or behavioral.
- Recommend 1 to 3 candidate patterns at most.
- Explain why the best option fits this code better than nearby alternatives.
- Call out anti-signals and the simplest valid option if a pattern would be overkill.
- Suggest an incremental refactor path instead of a rewrite.
- Tailor the implementation advice to the repository language and conventions when they are known.
What to look for
Look for recurring signs such as:
- large conditional trees that choose behavior
- tightly coupled modules with unclear boundaries
- difficult object or service construction
- wrapper code repeated across integrations
- state transitions encoded as flags and branching
- scattered side effects and notification logic
- features that are correct but painful to extend
Output guidance
Prefer a practical structure like this:
- Design problem
- Best pattern choice
- Why it fits here
- Why nearby patterns do not fit as well
- Refactor sketch or steps
- Risks, tradeoffs, and anti-signals
If the user asks for code changes, keep the implementation incremental and idiomatic for the language in the repo.
Guardrails
Do not recommend a pattern only because the terminology sounds familiar.
Do not abstract early when:
- there is only one stable behavior
- the variation is speculative
- the new layer would hide simple code behind ceremony
- the existing problem can be solved with a small extraction or rename
If no pattern is warranted, say so clearly and recommend the simpler refactor.
More from joacod/skills
secure-node-typescript
Write secure-by-default Node.js and TypeScript applications following security best practices. Use when: (1) Writing new Node.js/TypeScript code, (2) Creating API endpoints or middleware, (3) Handling user input or form data, (4) Implementing authentication or authorization, (5) Working with secrets or environment variables, (6) Setting up project configurations (tsconfig, eslint), (7) User mentions security concerns, (8) Reviewing code for vulnerabilities, (9) Working with file paths or child processes, (10) Setting up HTTP headers or CORS.
39react-anti-patterns
Introduce React anti-patterns and common mistakes into existing React codebases for training, review, or teaching. Use when asked to intentionally degrade React performance or code quality while keeping apps functional, or to generate anti-pattern examples for junior developer education.
13