Agent skill
design-patterns
Identifies, implements, and refactors code using standard Design Patterns (GoF + Modern).
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/architecture-andreibesleaga-gabbe-11
SKILL.md
Design Patterns Skill
Triggers
- design pattern
- refactor pattern
- strategy pattern
- observer pattern
- factory pattern
- singleton
Purpose
To improve code maintainability, flexibility, and readability by applying proven solutions to common design problems.
Supported Patterns (2025 Context)
Creational
- Factory / Builder: For complex object construction (e.g., configuring LLM clients).
- Singleton: Use sparingly (e.g., for Database connections or Logging service).
Structural
- Adapter: Connecting legacy code or external APIs (e.g., standardizing different LLM APIs).
- Facade: Simplifying complex subsystems (e.g., a simple
WebScraperclass wrapping Puppeteer). - Composite: For tree structures (e.g., parsing code ASTs).
Behavioral
- Strategy: Swappable algorithms (e.g., switching between 'Fast' and 'Smart' search).
- Observer: Event handling (e.g., updating UI when data changes).
- State: Managing complex entity lifecycles (e.g., Order status: Pending -> Paid -> Shipped).
Modern / Cloud
- Circuit Breaker: Preventing cascading failures in distributed calls.
- Sidecar: Offloading infra concerns (logging, proxying) to a separate process/container.
- BFF (Backend for Frontend): API layer tailored to specific UIs.
Instructions
- Identify the Problem: "I have a lot of
if/elsestatements for different payment methods." - Match Pattern: "This looks like a use case for the Strategy Pattern."
- Refactor:
- Define the Interface.
- Implement Concrete Strategies.
- Inject the Strategy into the Context.
- Document: Add a comment or use
DESIGN_PATTERN_USAGE.mdif complex.
Anti-Patterns to Avoid
- God Object: Class that does everything.
- Golden Hammer: Using the same pattern everywhere (e.g., everything is a Singleton).
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?