Skip to content
Back to skills

Strategy Pattern

ASecurity

Implement the Strategy pattern with Symfony's tagged services for runtime algorithm selection and extensibility

  • 233 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added August 31, 2026
developmentgorails

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 6, 2026

npx -y skills add dev-toolings/superpowers-symfony --skill strategy-pattern --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Strategy Pattern?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Strategy Pattern
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dev-toolings-strategy-pattern/badge)](https://www.skillsdirectory.com/skills/dev-toolings-strategy-pattern)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: strategy-pattern
description: Implement the Strategy pattern with Symfony's tagged services for runtime algorithm selection and extensibility
capabilities: [read, search]
tags: [architecture]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
---

# Strategy Pattern (Symfony)

## Use when
- One operation has several interchangeable algorithms chosen at runtime, such as payment providers or export formats.
- A `switch` or `match` on a type string keeps growing.
- New variants must be added without editing the code that selects them.

## Default workflow
1. Define the strategy interface, with a `supports()` method or a key per strategy.
2. Tag every implementation through `#[AutoconfigureTag]` on the interface or on each class.
3. Inject them with `#[AutowireIterator]` to try each in order, or `#[AutowireLocator]` to fetch one by key.
4. Set priorities where evaluation order matters, and register a fallback strategy.
5. Test each strategy alone, and the selector with fakes.

## Guardrails
- The selector fails explicitly when no strategy supports the input.
- Keep strategies stateless and independent of each other.
- Two cases that will not grow do not need the pattern: a `match` is enough.

## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.

## Output contract
- The interface and its tagged implementations.
- The selector, with its order and its fallback.
- Tests per strategy and for the no-match case.

## References
- `reference.md`

Files in this skill

  • SKILL.md1.1 KB
  • reference.md8.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.