npx skills add ...
npx skills add google-labs-code/design.md --skill typed-service-contracts
Architecture standard for building robust, type-safe TypeScript services using the "Spec and Handler" pattern. Use when building CLIs, libraries, or complex business logic.
npx skills add google-labs-code/design.md --skill typed-service-contracts
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.
spec.ts)The "Contract" or "Port". It defines the What. It must contain:
DiscriminatedUnion of Success | Failure.interface ConfigureSpec).handler.ts)The "Implementation" or "Adapter". It defines the How. It must:
Result type.spec.ts)Follow this template to define the boundaries.
handler.ts)Follow this template to implement the logic.
Do not write monolithic tests. Split them into Contract Tests and Logic Tests.
Test the Bouncer. Ensure invalid data is rejected before it reaches the handler.
Test the Chef. Mock external dependencies (fs, network) and assert the Result Object.