acc-create-query
Generates CQRS Queries and Handlers for PHP 8.5. Creates read-only query DTOs with handlers that return data without side effects. Includes unit tests.
Best use case
acc-create-query is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates CQRS Queries and Handlers for PHP 8.5. Creates read-only query DTOs with handlers that return data without side effects. Includes unit tests.
Teams using acc-create-query should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-create-query/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-create-query Compares
| Feature / Agent | acc-create-query | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates CQRS Queries and Handlers for PHP 8.5. Creates read-only query DTOs with handlers that return data without side effects. Includes unit tests.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Query Generator
Generate CQRS-compliant Queries and Query Handlers with tests.
## Query Characteristics
- **Immutable**: `final readonly class`
- **Interrogative naming**: Get/Find/List + noun
- **No side effects**: Handler never modifies state
- **Returns DTOs**: Never returns domain entities
- **Read-optimized**: Can use dedicated read models
---
## Generation Process
### Step 1: Generate Query
**Path:** `src/Application/{BoundedContext}/Query/`
1. `{Name}Query.php` — Immutable query DTO with parameters
### Step 2: Generate Handler
**Path:** `src/Application/{BoundedContext}/Handler/`
1. `{Name}Handler.php` — Read model consumer
### Step 3: Generate DTOs
**Path:** `src/Application/{BoundedContext}/DTO/`
1. `{Name}DTO.php` — Result data structure
2. `PaginatedResultDTO.php` — For list queries (optional)
### Step 4: Generate Read Model Interface
**Path:** `src/Application/{BoundedContext}/ReadModel/`
1. `{Name}ReadModelInterface.php` — Query methods contract
### Step 5: Generate Tests
**Path:** `tests/Unit/Application/{BoundedContext}/`
---
## File Placement
| Component | Path |
|-----------|------|
| Query | `src/Application/{BoundedContext}/Query/` |
| Handler | `src/Application/{BoundedContext}/Handler/` |
| DTO | `src/Application/{BoundedContext}/DTO/` |
| Read Model Interface | `src/Application/{BoundedContext}/ReadModel/` |
| Unit Tests | `tests/Unit/Application/{BoundedContext}/` |
---
## Query Naming Conventions
| Purpose | Query Name | Returns |
|---------|------------|---------|
| Single by ID | `GetOrderDetailsQuery` | DTO or throws |
| Single by field | `FindUserByEmailQuery` | DTO or null |
| List/Collection | `ListOrdersQuery` | PaginatedResult |
| Search | `SearchProductsQuery` | array of DTOs |
| Count | `CountPendingOrdersQuery` | int |
| Check existence | `CheckEmailExistsQuery` | bool |
---
## Quick Template Reference
### Query
```php
final readonly class {Name}Query
{
public function __construct(
public {IdType} $id
) {}
}
```
### Query with Pagination
```php
final readonly class List{Name}Query
{
public function __construct(
public ?{FilterType} $filter = null,
public int $limit = 20,
public int $offset = 0,
public string $sortBy = 'created_at',
public string $sortDirection = 'desc'
) {
if ($limit < 1 || $limit > 100) {
throw new \InvalidArgumentException('Limit must be between 1 and 100');
}
}
}
```
### Handler
```php
final readonly class {Name}Handler
{
public function __construct(
private {ReadModelInterface} $readModel
) {}
public function __invoke({Name}Query $query): {ResultDTO}
{
$result = $this->readModel->findById($query->id->value);
if ($result === null) {
throw new {NotFoundException}($query->id);
}
return $result;
}
}
```
---
## Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|--------------|---------|----------|
| Side Effects | Handler modifies state | Keep read-only |
| Returning Entities | Leaking domain | Return DTOs only |
| No Validation | Invalid parameters | Validate in constructor |
| Unbounded Lists | Performance issues | Always paginate |
| Missing Read Model | Querying write model | Use dedicated read model |
---
## References
For complete PHP templates and examples, see:
- `references/templates.md` — Query, Handler, DTO, PaginatedResult, ReadModel templates
- `references/examples.md` — GetOrderDetails, ListOrders, OrderDTO examples and testsRelated Skills
acc-create-test-builder
Generates Test Data Builder and Object Mother patterns for PHP 8.5. Creates fluent builders with sensible defaults and factory methods for test data creation.
acc-create-psr18-http-client
Generates PSR-18 HTTP Client implementation for PHP 8.5. Creates ClientInterface with request sending and exception handling. Includes unit tests.
acc-create-psr14-event-dispatcher
Generates PSR-14 Event Dispatcher implementation for PHP 8.5. Creates EventDispatcherInterface, ListenerProviderInterface, and StoppableEventInterface with event propagation. Includes unit tests.
acc-create-entity
Generates DDD Entities for PHP 8.5. Creates identity-based objects with behavior, state transitions, and invariant protection. Includes unit tests.
acc-create-builder
Generates Builder pattern for PHP 8.5. Creates step-by-step object construction with fluent interface and validation. Includes unit tests.
acc-create-value-object
Generates DDD Value Objects for PHP 8.5. Creates immutable, self-validating objects with equality comparison. Includes unit tests.
acc-create-unit-test
Generates PHPUnit unit tests for PHP 8.5. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.
acc-create-test-double
Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.5. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.
acc-create-psr7-http-message
Generates PSR-7 HTTP Message implementations for PHP 8.5. Creates Request, Response, Stream, Uri, and ServerRequest classes with immutability. Includes unit tests.
acc-create-policy
Generates Policy pattern for PHP 8.5. Creates encapsulated business rules for authorization, validation, and domain constraints. Includes unit tests.
acc-create-null-object
Generates Null Object pattern for PHP 8.5. Creates safe default implementations eliminating null checks. Includes unit tests.
acc-create-command
Generates CQRS Commands and Handlers for PHP 8.5. Creates immutable command DTOs with handlers that modify state. Includes unit tests.