state-schema

Define typed state schemas to validate and route Durable Streams events.

1.7k|64|Updated Dec 4, 2025
One-click install
npx skills add https://github.com/durable-streams/durable-streams --skill state-schema
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-schema
Source: https://github.com/durable-streams/durable-streams/tree/main/packages/state/skills/state-schema
Command: npx skills add https://github.com/durable-streams/durable-streams --skill state-schema

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

State schemas let developers define typed collections over durable streams, ensuring data validation, consistent event types, and reliable change tracking.

Core Features & Use Cases

  • Typed schemas with Zod, Valibot, or custom Standard Schema validators.
  • Helpers to create insert, update, delete, and upsert events with type safety.
  • Transaction ID support for write confirmation and replayability.
  • Validation against duplicate event types and reserved collection names.

Quick Start

Create a state schema for users and messages, then generate an insert event for a new user.

Frequently Asked Questions about state-schema

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

FAQPage Schema
How do I define typed state schemas for durable streaming event validation?

Typed state schemas define structured collections over durable streams to validate event data and route events consistently. They ensure type safety and reliable change tracking in resilient AI applications or collaborative agent systems.

Can I use Zod or Valibot to validate events in a durable stream?

Yes, durable stream state schemas support any Standard Schema validator, including Zod, Valibot, or custom implementations, to enforce type safety for insert, update, delete, and upsert events.

How do I ensure exactly-once delivery when writing events to replayable streams?

State schemas provide transaction-ID support for write confirmation and replayability, ensuring exactly-once delivery of typed events. This mechanism validates against duplicate event types and reserved collection names.

How do I generate type-safe insert and update events for a new user collection?

You can use state schema helpers to create insert, update, delete, and upsert events with full type safety. Define a schema for users and messages, then generate the corresponding typed events.

What are the limitations when using custom Standard Schema validators for state schemas?

Custom Standard Schema validators must align with the state schema's event type validation, which actively rejects duplicate event types and reserved collection names to maintain stream integrity.