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

make-decorator

Skill4 starsChanged 2 months agoMITView on GitHub

Use when an existing service's behavior must change without editing its class, such as adding caching, logging or a fallback around it.

The file

Files
SKILL.md

Service decorator

symfony console make:decorator translator App\\Translation\\LoggingTranslator

Both values are arguments: the id of the service to decorate, then the class to create. Non-interactively the id must be exact. An interactive run guesses near misses and offers a choice, a non-interactive run fails instead. symfony console debug:container lists the ids. --priority orders multiple decorators on the same service.

What you get

A class marked #[AsDecorator('<id>')], a constructor that receives the decorated service through #[AutowireDecorated], and one forwarding method per public method of the decorated class. No configuration file changes: the attribute is the registration.

Change only the methods whose behavior should differ and leave the rest forwarding. A decorator that reimplements everything is a replacement, and then the honest move is a new service, not a decorator.

When to decorate

Decorating earns its place when the class is not yours to edit: a vendor service, a framework service, or a class other code depends on staying as it is. When you own the class and can change it, change it. A decorator around your own service adds indirection without buying anything.

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.