typed-service-contracts — typed-service-contracts for complex validation typed-service-contracts, stitch-mcp, community, typed-service-contracts for complex validation, ide skills, typed-service-contracts install, Claude Code, Cursor, Windsurf

v1.0.0
GitHub

About this Skill

Ideal for Architecture Agents requiring rigorous Vertical Slice Architecture and Design by Contract principles typed-service-contracts is a skill that defines a Vertical Slice Architecture backed by Design by Contract principles, ensuring strict boundaries and robust error handling in application logic.

Features

Implements Vertical Slice Architecture for modular application design
Applies Design by Contract principles for rigorous input parsing and error handling
Treats application logic as rigorously defined Units of Work with parsed inputs
Utilizes the Result Pattern for error handling, treating errors as values rather than exceptions
Enforces strict boundaries between user input and system logic for secure and reliable applications
Supports complex validation for robust and fault-tolerant systems

# Core Topics

davideast davideast
[0]
[0]
Updated: 3/8/2026

Agent Capability Analysis

The typed-service-contracts skill by davideast is an open-source community AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for typed-service-contracts for complex validation, typed-service-contracts install.

Ideal Agent Persona

Ideal for Architecture Agents requiring rigorous Vertical Slice Architecture and Design by Contract principles

Core Value

Empowers agents to implement robust application logic as Units of Work, utilizing the Result Pattern for error handling and strict input parsing, making it perfect for building robust CLIs, libraries, and complex validation systems with Design by Contract principles

Capabilities Granted for typed-service-contracts

Building robust Command-Line Interfaces with strict input validation
Implementing complex validation systems with Vertical Slice Architecture
Developing libraries with rigorously defined Units of Work

! Prerequisites & Limits

  • Requires strict adherence to Design by Contract principles
  • May add complexity to simple applications
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

typed-service-contracts

Install typed-service-contracts, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

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.
  • Interface: The capability definition (e.g., interface ConfigureSpec).

2. The Handler (handler.ts)

The "Implementation" or "Adapter". It defines the How. It must:

  • Implement the Interface defined in the Spec.
  • Be an "Impure" class that handles side effects (File System, API calls).
  • NEVER throw exceptions. It must catch internal errors and map them to the Result type.

How to use it

Step 1: Define the Contract (spec.ts)

Follow this template to define the boundaries.

typescript
1import { z } from 'zod'; 2 3// 1. VALIDATION HELPERS (Reusable Refinements) 4export const SafePathSchema = z.string() 5 .min(1) 6 .refine(p => !p.includes('..'), "No traversal allowed"); 7 8// 2. INPUT (The Command) - "Parse, don't validate" 9export const MyTaskInputSchema = z.object({ 10 path: SafePathSchema, 11 force: z.boolean().default(false), 12}); 13export type MyTaskInput = z.infer<typeof MyTaskInputSchema>; 14 15// 3. ERROR CODES (Exhaustive) 16export const MyTaskErrorCode = z.enum([ 17 'FILE_NOT_FOUND', 18 'PERMISSION_DENIED', 19 'UNKNOWN_ERROR' 20]); 21 22// 4. RESULT (The Monad) 23export const MyTaskSuccess = z.object({ 24 success: z.literal(true), 25 data: z.string(), // The output payload 26}); 27 28export const MyTaskFailure = z.object({ 29 success: z.literal(false), 30 error: z.object({ 31 code: MyTaskErrorCode, 32 message: z.string(), 33 suggestion: z.string().optional(), 34 recoverable: z.boolean(), 35 }) 36}); 37 38export type MyTaskResult = 39 | z.infer<typeof MyTaskSuccess> 40 | z.infer<typeof MyTaskFailure>; 41 42// 5. INTERFACE (The Capability) 43export interface MyTaskSpec { 44 execute(input: MyTaskInput): Promise<MyTaskResult>; 45} 46

Step 2: Implement the Handler (handler.ts)

Follow this template to implement the logic.

typescript
1import { MyTaskSpec, MyTaskInput, MyTaskResult } from './spec.js'; 2import * as fs from 'fs'; 3 4export class MyTaskHandler implements MyTaskSpec { 5 async execute(input: MyTaskInput): Promise<MyTaskResult> { 6 try { 7 // 1. Business Logic 8 if (!fs.existsSync(input.path)) { 9 // 2. Explicit Error Return (No Throwing) 10 return { 11 success: false, 12 error: { 13 code: 'FILE_NOT_FOUND', 14 message: `Path does not exist: ${input.path}`, 15 recoverable: true 16 } 17 }; 18 } 19 20 // 3. Success Return 21 return { 22 success: true, 23 data: 'Operation complete' 24 }; 25 26 } catch (error) { 27 // 4. Safety Net: Catch unknown runtime errors 28 return { 29 success: false, 30 error: { 31 code: 'UNKNOWN_ERROR', 32 message: error instanceof Error ? error.message : String(error), 33 recoverable: false 34 } 35 }; 36 } 37 } 38} 39

Step 3: Testing Strategy

Do not write monolithic tests. Split them into Contract Tests and Logic Tests.

A. Contract Tests (Schema)

Test the Bouncer. Ensure invalid data is rejected before it reaches the handler.

  • Focus: Edge cases, validation rules, Zod refinements.
  • Style: Data-driven (Table tests).
typescript
1// spec.test.ts 2import { MyTaskInputSchema } from './spec'; 3 4const invalidCases = [ 5 { val: '../etc/passwd', err: 'No traversal allowed' }, 6 { val: '', err: 'min(1)' }, 7]; 8 9test.each(invalidCases)('validates paths', ({ val, err }) => { 10 const result = MyTaskInputSchema.safeParse({ path: val }); 11 expect(result.success).toBe(false); 12}); 13

B. Logic Tests (Handler)

Test the Chef. Mock external dependencies (fs, network) and assert the Result Object.

  • Focus: Business logic flow, error mapping, success states.
  • Style: Mocked unit tests or Scenario Runners.
typescript
1// handler.test.ts 2import { MyTaskHandler } from './handler'; 3import { vi } from 'vitest'; // or jest 4 5test('returns FILE_NOT_FOUND if path missing', async () => { 6 // MOCK 7 vi.mocked(fs.existsSync).mockReturnValue(false); 8 9 // EXECUTE 10 const handler = new MyTaskHandler(); 11 const result = await handler.execute({ path: '/fake' }); 12 13 // ASSERT (Check the Result Object) 14 expect(result.success).toBe(false); 15 if (!result.success) { 16 expect(result.error.code).toBe('FILE_NOT_FOUND'); 17 } 18}); 19

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is typed-service-contracts?

Ideal for Architecture Agents requiring rigorous Vertical Slice Architecture and Design by Contract principles typed-service-contracts is a skill that defines a Vertical Slice Architecture backed by Design by Contract principles, ensuring strict boundaries and robust error handling in application logic.

How do I install typed-service-contracts?

Run the command: npx killer-skills add davideast/stitch-mcp/typed-service-contracts. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for typed-service-contracts?

Key use cases include: Building robust Command-Line Interfaces with strict input validation, Implementing complex validation systems with Vertical Slice Architecture, Developing libraries with rigorously defined Units of Work.

Which IDEs are compatible with typed-service-contracts?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for typed-service-contracts?

Requires strict adherence to Design by Contract principles. May add complexity to simple applications.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add davideast/stitch-mcp/typed-service-contracts. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use typed-service-contracts immediately in the current project.

Related Skills

Looking for an alternative to typed-service-contracts or another community skill for your workflow? Explore these related open-source skills.

View All

widget-generator

Logo of f
f

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

149.6k
0
AI

flags

Logo of vercel
vercel

flags is a Next.js feature management skill that enables developers to efficiently add or modify framework feature flags, streamlining React application development.

138.4k
0
Browser

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI