services
Skill4 starsChanged 3 months agoMITView on GitHub
Use when creating a service class, wiring dependency injection, or about to edit services.yaml.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cli-conventionsSkill
- componentsSkill
- configurationSkill
- discoverSkill
- make-ciSkill
- make-commandSkill
- make-controllerSkill
- make-crudSkill
- make-decoratorSkill
- make-entitySkill
- make-formSkill
- make-listenerSkill
- make-migrationSkill
- make-registration-formSkill
- make-reset-passwordSkill
- make-security-customSkill
- make-security-form-loginSkill
- make-testSkill
- make-twig-extensionSkill
- make-userSkill
- make-voterSkill
- make-webhookSkill
- templatesSkill
The file
Files
Services and dependency injection
The default services.yaml already registers every class in src/ as a service,
autowired and autoconfigured. A new class is a service the moment the file exists. The
most common mistake is adding configuration for it anyway.
Training data is full of the old style: explicit service ids, arguments: lists,
public: true, tags wired by hand. None of that is current. If you are writing a
services.yaml entry, name the reason; the legitimate ones are a vendor class outside
src/ and a per-environment override. Everything else has an attribute.
What needs no configuration
- Constructor type-hints resolve themselves. An interface with exactly one implementation autowires like a class.
#[AsEventListener],#[AsCommand],#[AsMessageHandler]and friends register the service where it is used. No tag entry anywhere.- Services are private and stateless by default. Keep them that way: nothing fetches from
the container, everything is injected.
ContainerInterfacein a constructor is the container pattern the defaults exist to prevent.
When you do configure, do it in the class
public function __construct(
#[Autowire('%kernel.project_dir%')] private string $projectDir,
#[AutowireIterator('app.exporter')] private iterable $exporters,
) {
}- A scalar comes in via
#[Autowire('%parameter%')]or#[Autowire(env: 'NAME')]. Where the value itself belongs is theconfigurationskill's question. - Several implementations of one interface:
#[AutowireIterator]or#[AutowireLocator]on the consumer,#[AsTaggedItem]on the implementations. - One implementation should win the type-hint:
#[AsAlias]on it.
Constructor injection is the default; reach for anything else only with a reason the code can show.
Checking
symfony console debug:autowiring <type> says what a type-hint resolves to, and
debug:container <service> shows the final definition. Ask, don't guess; the discover
skill lists the rest.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

