effect-domain-modeling

Create runtime-validated Effect Schemas from discriminated union types.

22|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-domain-modeling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-domain-modeling
Source: https://github.com/mpsuesser/pi-effect-harness/tree/main/harnesses/effect/skills/effect-domain-modeling
Command: npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-domain-modeling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Domain modeling in TypeScript often devolves into loosely typed objects, fragile discriminated unions, and ad-hoc validation and pattern matching. This skill solves that by guiding you to define runtime-validated, discriminated domain types with first-class constructors, guards, and exhaustive matchers using Effect v4 Schema utilities.

Core Features & Use Cases

  • Schema-tagged ADTs with _tag: Use Schema.TaggedStruct to define discriminated unions cleanly and exhaustively.
  • Validated constructors: Generate type-safe constructors with Schema.decodeSync so invalid input is rejected at runtime.
  • Guards, matching, and utilities: Provide Schema.is-based predicates and Match.typeTags pattern matching for safe branching on variants.
  • Equality, ordering, and equivalence: Prefer deep structural equality via Equal.equals, and add field-based Equivalence when semantics require it.
  • Advanced modeling patterns: Support recursive schemas (Schema.suspend), branded validation constraints (Brand.make), and typeclass instances when appropriate.
  • Documentation and consistency standards: Enforce JSDoc with @category, @since, and runnable @example imports using namespace import style.

Quick Start

Use this skill to create a domain module for a discriminated union entity by defining variants with Schema.TaggedStruct, adding Schema.decodeSync constructors, and generating Schema.is guards plus a Match.typeTags matcher for exhaustive handling of each _tag.

Frequently Asked Questions about effect-domain-modeling

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

FAQPage Schema
How do I create runtime-validated domain models with Effect Schema?

Effect domain modeling uses Schema.TaggedStruct to define discriminated union variants, Schema.decodeSync to generate type-safe constructors that reject invalid runtime input, and Schema.is to provide type guards. This ensures your domain entities are validated at runtime while remaining fully type-safe.

What is the best way to handle exhaustive pattern matching for tagged unions in Effect?

Exhaustive pattern matching for tagged unions in Effect is handled using Match.typeTags. By defining your variants with Schema.TaggedStruct, you can safely branch on each `_tag` value, ensuring all possible domain entity states are covered without falling back to fragile ad-hoc switch statements.

How do I enforce consistent equality and ordering across Effect Schema variants?

Consistent equality and ordering across Effect Schema variants is enforced by preferring deep structural equality via Equal.equals. When specific semantics are required, you can add field-based Equivalence to maintain consistent ordering and equality checks across your domain model versions.

Can I use recursive schemas and branded types for domain modeling in Effect?

Recursive schemas and branded types are fully supported in Effect domain modeling. You can use Schema.suspend to define recursive data structures and Brand.make to apply branded validation constraints, allowing you to model complex ADTs and enforce strict runtime safety rules.

Does Effect Schema require JSDoc annotations for domain modules?

Effect domain modeling enforces documentation consistency by requiring JSDoc annotations. Domain modules should include @category, @since, and runnable @example imports using namespace import style to ensure your tagged variants, constructors, and guards are consistently documented and maintainable.

Why do I need runtime validation for discriminated unions in TypeScript?

Runtime validation for discriminated unions prevents loosely typed objects and fragile data handling. By generating Schema.decodeSync constructors and Schema.is guards, you reject invalid input at runtime, overcoming the limitations of ad-hoc validation and ensuring type safety throughout your domain logic.