About interfaces-and-autowiring
interfaces-and-autowiring is a Symfony development skill for designing service interfaces and resolving dependency injection. It covers implementation selection, decorators, tagged collections, scalar injection, and diagnosing autowiring failures.
Key features
- 01Extracting focused service interfaces
- 02Selecting implementations with aliases
- 03Adding behavior with decorators
- 04Injecting scalars and tagged services
- 05Diagnosing autowiring with debug:autowiring
Use cases
- 01Making a service replaceable in tests
- 02Choosing among multiple implementations
- 03Adding logging, caching, or retries
- 04Resolving ambiguous or failed autowiring
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dev-toolings/ superpowers-symfony --skill interfaces-and-autowiringAfter installing, type/interfaces-and-autowiringin Claude Code to confirm it loaded.
Bundled filesreference.md
Details
From the project READMEInterfaces And Autowiring (Symfony)
Use when
- A service depends on a concrete class and must be swappable or replaced in tests.
- Several implementations of one interface exist and the right one must be injected.
- Adding cross-cutting behavior (logging, caching, retries) around an existing service.
- Injecting scalars, parameters, env vars, or every service carrying a tag.
- Autowiring fails with "cannot autowire" or an ambiguous type.
Default workflow
- Extract a focused interface for what the consumer actually needs.
- Let autowiring bind it when there is a single implementation.
- With several implementations, pick one per consumer through a named alias and
#[Target]. - Add behavior around a service with
#[AsDecorator]instead of editing or extending it. - Inject scalars with
#[Autowire]and tagged collections with#[AutowireIterator]. - Confirm the result with
debug:autowiringfor each type involved.
Guardrails
- Constructor injection with
private readonlydependencies; no setter injection, no container access. - Keep interfaces small: one consumer need per interface.
- Make services
finalby default and decorate them rather than extend them. - Use lazy services or service closures only for expensive dependencies that some paths skip.
Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.
Output contract
- Interfaces and the bindings or aliases that select each implementation.
- Decorators or tagged collections, with their priority.
- The
debug:autowiringoutput for the types involved.
References
reference.md
Comments
Markdown supported