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

make-controller

Skill4 starsChanged 2 months agoMITView on GitHub

Use when creating a controller or an HTTP endpoint in a Symfony project.

The file

Files
SKILL.md

Controller

symfony console make:controller ProductController
symfony console make:controller ProductController --no-template   # API, no Twig
symfony console make:controller HealthController --invokable      # single action

The maker takes the class name as an argument and asks nothing further. Install it first if it is missing: symfony composer require --dev symfony/maker-bundle.

What to keep

Extend AbstractController — always. It provides render(), redirectToRoute(), isGranted() and the form helpers, and a controller is thin enough that the coupling costs nothing.

Route metadata goes in attributes, never YAML: #[Route] on the class as a prefix and on each action, with snake_case route names prefixed by the entity (product_index, product_show).

What the framework already does for you

  • #[MapRequestPayload] and #[MapQueryString] on an action argument wire up the Serializer and the Validator. Hand-written json_decode() plus manual checks is the thing to avoid. Both need symfony/serializer and symfony/validator — require them rather than falling back to parsing by hand.
  • A failed validation on those attributes already answers 422 with the violations. An exception listener written to produce that response duplicates what the attribute does. validationFailedStatusCode changes the code when 422 is wrong for the endpoint.
  • A route parameter type-hinted as an entity is resolved and 404s on its own. Query the repository yourself only when the lookup is genuinely more complex.
  • #[IsGranted] and #[Cache] express authorisation and caching declaratively.

Business logic belongs in a service. A controller that grew past orchestration has taken on someone else's job.

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.