About cqrs-and-handlers
A Symfony skill for structuring CQRS use cases with separate command and query buses and dedicated handlers. It guides message design, bus configuration, dispatching, and tests.
Key features
- 01Separate command and query buses
- 02Readonly message classes
- 03One handler per message
- 04Command-bus middleware setup
- 05Controller dispatch patterns
Use cases
- 01Separating state changes from reads
- 02Adding a command with its handler
- 03Adding a query with its handler
- 04Testing handlers and controller flows
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dev-toolings/ superpowers-symfony --skill cqrs-and-handlersAfter installing, type/cqrs-and-handlersin Claude Code to confirm it loaded.
Bundled filesreference.md
Details
From the project READMECqrs And Handlers (Symfony)
Use when
- Separating writes from reads with distinct command and query buses.
- A service both changes state and returns data for display.
- Adding a use case as a command or a query with its own handler.
Default workflow
- Name the use case: a command changes state, a query returns data.
- Write the message as a readonly class and exactly one handler for it.
- Configure separate command and query buses; give the command bus the
validationanddoctrine_transactionmiddleware. - Inject the buses behind small interfaces, or the native buses with
#[Target]. - Dispatch from a thin controller and return the query result or the new id.
Guardrails
- Commands return nothing, or at most the id they created.
- Queries have no side effects, so they can be cached and retried.
- One handler per message; no handler dispatches back onto the bus it serves.
- Read models for complex queries are optional: add them when a query outgrows the entities.
Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.
Output contract
- Commands, queries and their handlers.
- The bus configuration and its middleware.
- Handler tests, and a functional test through the controller.
References
reference.md
Comments
Markdown supported