strategy-pattern — Claude Code skill: what it does, how to install
Implements the Strategy pattern in Symfony using tagged services. Helps clean up branching logic when algorithms or providers vary at runtime.
MIT ★ 234 updated 2026-10-05
npx skills add dev-toolings/superpowers-symfony --skill strategy-pattern -a claude-codeWhat strategy-pattern does
This skill guides the implementation of the Strategy pattern in Symfony projects without letting match or switch blocks grow out of hand. It defines a strategy interface with a supports() check or a unique key, registers implementations via #[AutoconfigureTag], and sets up injection with #[AutowireIterator] or #[AutowireLocator].
The generated structure includes a selector that fails explicitly if no strategy matches, fallback handling, priority sorting, and unit tests using test doubles. For fixed two-branch scenarios that will not expand, the instructions advise keeping a plain match statement instead of introducing extra classes.
What it helps with
- replace growing
switchormatchblocks on type strings - iterate through algorithm implementations via
#[AutowireIterator] - resolve keyed services using Symfony
#[AutowireLocator] - add payment gateways or export formats without touching selector code
Example prompts for the agent
- Refactor our payment provider selection into Symfony tagged strategies
- Create an export strategy selector using AutowireIterator with priority ordering
- Write unit tests for the strategy selector covering the no-match failure case
How to install strategy-pattern
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill strategy-pattern -a claude-code2Manually: put the files in place
~/.claude/skills/strategy-pattern/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/strategy-pattern/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill strategy-pattern -a codex2Manually: put the files in place
.agents/skills/strategy-pattern/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill strategy-pattern -a cursor2Manually: put the files in place
.cursor/skills/strategy-pattern/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install dev-toolings/superpowers-symfony content/skills/strategy-pattern2Manually: put the files in place
.github/skills/strategy-pattern/SKILL.md1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill strategy-pattern -a gemini-cli2Platform CLI
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/strategy-patternManually: put the files in place
.devin/skills/strategy-pattern/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about strategy-pattern
How to install strategy-pattern in Claude Code?
Run npx skills add dev-toolings/superpowers-symfony --skill strategy-pattern -a claude-code in your terminal.
What does strategy-pattern do?
It guides Claude Code to build stateless Symfony strategy classes, configure tagged service locators or iterators, and test selector fallbacks.
When does the skill advise skipping the Strategy pattern?
When there are only two static cases that will not grow, a native match expression is preferred over the full pattern.
Source text
SKILL.md · MIT
--- 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`
© dev-toolings · MIT · dev-toolings/superpowers-symfony