create-read-model

Generate read models/projections for PHP 8.4. Create optimized query models for the read side of CQRS, including projections and denormalization handling, and include unit test examples to validate read behavior.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

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-read-model" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-471053455ffe6dda50ae6636471d448c39074cc748914b240d872e4ff0cb22cf. 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 read models/projections for PHP 8.4. Create optimized query models for the read side of CQRS, including projections and denormalization handling, and include unit test examples to validate read behavior.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Read Model/Projection for PHP 8.4. Creates optimized query models for CQRS read side with projections and denormalization. Includes unit tests.
Audience
| Scenario | Example | |----------|---------| | CQRS read side | Separate query models | | Denormalized views | Dashboard aggregates | | Complex queries | Multi-entity joins | | Event-driven updates | Event projections |
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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/

  1. {Name}ReadModel.php — Immutable read model with fromArray/toArray
  2. {Name}ReadModelRepositoryInterface.php — Query-focused repository interface

Step 2: Generate Application Projection

Path: src/Application/{BoundedContext}/Projection/

  1. {Name}ProjectionInterface.php — Projection contract
  2. {Name}Projection.php — Event handlers building read model

Step 3: Generate Infrastructure

Path: src/Infrastructure/{BoundedContext}/

  1. Projection/{Name}Store.php — Store for insert/update/upsert
  2. ReadModel/Doctrine{Name}Repository.php — Repository implementation

Step 4: Generate Tests

  1. {Name}ReadModelTest.php — Read model serialization tests
  2. {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 templates
  • references/examples.md — OrderSummary example and tests
  • references/event-sourcing-projections.md — Event replay projections, versioning, checkpoint tracking, async workers

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 为 CQRS 读取端生成优化的查询模型,具有明确的实用价值
  • 包含投影和去规范化处理,适用于复杂查询场景
  • 提供单元测试,增强代码质量保障
Trigger Precision95/100

Highlights

  • 触发词精准完整,覆盖多种变体(CQRS read side、denormalized views、complex queries、event-driven updates)
  • 边界清晰,不易与其他 Skill 重叠
Structure and Standards90/100

Highlights

  • Phase/步骤清晰(Step 1-4),有出口条件
  • 含端到端示例,frontmatter完整
  • 单文件≤500行,结构良好
Execution Reliability88/100

Highlights

  • 工具来源明确(PHP 8.4),参数正确
  • 覆盖主要异常(idempotent processing、reset mechanism)
  • 不可逆操作有确认机制(projection reset)
Evidence Verifiability (mean of the first four)90/100

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.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

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.