typed-service-contracts

Define type-safe TypeScript service contracts using Spec and Handler patterns.

Updated Apr 28, 2026
One-click install
npx skills add https://github.com/Lev-it/lev-skills --skill typed-service-contracts-lev-it
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typed-service-contracts
Source: https://github.com/Lev-it/lev-skills/tree/main/.claude/skills/typed-service-contracts
Command: npx skills add https://github.com/Lev-it/lev-skills --skill typed-service-contracts-lev-it

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zod, and includes scripts (resource) components.

What problem does it solve?

This Skill unit offers a structured approach to building TypeScript services, ensuring robustness and type safety through the "Spec and Handler" pattern.

Core Features & Use Cases

  • Type Safety: Utilizes Zod schemas for input and output validation, ensuring data integrity.
  • Error Handling: Implements a Result Pattern for error handling, avoiding exceptions.
  • Separation of Concerns: Separates contract definitions from implementation logic.
  • Use Case: Ideal for creating CLIs, libraries, or complex business logic where strict validation and error handling are crucial.

Quick Start

To define a new service, start by creating a spec.ts file to define the input and output schemas, followed by a handler.ts file to implement the service logic.

Frequently Asked Questions about typed-service-contracts

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

FAQPage Schema
How do I build type-safe TypeScript services with strict input validation?

You can build type-safe TypeScript services by defining Zod schemas for input and output in a spec file, then implementing the logic in a handler file. This enforces data integrity and separates contract definitions from implementation.

What is the Spec and Handler pattern for TypeScript service architecture?

The Spec and Handler pattern separates service architecture into a spec file for defining input and output schemas, and a handler file for implementation logic. This enforces strict separation of concerns and type safety.

How do I handle errors in TypeScript without throwing exceptions?

You can handle errors without throwing exceptions by implementing a Result Pattern within your TypeScript service architecture. This approach avoids exceptions and integrates with Zod schema validation for robust error handling.

Do I need Zod to use the Spec and Handler pattern for service architecture?

Yes, Zod is a required dependency for utilizing this Spec and Handler architecture. It provides the core schema validation needed to ensure type safety and data integrity for both input parsing and output validation.

Can I use this type-safe service architecture for building command line interfaces?

Yes, this service architecture explicitly supports CLI development alongside library development. The Spec and Handler pattern provides the strict input parsing and error handling required for robust command line interfaces.

What is the best way to separate contract definitions from implementation logic in TypeScript?

The best way to separate contracts from logic is using the Spec and Handler pattern, placing Zod schema definitions in a spec file and the service logic in a handler file, ensuring type safety and separation of concerns.