typed-service-contracts

Installation
SKILL.md

Typed Service Contracts (Spec & Handler Pattern)

This skill defines a Vertical Slice Architecture backed by Design by Contract (DbC) principles. It treats application logic as rigorously defined Units of Work where inputs are parsed (not just validated) and errors are treated as values (Result Pattern) rather than exceptions.

When to use this skill

  • Building CLIs or Libraries: When you need strict boundaries between user input and system logic.
  • Complex Validation: When inputs require transformation (parsing) before being useful (e.g., ensuring a string is a valid file path).
  • High-Reliability Requirements: When you cannot afford unhandled runtime exceptions and need exhaustive error handling.
  • Testing Focus: When you want to separate data validation tests from business logic tests.

Architecture Components

1. The Spec (spec.ts)

The "Contract" or "Port". It defines the What. It must contain:

  • Input Schema: A Zod schema that parses raw input into a valid DTO.
  • Output Schema: A Zod schema defining the successful data structure.
  • Error Schema: A discriminated union of specific failure modes (not generic errors).
  • Result Type: A DiscriminatedUnion of Success | Failure.
Related skills
Installs
111
GitHub Stars
12.7K
First Seen
Apr 22, 2026