create-query
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-query" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-2ef8bd79931063d6b68e89b0d8ea45b731cc51a92854a108e94b04603eba102e. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Generate a CQRS query and handler for PHP 8.4: create a read-only query DTO and a side-effect-free handler that returns data, including unit tests.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates CQRS Queries and Handlers for PHP 8.4. Creates read-only query DTOs with handlers that return data without side effects. Includes unit tests.
- Testing
- Not tested
Browse files
Frontmatter
name: create-query
description: Generates CQRS Queries and Handlers for PHP 8.4. Creates read-only query DTOs with handlers that return data without side effects. Includes unit tests.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/
{Name}Query.php— Immutable query DTO with parameters
Step 2: Generate Handler
Path: src/Application/{BoundedContext}/Handler/
{Name}Handler.php— Read model consumer
Step 3: Generate DTOs
Path: src/Application/{BoundedContext}/DTO/
{Name}DTO.php— Result data structurePaginatedResultDTO.php— For list queries (optional)
Step 4: Generate Read Model Interface
Path: src/Application/{BoundedContext}/ReadModel/
{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
final readonly class {Name}Query
{
public function __construct(
public {IdType} $id
) {}
}
Query with Pagination
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
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 templatesreferences/examples.md— GetOrderDetails, ListOrders, OrderDTO examples and tests
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供完整的 CQRS 查询生成流程,涵盖 Query、Handler、DTO、ReadModel 和单元测试
Highlights
- description 清晰准确,明确限定 PHP 8.4 和 CQRS 场景,触发边界清晰
Areas to improve
-
缺少 When to Use 明确章节 Reported severity: Minor
文档未设置独立的 When to Use 章节说明适用场景
Recommendation: 建议增加 When to Use 章节,明确说明何时使用此 Skill
-
缺少端到端完整示例 Reported severity: Minor
仅提供代码模板片段,缺少一个完整的端到端使用示例
Recommendation: 建议在 examples.md 或主文档中添加一个完整示例,展示从输入到生成文件的完整流程
Highlights
- 生成步骤划分清晰,包含文件路径、命名规范、反模式提醒等实用信息
Areas to improve
-
参数校验与异常处理说明不足 Reported severity: Minor
未详细说明如何处理用户输入参数校验及生成代码的异常处理机制
Recommendation: 建议在文档中补充参数校验规则和异常处理的最佳实践说明
Highlights
- 代码生成逻辑自洽,遵循 CQRS 原则,无副作用设计合理
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.