create-read-model
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-read-model":https://skillpi.com/zh/skills/deepskill-471053455ffe6dda50ae6636471d448c39074cc748914b240d872e4ff0cb22cf。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成读取模型/投影。针对 CQRS 的读取端创建优化查询模型,包含投影与去规范化处理,并附带相应的单元测试示例以验证读取行为。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: create-read-model
description: Generates Read Model/Projection for PHP 8.4. Creates optimized query models for CQRS read side with projections and denormalization. Includes unit tests.Read Model / Projection Generator
Creates Read Model infrastructure for CQRS read side with optimized query models.
When to Use
| Scenario | Example |
|---|---|
| CQRS read side | Separate query models |
| Denormalized views | Dashboard aggregates |
| Complex queries | Multi-entity joins |
| Event-driven updates | Event projections |
Component Characteristics
Read Model
- Optimized for queries
- Denormalized data
- Eventually consistent
- No business logic
Projection
- Builds read models from events
- Handles event streams
- Maintains synchronization
- Idempotent processing
Repository
- Query-focused methods
- Returns read models
- No write operations
Generation Process
Step 1: Generate Domain Read Model
Path: src/Domain/{BoundedContext}/ReadModel/
{Name}ReadModel.php— Immutable read model with fromArray/toArray{Name}ReadModelRepositoryInterface.php— Query-focused repository interface
Step 2: Generate Application Projection
Path: src/Application/{BoundedContext}/Projection/
{Name}ProjectionInterface.php— Projection contract{Name}Projection.php— Event handlers building read model
Step 3: Generate Infrastructure
Path: src/Infrastructure/{BoundedContext}/
Projection/{Name}Store.php— Store for insert/update/upsertReadModel/Doctrine{Name}Repository.php— Repository implementation
Step 4: Generate Tests
{Name}ReadModelTest.php— Read model serialization tests{Name}ProjectionTest.php— Projection event handling tests
File Placement
| Component | Path |
|---|---|
| Read Model | src/Domain/{BoundedContext}/ReadModel/ |
| Repository Interface | src/Domain/{BoundedContext}/ReadModel/ |
| Projection Interface | src/Application/{BoundedContext}/Projection/ |
| Projection | src/Application/{BoundedContext}/Projection/ |
| Store | src/Infrastructure/{BoundedContext}/Projection/ |
| Repository Impl | src/Infrastructure/{BoundedContext}/ReadModel/ |
| Unit Tests | tests/Unit/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Read Model | {Name}ReadModel |
OrderSummaryReadModel |
| Repository Interface | {Name}ReadModelRepositoryInterface |
OrderSummaryReadModelRepositoryInterface |
| Projection Interface | {Name}ProjectionInterface |
OrderSummaryProjectionInterface |
| Projection | {Name}Projection |
OrderSummaryProjection |
| Store | {Name}Store |
OrderSummaryStore |
| Test | {ClassName}Test |
OrderSummaryProjectionTest |
Quick Template Reference
Read Model
final readonly class {Name}ReadModel
{
public function __construct(
public string $id,
// ... denormalized properties
public \DateTimeImmutable $createdAt,
public \DateTimeImmutable $updatedAt
) {}
public static function fromArray(array $data): self;
public function toArray(): array;
}
Projection
final class {Name}Projection implements {Name}ProjectionInterface
{
public function project(DomainEventInterface $event): void
{
match ($event::class) {
OrderCreated::class => $this->whenOrderCreated($event),
OrderShipped::class => $this->whenOrderShipped($event),
default => null,
};
}
public function reset(): void;
public function subscribedEvents(): array;
}
Usage Example
// Query read model
$orders = $orderSummaryRepository->findByCustomerId($customerId);
// Project event
$projection->project($orderCreatedEvent);
// Reset projection for rebuild
$projection->reset();
Database Schema
CREATE TABLE order_summaries (
id VARCHAR(36) PRIMARY KEY,
order_number VARCHAR(50) NOT NULL UNIQUE,
customer_id VARCHAR(36) NOT NULL,
customer_name VARCHAR(255) NOT NULL,
status VARCHAR(50) NOT NULL,
total_cents BIGINT NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
INDEX idx_customer (customer_id),
INDEX idx_status (status)
);
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| Business Logic | Read model has behavior | Keep data-only |
| Write Operations | Modifying read models | Use projections only |
| Non-idempotent | Re-projection breaks data | Idempotent event handling |
| Missing Reset | Can't rebuild | Add reset() method |
| Tight Coupling | Projection depends on domain | Use events only |
References
For complete PHP templates and examples, see:
references/templates.md— Read model, projection, store templatesreferences/examples.md— OrderSummary example and testsreferences/event-sourcing-projections.md— Event replay projections, versioning, checkpoint tracking, async workers
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 为 CQRS 读取端生成优化的查询模型,具有明确的实用价值
- 包含投影和去规范化处理,适用于复杂查询场景
- 提供单元测试,增强代码质量保障
亮点
- 触发词精准完整,覆盖多种变体(CQRS read side、denormalized views、complex queries、event-driven updates)
- 边界清晰,不易与其他 Skill 重叠
亮点
- Phase/步骤清晰(Step 1-4),有出口条件
- 含端到端示例,frontmatter完整
- 单文件≤500行,结构良好
亮点
- 工具来源明确(PHP 8.4),参数正确
- 覆盖主要异常(idempotent processing、reset mechanism)
- 不可逆操作有确认机制(projection reset)
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。