design-patterns
/design-patterns
Rozpoznaje, implementuje i refaktoryzuje kod według standardowych wzorców projektowych (GoF i nowoczesnych), takich jak strategy, observer, factory i singleton.
- Autor
- andreibesleaga ↗
- Repozytorium
- gabbe ↗
- Licencja
- CC-BY-4.0
- Ostatnia zmiana repozytorium
- 24.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 2
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 24.10.2026, bez odwołań do wycofanych modeli i API.
CC-BY-4.0, otwarta.
Co robi i kiedy
Rozpoznaje, implementuje i refaktoryzuje kod według standardowych wzorców projektowych (GoF i nowoczesnych), takich jak strategy, observer, factory i singleton.
Oryginalny opis (EN)
Identifies, implements, and refactors code using standard Design Patterns (GoF + Modern). Use when: design pattern, refactor pattern, strategy pattern, observer pattern, factory pattern, singleton.
Jak działa
- Goal
- Supported Patterns (2025 Context)
- Steps
- Anti-Patterns to Avoid
- Security & Guardrails
Podgląd SKILL.md
---
name: design-patterns
description: "Identifies, implements, and refactors code using standard Design Patterns (GoF + Modern). Use when: design pattern, refactor pattern, strategy pattern, observer pattern, factory pattern, singleton."
license: CC-BY-SA-4.0
metadata:
source: "agents/skills/architecture/design-patterns.skill.md"
tags: "architecture"
core: "false"
context_cost: "low"
---
# Design Patterns Skill
## Goal
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 `WebScraper` class 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.
## Steps
1. **Identify the Problem**: "I have a lot of `if/else` statements for different payment methods."
2. **Match Pattern**: "This looks like a use case for the **Strategy Pattern**."
3. **Refactor**:
- Define the Interface.
- Implement Concrete Strategies.
- Inject the Strategy into the Context.
4. **Document**: Add a comment or use `DESIGN_PATTERN_USAGE.md` if complex.
## Anti-Patterns to Avoid
- **God Object**: Class that does everything.
- **Golden Hammer**: Using the same pattern everywhere (e.g., everything is a Singleton).
## Security & Guardrails
### 1. Skill Security (Design Patterns)
- **Pattern Implementation Integrity**: When the agent generates code for complex patterns like `Facade` or `Adapter`, it must not inadvertently bypass existing security checks. For example, if an `Adapter` wraps an older API, the agent must ensure it does not accidentally strip out authentication headers or input sanitization routines present in the original call chain.
- **Singleton State Exhaustion**: If the agent implements a `Singleton` for a shared resource (like a DB connection pool), it must explicitly define maximum bounds and timeout values. An unbound Singleton can be exploited to cause a Denial of Service (DoS) by exhausting memory or connections globally across the application.
### 2. System Integration Security
- **Proxy/Sidecar Bypass**: When the architecture uses a `Sidecar` or `BFF` for security concerns (like TLS termination or global rate limiting), the agent must physically or logically isolate the backend service so it ONLY accepts traffic from the Sidecar/BFF. Any network configuration allowing a direct request to the backend service bypasses the security pattern entirely.
- **Observer Data Leakage**: In the `Observer` pattern, state changes are broadcast to all subscribed listeners. The agent must verify that sensitive data (e.g., unhashed passwords, PII) is scrubbed from the event payload *before* it is broadcast, ensuring that an arbitrary internal listener cannot silently capture regulated data.
### 3. LLM & Agent Guardrails
- **Complexity-Driven Vulnerabilities**: The LLM might propose an overly convoluted combination of `Strategy`, `Factory`, and `Decorator` patterns to solve a simple problem. This extreme abstraction (the "Lasagna Architecture") makes it nearly impossible for human reviewers to trace the execution flow and identify authorization bugs. The agent must prioritize the "Keep It Simple, Stupid" (KISS) principle for security-critical pathways.
- **Hallucinated Thread-Safety**: The agent must definitively know the concurrency model of the target language. If the agent generates a `Singleton` in a multi-threaded language (like Java or Go), it is strictly forbidden from generating naive, thread-unsafe initializations which could lead to race conditions and unpredictable authorization state.
Pliki w paczce (2)
- DESIGN_PATTERN_USAGE.md 1 KB
- SKILL.md 4 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · andreibesleaga/gabbe | 100 | CC-BY-4.0 |
| spencerbeggs/effected | 100 | MIT |
| spencerbeggs/effected | 100 | MIT |
| joeblackwaslike/agent-skills | 100 | MIT |
| krzysztofsurdy/code-virtuoso | 100 | MIT |
| nimadorostkar/Claude-Skills-collection | 100 | MIT |
| pantheon-org/tekhne | 100 | MIT |
| itzcull/software-skills | 100 | MIT |
| guilhermevozniak/refactor-pilot-framework | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 2baea9e9a828 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100design-patterns-ruby
Dostarcza implementacje wzorców Gang of Four w Ruby (Factory, Singleton, Observer, Strategy i inne) do rozwiązań obiektowych, redukcji sprzężeń i problemów architektonicznych. - 100design-patterns-implementation
Stosuje wzorce projektowe (Singleton, Factory, Observer, Strategy i inne) do problemów architektonicznych, przy refaktoryzacji, systemach rozszerzalnych i zasadach SOLID. - 100design-patterns-gof
Dostarcza praktyczny przewodnik po 23 wzorcach Gang of Four: intencja, kompromisy, aktualność, zamienniki w językach i przypadki, kiedy ich unikać, do code review i oceny nadmiernej abstrakcji. - 100php-patterns
Stosuje wzorce projektowe w PHP (Repository, Factory, Strategy, Decorator, Observer, Singleton, Builder, wstrzykiwanie zależności) przy architekturze aplikacji i wzorcach z Magento. - 100php-patterns
Stosuje wzorce projektowe w PHP (Singleton, Factory, Strategy, Observer, Repository, Decorator, wstrzykiwanie zależności) przy strukturze rozszerzeń WooCommerce i złożonej logice biznesowej. - 100design-pattern
Dostarcza wiedzę o wzorcach projektowych (GoF, architektoniczne, SOLID) i pomaga stosować je do poprawy utrzymywalności kodu oraz wykrywania code smells.