Skip to main content
skill CX Codex

cqrs-and-handlers — Claude Code skill: what it does, how to install

cqrs-and-handlers implements CQRS in Symfony projects using separate Messenger buses for commands and queries.

MIT ★ 234 updated 2026-10-05

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dev-toolings/superpowers-symfony --skill cqrs-and-handlers -a claude-code
Open on GitHub

What cqrs-and-handlers does

This skill guides Claude Code through setting up a CQRS structure with the Symfony Messenger component. It enforces isolated paths for writes and reads, requiring messages to be readonly classes handled by a single dedicated handler.

The command bus configuration includes validation and doctrine_transaction middleware to keep state changes atomic and valid. Commands return either nothing or just the created identifier. In contrast, queries must remain free of side effects, which allows caching and safe retries.

Along with messages and bus configuration, the workflow expects unit tests for each handler and a functional test running through the controller.

What it helps with

  • split reads and writes into dedicated Messenger buses in Symfony
  • generate readonly commands and single-purpose handlers
  • configure transactional middleware for state changes
  • create handler unit tests and controller functional tests

Example prompts for the agent

  • Create a command and handler for registering a new user with validation middleware
  • Design a query bus flow to fetch account settings without side effects
  • Configure separate command and query buses in messenger.yaml

How to install cqrs-and-handlers

1Skills CLI (Vercel)

npx skills add dev-toolings/superpowers-symfony --skill cqrs-and-handlers -a claude-code

2Manually: put the files in place

~/.claude/skills/cqrs-and-handlers/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cqrs-and-handlers/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cqrs-and-handlers

How to install cqrs-and-handlers in Claude Code?

Run npx skills add dev-toolings/superpowers-symfony --skill cqrs-and-handlers -a claude-code in your terminal.

What does cqrs-and-handlers do?

It provides architecture rules and templates for building CQRS workflows in Symfony with separate message buses and test suites.

What are the rules for handlers in this skill?

Each message must have exactly one handler. Handlers are forbidden from dispatching back into their own bus, and commands cannot return arbitrary data beyond a generated ID.

Source text

SKILL.md · MIT
---
name: cqrs-and-handlers
description: Implement CQRS in Symfony with separate Command and Query buses/handlers using the Messenger component
capabilities: [read, search]
tags: [architecture, messenger]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
---

# Cqrs 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
1. Name the use case: a command changes state, a query returns data.
2. Write the message as a readonly class and exactly one handler for it.
3. Configure separate command and query buses; give the command bus the `validation` and `doctrine_transaction` middleware.
4. Inject the buses behind small interfaces, or the native buses with `#[Target]`.
5. 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`

© dev-toolings · MIT · dev-toolings/superpowers-symfony

Similar skills

All skills for Backend and APIs →

From the same set51

The whole set →
effective-context effective-context is a Claude Code skill that teaches an agent to gather context for Symfony development: versions, error-path files, stack traces, and project constraints. CX Codex +1 ★ 234repo stars strategy-pattern Implements the Strategy pattern in Symfony using tagged services. Helps clean up branching logic when algorithms or providers vary at runtime. CX Codex +1 ★ 234repo stars executing-plans The executing-plans skill guides Claude Code through an approved implementation plan, with test-first steps and a separate commit for each one. Use it for multi-step work or to resume after an interruption. CX Codex +1 ★ 234repo stars twig-components twig-components turns repeated Twig markup into Symfony UX components with props, slots and CVA variants. Handy once the same template chunk starts getting copied around. CX Codex +1 ★ 234repo stars daily-workflow The daily-workflow skill lays out a routine for Symfony work, from getting a project running to checking changes before a commit. Use it for migrations, debugging, and recurring maintenance. CX Codex +1 ★ 234repo stars bootstrap-check bootstrap-check runs a pass/fail check over a Symfony project's setup: .env, services, Doctrine mappings, routes. Each failure comes with the fix. CX Codex +1 ★ 234repo stars ports-and-adapters ports-and-adapters guides Claude Code in setting up Hexagonal Architecture in Symfony, isolating domain models from Doctrine, HTTP, and vendor SDKs. CX Codex +1 ★ 234repo stars config-env-parameters The config-env-parameters skill guides changes to Symfony environment variables, parameters, and secrets across environments. Use it when configuration needs a clear home and safe injection into the app. CX Codex +1 ★ 234repo stars

Project sponsors

Companies that keep this analytics open