Skip to content
Back to skills

Create Cqrs Queries

ASecurity

Create the read-side CQRS layer: queries, result DTOs, and query handler interfaces. Covers Get{Domain}ForEditing (single entity for edit form) and optionally Get{Domain}sForListing (grid data source). Trigger: "create queries for {Domain}", "set up read side for {Domain}".

  • 6 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 29, 2026
ai-agentsgophp

Security analysis

A100/100

Scanned May 29, 2026

npx -y skills add jeffsenso/prestashop-skills --skill create-cqrs-queries --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Create Cqrs Queries?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Create Cqrs Queries
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jeffsenso-create-cqrs-queries/badge)](https://www.skillsdirectory.com/skills/jeffsenso-create-cqrs-queries)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: create-cqrs-queries
description: >
  Create the read-side CQRS layer: queries, result DTOs, and query handler interfaces.
  Covers Get{Domain}ForEditing (single entity for edit form) and optionally
  Get{Domain}sForListing (grid data source). Trigger: "create queries for {Domain}",
  "set up read side for {Domain}".
needs: [create-cqrs-commands]
produces: "src/Core/Domain/{Domain}/Query/, QueryResult/, QueryHandler/ — read-side domain layer"
subagent: optional
---

# create-cqrs-queries

Read [CQRS/CONTEXT.md](../../CONTEXT.md) for conventions (scalar inputs/VO getters, QueryResult scalar-only rule).

## 1. Get-for-editing query

Create `src/Core/Domain/{Domain}/Query/Get{Domain}ForEditing.php`:

- Constructor takes `int $id` (scalar)
- Getter returns VO: `getId(): {Domain}Id`
- Queries are read-only data objects — no side effects

## 2. Result DTO

Create `src/Core/Domain/{Domain}/QueryResult/Editable{Domain}.php`:

- Constructor parameters: all fields the edit form needs to pre-fill (scalar types only — see CONTEXT.md)
- Public getter for every field
- Immutable: no setters, all values set at construction

**Reference:** `src/Core/Domain/Tax/QueryResult/EditableTax.php` (simple), `src/Core/Domain/Manufacturer/QueryResult/EditableManufacturer.php` (with associations)

## 3. List query (assess first)

Most PS grids use `SearchCriteria` + grid `QueryBuilder` directly — no explicit CQRS query class needed.

Check the domain convention before creating a list query:
- If the domain uses `SearchCriteria` + `QueryBuilder` in the grid: skip this step
- If the domain uses an explicit query: create `Get{Domain}sForListing.php` with `SearchCriteria` parameter

**Reference:** Most domains (Tax, Manufacturer, Category) use the grid QueryBuilder pattern without an explicit list query.

## 4. Query handler interfaces

Create in `src/Core/Domain/{Domain}/QueryHandler/`:

- `Get{Domain}ForEditingHandlerInterface` with `handle(Get{Domain}ForEditing $query): Editable{Domain}`
- If list query exists, create corresponding interface
- Query handlers always return data (typed DTO or array) — never void

## Rules

Conventions (scalar-only DTOs, read-only queries) are in [CQRS/CONTEXT.md](../../CONTEXT.md). Skill-specific reminders:

- Map ALL editable fields in the DTO — missing fields cause empty form fields on edit
- Return typed DTOs, not ObjectModel instances

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.