agentleFS
wachterjohanneswachterjohannes/symfony-skills/skills/make-listener/SKILL.md

make-listener

Skill4 starsChanged 2 months agoMITView on GitHub

Use when code should run in response to a framework or application event.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer the listener. The attribute keeps the wiring next to the method it wires, and a class handling several related events is the case …

    line 27

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Event listener

symfony console make:listener ExceptionListener kernel.exception
symfony console make:listener RequestSubscriber kernel.request

The suffix decides what is generated: a name ending in Listener produces a listener, one ending in Subscriber a subscriber. Both the name and the event are arguments, so nothing is asked. Install the maker first if it is missing: symfony composer require --dev symfony/maker-bundle.

Listener or subscriber

A listener declares one method with #[AsEventListener] and says in the attribute which event and at what priority. A subscriber declares getSubscribedEvents() and carries that knowledge in the class itself.

Prefer the listener. The attribute keeps the wiring next to the method it wires, and a class handling several related events is the case where a subscriber earns its extra indirection.

What to keep

The generated class is an ordinary service — inject what it needs through the constructor.

Priority matters when several listeners touch the same event, and the default of 0 is usually right. symfony console debug:event-dispatcher <event> shows the order that actually applies, which is worth checking before guessing at a number.

Where a listener is the wrong answer

An event listener runs on every dispatch of that event, application-wide. A rule that applies to one controller belongs in that controller, and a decision about access belongs in a voter. Reach for a listener when the behaviour is genuinely cross-cutting.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.