pekko-cqrs-es-implementation

Implements CQRS and Event Sourcing patterns with Apache Pekko and Scala 3.

Updated Jun 23, 2026
One-click install
npx skills add https://github.com/j5ik2o/marp-ai-base --skill pekko-cqrs-es-implementation-j5ik2o
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pekko-cqrs-es-implementation
Source: https://github.com/j5ik2o/marp-ai-base/tree/main/.agents/skills/pekko-cqrs-es-implementation
Command: npx skills add https://github.com/j5ik2o/marp-ai-base --skill pekko-cqrs-es-implementation-j5ik2o

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building a CQRS/Event Sourcing system with Apache Pekko and Scala involves many non-obvious decisions: how to separate domain models from actors, how to persist events safely, how to version event schemas, and how to wire read models. This Skill provides concrete, production-tested implementation patterns so you avoid architectural mistakes. ## Core Features & Use Cases - Aggregate Actor Patterns: Implement aggregate actors using PersistenceEffector with state-separated handler functions, type-safe state transitions via enums, and supervision strategies. - Pure Domain Modeling: Design framework-independent domain models where state changes return Either[Error, (NewState, Event)], keeping Pekko out of business logic. - Event & Serialization Design: Define versioned events (e.g., Renamed_V1) with Protocol Buffers serialization, snapshot strategies, and ZIO-based use case layers. - Use Case: When asked to implement a user account aggregate with create/rename/delete commands in a Scala 3 + Pekko CQRS system, this Skill supplies the full layered structure from domain model to GraphQL-facing use case. ## Quick Start Ask the assistant to implement a Pekko aggregate actor with event sourcing for a Scala 3 CQRS application, for example a user account with rename and delete commands.

Frequently Asked Questions about pekko-cqrs-es-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement an aggregate actor with Apache Pekko PersistenceEffector?

Define a state enum (NotCreated, Created, Deleted), separate handler functions per state, and use PersistenceEffector.fromConfig with an applyEvent function. Persist events via effector.persistEvent before sending replies, and delegate all business logic to the pure domain model.

How should domain models be separated from actors in event sourcing?

Keep domain models as pure Scala code with zero Pekko imports. State-changing methods return Either[Error, (NewState, Event)], and the actor only handles persistence and lifecycle, delegating all business rules to the domain model.

Can I use this CQRS pattern with Java or other languages?

No, these patterns are specific to Scala 3 with Apache Pekko. The implementation relies on Scala enums, Either types, ZIO effects, and Pekko Typed actors, so other languages require different frameworks and idioms.

How do I version events in a Pekko event sourcing system?

Name events in past tense with a version suffix like Renamed_V1, and serialize them with Protocol Buffers where field numbers ensure backward compatibility. When schemas change, add a new event version rather than modifying existing ones.

What snapshot strategy should I use for Pekko persistence?

A common configuration saves a snapshot every 1000 events and retains the latest 2 snapshots. This balances actor recovery startup time against storage costs while keeping a fallback snapshot for recovery safety.

When should I not use CQRS with Event Sourcing?

Avoid CQRS/ES for simple CRUD applications without complex business rules or audit requirements. The pattern adds operational complexity with eventual consistency, separate data stores, and event schema management that simple domains do not justify.