symfony-api-response
Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API,…
Symfony CQRS command/query handlers — commands, queries, handlers, bus configuration, use cases. Triggers on: command, query, handler, CQRS, bus, use case, command handler, query handler, message bus
$ npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-cqrs-handlers --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/symfony-cqrs-handlersContext preview
The summary Claude sees to decide when to auto-load this skill.
Symfony CQRS command/query handlers — commands, queries, handlers, bus configuration, use cases. Triggers on: command, query, handler, CQRS, bus, use case, command handler, query handler, message bus
description: "Symfony CQRS command/query handlers — commands, queries, handlers, bus configuration, use cases. Triggers on: command, query, handler, CQRS, bus, use case, command handler, query handler, message bus"
You are an expert in CQRS (Command Query Responsibility Segregation) within Symfony hexagonal architecture.
Commands represent write operations (create, update, delete). They are DTOs dispatched to the command bus.
namespace App\Application\{Module}\Command;
final readonly class {ActionVerb}{Entity}
{
public function __construct(
public string $param1,
public string $param2,
// only primitives and simple types
) {
}
}namespace App\Application\{Module}\Command;
use App\Domain\{Module}\Port\{Repository}Interface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler(bus: 'command.bus')]
final readonly class {ActionVerb}{Entity}Handler
{
public function __construct(
private {Repository}Interface $repository,
) {
}
public function __invoke({ActionVerb}{Entity} $command): void
{
// 1. Reconstruct/create domain objects
// 2. Execute business logic
// 3. Persist via port
// NO side-effects here — use domain events
}
}Queries represent read operations. They return DTOs, never domain entities.
namespace App\Application\{Module}\Query;
final readonly class {GetDescription}
{
public function __construct(
public string $identifier,
// filter/pagination params
) {
}
}namespace App\Application\{Module}\Query;
use App\Application\{Module}\DTO\{Entity}DTO;
use App\Domain\{Module}\Port\{Repository}Interface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler(bus: 'query.bus')]
final readonly class {GetDescription}Handler
{
public function __construct(
private {Repository}Interface $repository,
) {
}
public function __invoke({GetDescription} $query): ?{Entity}DTO
{
$entity = $this->repository->findById($query->identifier);
if ($entity === null) {
return null;
}
return {Entity}DTO::fromEntity($entity);
}
}namespace App\Application\{Module}\DTO;
final readonly class {Entity}DTO
{
public function __construct(
public string $id,
public string $field1,
public string $field2,
) {
}
public static function fromEntity(/* entity */): self
{
return new self(
id: (string) $entity->id(),
field1: $entity->field1(),
field2: $entity->field2(),
);
}
}See `references/` for detailed guides:
A Claude Code plugin that enforces hexagonal architecture (ports & adapters) in Symfony projects. Works with both new projects (full scaffolding) and existing projects (progressive, module-by-module refactoring).
Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API,…
Symfony Doctrine persistence — repository adapters, entity mapping, migrations, transactions, database patterns. Triggers on: doctrine, repository,…
Symfony domain modeling — entities, value objects, domain events, aggregates, domain exceptions. Triggers on: entity, value object, domain event, aggregate,…
Symfony hexagonal architecture setup — project structure, module scaffolding, layer responsibilities, dependency rules. Triggers on: architecture, module,…
Symfony Messenger async processing — message queues, retry strategies, failure transport, Symfony Scheduler, idempotency patterns, background jobs. Triggers…
Symfony ports and adapters — port interfaces, adapter implementations, dependency injection, autowiring, repository interfaces. Triggers on: port, adapter,…