# typed-service-contracts

> Claude/Codex skill by [@google-labs-code](https://omgskills.com/library/google-labs-code/index.md) · 27k stars · Updated 2026-07-27

Architecture standard for building robust, type-safe TypeScript services using the "Spec and Handler" pattern. Use when building CLIs, libraries, or complex business logic.

## Install

```sh
git clone https://github.com/google-labs-code/design.md /tmp/design.md && ln -s /tmp/design.md/.agents/skills/typed-service-contracts ~/.claude/skills/typed-service-contracts
```

## From README

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 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.

## Links

- HTML page: https://omgskills.com/skills/google-labs-code/design.md/typed-service-contracts/
- GitHub: https://github.com/google-labs-code/design.md
- Author: [@google-labs-code](https://omgskills.com/library/google-labs-code/index.md)

## More from this repo

- [agent-dx-cli-scale](https://omgskills.com/skills/google-labs-code/design.md/agent-dx-cli-scale/index.md) — A scoring scale for evaluating how well a CLI is designed for AI agents, based on the "Rewrite Your CLI for AI Agents"...
   - [@google-labs-code](https://omgskills.com/library/google-labs-code/index.md) · 27k stars
- [ink](https://omgskills.com/skills/google-labs-code/design.md/ink/index.md) — Ink terminal renderer for json-render that turns JSON specs into interactive terminal UIs.
   - [@google-labs-code](https://omgskills.com/library/google-labs-code/index.md) · 27k stars

## More skills by this author

- [enhance-prompt](https://omgskills.com/skills/google-labs-code/stitch-skills/enhance-prompt/index.md) — Transforms vague UI ideas into polished, Stitch-optimized prompts.
   - [@google-labs-code](https://omgskills.com/library/google-labs-code/index.md) · 7.9k stars
