Inferensys

Prompt

Event Sourcing Schema Review Prompt

A practical prompt playbook for using the Event Sourcing Schema Review Prompt in production AI-assisted architecture review workflows.
Developer designing multi-agent workflow on laptop, architecture diagram on screen, casual home office setup with afternoon light.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job, reader, and constraints for reviewing event-sourced aggregate schemas before they reach production.

This prompt is for architects and platform engineers who need a structured, automated first pass at reviewing event-sourced aggregate schemas. The job-to-be-done is catching design flaws—such as incorrect event granularity, missing snapshot strategies, or projection rebuild feasibility gaps—before the schema is committed and events are produced. The ideal user has a draft aggregate schema and a set of event type definitions, and they need a review that goes beyond linting to assess runtime behavior, evolution risk, and operational recoverability. You should use this prompt when a new aggregate is being designed, when an existing aggregate is undergoing a significant schema change, or as a gate in a CI/CD pipeline for event schema registries.

Do not use this prompt for reviewing individual event schemas in isolation (use the Event Schema Design Review Prompt Template instead), for runtime debugging of event processing failures, or for systems that do not use event sourcing. The prompt assumes the reader understands Domain-Driven Design aggregates, event versioning, and projection rebuilds. It is not a tutorial. The required inputs are the aggregate definition, its event type taxonomy, the current snapshot strategy, and any known projection dependencies. The output is a structured review covering event granularity, snapshot strategy, event type taxonomy, and projection rebuild feasibility, with explicit failure mode checks for event splitting and type explosion. Because aggregate schema decisions have long-lived production consequences—incorrect granularity can force expensive event migrations and type explosion can degrade projection performance—this prompt includes mandatory eval criteria and recommends human review for any findings flagged as high risk before the schema is finalized.

After running the review, treat the output as a design discussion artifact, not a final verdict. Validate each finding against your system's specific latency, storage, and consistency requirements. Pay particular attention to the failure mode checks: event splitting (where a single business event is incorrectly decomposed into multiple fine-grained events, breaking atomicity) and type explosion (where unbounded event type proliferation makes projection code unmaintainable). If the prompt flags either of these, schedule a synchronous design review with the team before proceeding. For high-risk domains such as finance or healthcare, always require human sign-off on the review output before schema registration.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Event Sourcing Schema Review Prompt works, where it fails, and what inputs it assumes.

01

Good Fit: Aggregate Boundary Review

Use when: reviewing event-sourced aggregate schemas before implementation. The prompt excels at checking event granularity, snapshot strategy, and projection rebuild feasibility. Guardrail: Provide the full aggregate definition and all event types; partial schemas produce incomplete reviews.

02

Good Fit: Event Taxonomy Audit

Use when: auditing event type taxonomies for consistency and avoiding type explosion. The prompt identifies overlapping event types, missing event variants, and classification gaps. Guardrail: Include domain context and business process descriptions so the model can distinguish intentional variation from accidental duplication.

03

Bad Fit: Runtime Performance Tuning

Avoid when: diagnosing production performance issues in an event store. This prompt reviews schema design, not query patterns, indexing strategies, or storage engine behavior. Guardrail: Route performance questions to database and infrastructure review prompts instead.

04

Bad Fit: Code-Level Implementation Review

Avoid when: reviewing handler code, projection logic, or serialization implementation. The prompt operates at the schema and strategy level, not the code level. Guardrail: Pair this prompt with a code review prompt for implementation details; schema review alone won't catch handler bugs.

05

Required Inputs

What you must provide: aggregate definitions, event type schemas with field descriptions, snapshot policies, projection requirements, and domain context. Guardrail: Missing event type definitions cause the model to hallucinate plausible but incorrect schema gaps. Always include complete event payloads, not just event names.

06

Operational Risk: Over-Engineering Detection

What to watch: the prompt may recommend splitting events too aggressively, creating unnecessary complexity for simple aggregates. Guardrail: Add a constraint in the prompt to flag when the current granularity is already appropriate and only recommend changes with clear operational benefit.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for reviewing event-sourced aggregate schemas, with placeholders for your specific domain context and constraints.

This prompt template is designed to be copied directly into your AI harness or development environment. It uses square-bracket placeholders that you must replace with your specific domain context, event schemas, and review constraints. The template is structured to produce a consistent, actionable schema review that covers event granularity, snapshot strategy, event type taxonomy, and projection rebuild feasibility. Before using this prompt in production, ensure you have defined your evaluation criteria and failure mode checks as described in the implementation harness section.

text
You are an expert software architect specializing in event sourcing and domain-driven design. Your task is to review an event-sourced aggregate schema for correctness, evolvability, and operational feasibility.

## INPUT

### Aggregate Context
- Aggregate Name: [AGGREGATE_NAME]
- Bounded Context: [BOUNDED_CONTEXT]
- Business Domain: [BUSINESS_DOMAIN]
- Aggregate Purpose: [AGGREGATE_PURPOSE_DESCRIPTION]

### Event Schema
[EVENT_SCHEMA_DEFINITIONS]

### Snapshot Configuration
- Snapshot Frequency: [SNAPSHOT_FREQUENCY]
- Snapshot Strategy: [SNAPSHOT_STRATEGY]
- Current Snapshot Schema: [SNAPSHOT_SCHEMA]

### Projection Requirements
[PROJECTION_REQUIREMENTS]

## CONSTRAINTS
- [CONSTRAINT_1]
- [CONSTRAINT_2]
- [CONSTRAINT_3]

## OUTPUT_SCHEMA
Produce a structured review with the following sections. Use the exact field names and types specified.

{
  "review_summary": {
    "overall_assessment": "string (PASS | PASS_WITH_RECOMMENDATIONS | FAIL)",
    "critical_issues_count": "integer",
    "recommendations_count": "integer"
  },
  "event_granularity_analysis": {
    "assessment": "string",
    "issues": [
      {
        "event_name": "string",
        "issue_type": "string (TOO_COARSE | TOO_FINE | AMBIGUOUS_BOUNDARY)",
        "description": "string",
        "recommendation": "string"
      }
    ],
    "suggested_splits": [
      {
        "original_event": "string",
        "proposed_events": ["string"],
        "rationale": "string"
      }
    ],
    "suggested_merges": [
      {
        "original_events": ["string"],
        "proposed_event": "string",
        "rationale": "string"
      }
    ]
  },
  "event_type_taxonomy_review": {
    "assessment": "string",
    "taxonomy_gaps": ["string"],
    "naming_consistency_issues": [
      {
        "event_name": "string",
        "issue": "string",
        "suggested_name": "string"
      }
    ],
    "missing_event_types": [
      {
        "event_type": "string",
        "rationale": "string",
        "suggested_schema": "object"
      }
    ],
    "type_explosion_risk": "string (LOW | MEDIUM | HIGH)",
    "type_explosion_mitigation": "string"
  },
  "snapshot_strategy_review": {
    "assessment": "string",
    "frequency_appropriateness": "string (APPROPRIATE | TOO_FREQUENT | TOO_INFREQUENT)",
    "schema_alignment_issues": ["string"],
    "performance_considerations": "string",
    "recommended_changes": ["string"]
  },
  "projection_rebuild_feasibility": {
    "assessment": "string",
    "rebuild_complexity": "string (LOW | MEDIUM | HIGH | NOT_FEASIBLE)",
    "blocking_factors": ["string"],
    "estimated_rebuild_concerns": "string",
    "recommended_improvements": ["string"]
  },
  "failure_mode_analysis": {
    "event_splitting_risks": [
      {
        "scenario": "string",
        "impact": "string",
        "detection_strategy": "string",
        "mitigation": "string"
      }
    ],
    "type_explosion_risks": [
      {
        "scenario": "string",
        "impact": "string",
        "detection_strategy": "string",
        "mitigation": "string"
      }
    ],
    "schema_evolution_risks": [
      {
        "change_type": "string",
        "breaking_change": "boolean",
        "impact": "string",
        "migration_strategy": "string"
      }
    ]
  },
  "action_items": [
    {
      "priority": "string (CRITICAL | HIGH | MEDIUM | LOW)",
      "category": "string",
      "description": "string",
      "effort_estimate": "string",
      "blocking_deployment": "boolean"
    }
  ]
}

## INSTRUCTIONS
1. Analyze each event in the schema for appropriate granularity. Events should represent meaningful business state changes, not CRUD operations or technical implementation details.
2. Review the event type taxonomy for completeness, consistency, and risk of type explosion. Flag any events that should be split, merged, or renamed.
3. Evaluate the snapshot strategy against the aggregate's event volume, performance requirements, and rebuild needs.
4. Assess whether all required projections can be rebuilt from the event stream. Identify any missing event data that would block rebuilds.
5. Perform a failure mode analysis covering event splitting risks, type explosion scenarios, and schema evolution breaking changes.
6. For every issue identified, provide a concrete, actionable recommendation.
7. If the schema has critical flaws that would cause data loss or unrecoverable state, mark the overall assessment as FAIL.

## RISK_LEVEL
[RISK_LEVEL]

If RISK_LEVEL is HIGH, flag any recommendation that could cause data loss or production incidents and require explicit human approval before implementation.

To adapt this template for your specific use case, replace each square-bracket placeholder with your actual domain data. The [EVENT_SCHEMA_DEFINITIONS] placeholder should contain your complete event schema in a structured format such as JSON Schema, Avro, or Protobuf definitions. The [PROJECTION_REQUIREMENTS] placeholder should describe each read model or projection that must be rebuildable from the event stream, including the fields required and any performance constraints. The [CONSTRAINT_1] through [CONSTRAINT_3] placeholders allow you to inject domain-specific rules such as regulatory requirements, latency budgets, or team capability constraints. The [RISK_LEVEL] placeholder should be set to LOW, MEDIUM, or HIGH based on the criticality of the system under review. For high-risk systems such as financial ledgers or healthcare records, the prompt will enforce additional caution in its recommendations and require explicit human approval gates. After adapting the template, validate the output against the evaluation criteria defined in your test harness before integrating it into your review pipeline.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Provide these variables to ensure the review covers event granularity, snapshot strategy, event type taxonomy, and projection rebuild feasibility.

PlaceholderPurposeExampleValidation Notes

[AGGREGATE_DEFINITION]

The full definition of the aggregate root, including its state, invariants, and business rules.

OrderAggregate { id, status, lineItems[], totalAmount, customerId } with invariant: totalAmount must equal sum of lineItem totals.

Must be a non-empty string describing state fields and at least one business invariant. Parse check: confirm the definition includes both state and rules.

[EVENT_SCHEMA_LIST]

A list of all event types currently emitted by or applied to the aggregate, with their full payload schemas.

OrderPlaced { orderId, customerId, totalAmount, timestamp }, OrderLineItemAdded { orderId, lineItemId, quantity, price }

Must be a valid JSON array of objects, each with a name and a properties map. Schema check: every event must have a unique name and a defined payload.

[SNAPSHOT_STRATEGY]

The current or proposed snapshot strategy, including frequency, trigger conditions, and storage mechanism.

Snapshot every 50 events or on aggregate state change. Store in S3 with event version pointer.

Must be a non-empty string. Validation check: confirm the strategy specifies a frequency or trigger condition. Null allowed if no strategy exists.

[PROJECTION_DEFINITIONS]

A list of read models or projections built from the event stream, including their purpose and rebuild requirements.

OrderSummaryProjection { orderId, status, itemCount, totalAmount } rebuilt nightly. OrderHistoryProjection rebuilt on demand.

Must be a valid JSON array of objects, each with a name, purpose, and rebuild trigger. Schema check: confirm each projection has a defined rebuild method.

[EVENT_TYPE_TAXONOMY]

The classification scheme for event types, such as domain events, integration events, and notification events.

Domain: OrderPlaced, OrderCancelled. Integration: OrderShipped. Notification: OrderConfirmationEmailSent.

Must be a non-empty string or JSON object mapping categories to event names. Parse check: every event in [EVENT_SCHEMA_LIST] should appear in exactly one category.

[BUSINESS_CONSTRAINTS]

Any business rules or regulatory requirements that constrain event design, retention, or processing.

GDPR right-to-erasure requires ability to delete PII from event streams. PCI-DSS prohibits storing full card numbers in events.

Must be a non-empty string listing constraints. Validation check: each constraint should reference a specific rule or regulation. Null allowed if no constraints apply.

[FAILURE_MODE_LOG]

A log of past production incidents or known failure modes related to event sourcing in this system.

Duplicate OrderPlaced events caused double-fulfillment in Q3. Snapshot rebuild took 14 hours during December peak.

Must be a valid JSON array of incident descriptions. Schema check: each entry should have a description and a date or impact summary. Null allowed if no incidents recorded.

[REVIEW_SCOPE]

The specific areas of the event-sourced schema to focus on, such as event splitting, type explosion, or snapshot efficiency.

Focus on event granularity for Order aggregate and type explosion risk from 47 event variants introduced in last 6 months.

Must be a non-empty string. Validation check: confirm the scope references at least one specific review dimension from the prompt's coverage areas.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Event Sourcing Schema Review Prompt into an architecture review pipeline with validation, retry, and human approval gates.

This prompt is designed to operate as a gated step in a schema review pipeline, not as a standalone chatbot interaction. The harness wraps the LLM call with pre-processing to extract and normalize the event schema from design documents, post-processing to validate the output against a strict JSON schema, and conditional routing to human review when confidence is low or critical failure modes are flagged. The goal is to produce a machine-readable review artifact that downstream tooling can consume for trend analysis, regression checks, and audit evidence.

Input assembly begins by extracting the event schema from the user's design document. Use a lightweight extraction step (a smaller, cheaper model or a deterministic parser) to isolate the schema definition, event type taxonomy, snapshot configuration, and projection specifications. Feed these into the prompt's [EVENT_SCHEMA] and [CONTEXT] placeholders. Set [REVIEW_DEPTH] to comprehensive for new schemas or incremental for schema changes. The [OUTPUT_SCHEMA] placeholder should contain the expected JSON structure: an object with review_summary, event_granularity_assessment, snapshot_strategy_review, event_type_taxonomy_review, projection_rebuild_feasibility, failure_mode_checks (including event splitting and type explosion flags), and a risk_level enum of low, medium, or high.

Validation and retry logic is critical because malformed output breaks downstream automation. After the LLM responds, validate the JSON against the expected schema. If validation fails, retry up to two times with the error message appended to the prompt as a correction hint. If the output still fails validation, route to a human reviewer with the raw output and validation errors. For successful parses, check the risk_level field: high always triggers human review; medium triggers review if any failure_mode_checks flag is true; low can auto-approve unless the projection_rebuild_feasibility field indicates rebuild time exceeds a configurable threshold (e.g., >4 hours). Log every review result with the schema version, timestamp, model used, retry count, and final disposition for audit trails.

Model choice and tool integration depend on your risk tolerance. Use a capable reasoning model (GPT-4o, Claude 3.5 Sonnet, or equivalent) for the review itself. For the extraction step, a smaller model like GPT-4o-mini or Claude Haiku is sufficient. If your event schemas are stored in a schema registry (e.g., Apicurio, Confluent), integrate a tool that fetches the current schema version and any prior review artifacts as additional context. This enables the prompt to perform change-impact analysis by comparing the new schema against the prior version. For teams using event sourcing frameworks like Marten or Axon, add a post-review tool that writes the review artifact back to the schema registry as metadata, creating a permanent link between the schema and its architectural assessment.

Human approval gates should be implemented as a review queue, not an email. When the harness routes a review for human approval, present the reviewer with the original schema, the LLM's structured review, the specific failure flags that triggered escalation, and a one-click approve/reject interface. Rejection should require a reason, which feeds back into the prompt as a correction example for future runs. This closed loop improves the prompt's accuracy over time without manual prompt engineering. Avoid deploying this harness without the human gate for schemas that affect financial events, compliance data, or projections that serve customer-facing read models—silent schema errors in event-sourced systems can corrupt historical state in ways that are expensive to repair.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the Event Sourcing Schema Review output. Use this contract to parse and validate the model response before accepting it into your review pipeline.

Field or ElementType or FormatRequiredValidation Rule

review_summary

string (max 500 chars)

Must be present and non-empty. Reject if null or whitespace-only.

event_type_taxonomy

array of objects

Each object must contain 'event_type' (string), 'category' (enum: Command, Domain, Integration, Projection), and 'granularity_assessment' (string). Array length must be >= 1.

snapshot_strategy

object

Must contain 'recommended_interval' (integer >= 1), 'rationale' (string), and 'projection_rebuild_feasibility' (enum: Feasible, Partial, Infeasible). Reject if any field is missing.

event_splitting_risks

array of strings

If present, each string must be non-empty. Null allowed. If array is empty, validate as intentional omission.

type_explosion_warnings

array of objects

Each object must contain 'event_type' (string) and 'risk_level' (enum: Low, Medium, High). Reject if risk_level is outside allowed enum values.

schema_evolution_notes

string

Must be present. If model cannot assess, field must contain explicit 'INSUFFICIENT_CONTEXT' string. Reject if field is missing entirely.

confidence_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive. Reject if out of range or non-numeric. Trigger human review if below 0.7.

review_timestamp

ISO 8601 string

Must parse as valid UTC datetime. Reject if unparseable or missing timezone offset.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first in event sourcing schema reviews and how to guard against it.

01

Event Type Explosion

What to watch: The model suggests a unique event type for every minor state change (e.g., NameUpdated, EmailUpdated, PhoneUpdated), leading to an unmanageable taxonomy. Guardrail: Constrain the prompt with a taxonomy rule: events must represent business decisions, not property setters. Add a post-generation check that flags any event name containing a CRUD verb.

02

Missing Snapshot Strategy

What to watch: The review focuses entirely on event granularity and ignores the read/rebuild side, failing to flag aggregates without a defined snapshot interval. Guardrail: Add a required [SNAPSHOT_STRATEGY] input field. The eval harness must fail the review if the output does not explicitly comment on snapshot feasibility and recommended frequency.

03

Incorrect Event Splitting

What to watch: The model recommends splitting a single business intent (e.g., OrderPlaced) into multiple technical steps, breaking atomicity and complicating projection rebuilds. Guardrail: Include a negative example in the prompt showing a bad split. Add an eval check that verifies all events in the output can be traced back to a single user or system intent.

04

Ignoring Schema Evolution

What to watch: The review approves a schema without checking for backward compatibility, missing the risk that adding a required field will break existing consumers. Guardrail: Add a [COMPATIBILITY_RULES] constraint (e.g., no new required fields, no type narrowing). The test suite must include a case with a breaking change and expect a rejection.

05

Projection Rebuild Blindness

What to watch: The review validates the event structure but fails to simulate whether a projection can be rebuilt from scratch using only the event stream. Guardrail: Include a [PROJECTION_REBUILD_CHECK] step in the prompt instructions. The eval must provide a sample projection and verify the output confirms or denies rebuild feasibility.

06

Ambiguous Event Naming

What to watch: The model approves vague event names like StatusChanged or DataUpdated that carry no domain meaning, making the event log useless for debugging. Guardrail: Enforce a naming convention in the prompt (e.g., [Noun][VerbPastTense]). Use a simple regex validator in the harness to reject any event name containing

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the Event Sourcing Schema Review output before sharing it with the architecture team. Each criterion targets a known failure mode of schema review prompts.

CriterionPass StandardFailure SignalTest Method

Event Granularity Assessment

Review identifies at least one event that is too coarse (carries excessive state) or too fine (CRUD-level) with specific reasoning.

Output describes events only as 'well-designed' or 'appropriate' without naming a granularity concern.

Parse output for granularity section; assert presence of at least one named event and a specific size concern.

Snapshot Strategy Feasibility

Review evaluates snapshot frequency against rebuild time and storage cost, citing the aggregate's event volume.

Output recommends a snapshot interval without referencing event volume, rebuild time, or storage trade-offs.

Check for numeric event volume estimate and explicit trade-off language in the snapshot section.

Event Type Taxonomy Completeness

Review classifies events into at least two categories (e.g., domain, state-changed, migration) and flags missing categories.

Output lists event types without classification or fails to note when a category is absent from the schema.

Scan for category labels; assert at least two categories are named and missing categories are flagged.

Projection Rebuild Feasibility

Review assesses whether all projections can be rebuilt from the event log alone, noting any external data dependencies.

Output assumes rebuild feasibility without checking for external service calls or non-deterministic data sources.

Search output for 'rebuild' or 'projection'; assert external dependency check is present.

Event Splitting Failure Mode Check

Review identifies at least one event that risks semantic overloading and suggests a split with rationale.

Output does not mention event splitting as a risk or suggests splits without semantic justification.

Search for 'split' or 'overloaded'; assert a specific event is named and a semantic boundary is proposed.

Type Explosion Failure Mode Check

Review warns against unbounded event type proliferation and proposes a taxonomy rule or consolidation strategy.

Output lists many event types without addressing long-term taxonomy maintenance or explosion risk.

Search for 'explosion' or 'proliferation'; assert a containment strategy or governance rule is suggested.

Source Grounding

Every finding references a specific event name, aggregate name, or schema field from the input.

Findings make generic claims about 'the schema' without citing a specific element from the provided input.

Spot-check three findings; assert each one names a concrete element from [INPUT_SCHEMA].

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single aggregate and a handful of events. Remove snapshot strategy and projection rebuild sections. Focus on event type taxonomy and granularity checks only.

code
Review this event-sourced aggregate schema for [AGGREGATE_NAME]:

Events:
[PASTE_EVENT_LIST]

Check: event granularity, type taxonomy, missing events.
Ignore: snapshot strategy, projection rebuild.

Watch for

  • Skipping event splitting checks on small event sets
  • Accepting CRUD-style events without domain meaning
  • Missing the "event type explosion" signal when only 3-4 events exist
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.