create-query
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-query":https://skillpi.com/zh/skills/deepskill-2ef8bd79931063d6b68e89b0d8ea45b731cc51a92854a108e94b04603eba102e。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成 CQRS 查询与处理器:创建只读查询 DTO,并附带一个无副作用、返回数据的查询处理器,包含单元测试。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
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
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 CQRS 查询生成流程,涵盖 Query、Handler、DTO、ReadModel 和单元测试
亮点
- description 清晰准确,明确限定 PHP 8.4 和 CQRS 场景,触发边界清晰
待提升项
-
缺少 When to Use 明确章节 原报告严重程度:轻微
文档未设置独立的 When to Use 章节说明适用场景
改进建议:建议增加 When to Use 章节,明确说明何时使用此 Skill
-
缺少端到端完整示例 原报告严重程度:轻微
仅提供代码模板片段,缺少一个完整的端到端使用示例
改进建议:建议在 examples.md 或主文档中添加一个完整示例,展示从输入到生成文件的完整流程
亮点
- 生成步骤划分清晰,包含文件路径、命名规范、反模式提醒等实用信息
待提升项
-
参数校验与异常处理说明不足 原报告严重程度:轻微
未详细说明如何处理用户输入参数校验及生成代码的异常处理机制
改进建议:建议在文档中补充参数校验规则和异常处理的最佳实践说明
亮点
- 代码生成逻辑自洽,遵循 CQRS 原则,无副作用设计合理
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。