orpc-contract

Design oRPC v2 APIs contract-first with oc, implement, and typed clients.

Updated Feb 27, 2026
One-click install
npx skills add https://github.com/firstaxel/neon --skill orpc-contract-firstaxel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: orpc-contract
Source: https://github.com/firstaxel/neon/tree/main/.agents/skills/orpc-contract
Command: npx skills add https://github.com/firstaxel/neon --skill orpc-contract-firstaxel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Sharing an API shape between separate server and client packages or teams is error-prone when types drift apart. This Skill guides you through oRPC v2 contract-first development, where a single contract defines schemas, errors, and metadata that both sides depend on without importing each other. ## Core Features & Use Cases - Contract Definition: Build procedure and router contracts with oc from @orpc/contract, using Zod, Valibot, ArkType, or any Standard Schema library, with typesafe errors and stacked input/output schemas. - Implementation & Consumption: Implement contracts with implement from @orpc/server and consume them via RPCLink or OpenAPILink with fully typed RouterContractClient clients. - Use Case: You maintain a public API and want to publish a typed SDK to npm. Define the contract once, implement it on your server, minify it with minifyRouterContract, and ship a factory function that returns a fully typed client to consumers. ## Quick Start Ask the AI to define an oRPC contract with oc for a planets API, implement it with implement from @orpc/server, and create a typed client using RPCLink.

Frequently Asked Questions about orpc-contract

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

FAQPage Schema
How do I define an oRPC contract with oc?▼

Import oc from @orpc/contract and chain methods like .input, .output, and .errors to build procedure contracts, then group them in a plain object as a router contract. Always define .output, otherwise clients infer the output as unknown.

How to implement an oRPC contract on the server?▼

Use implement from @orpc/server to turn the contract into an implementer that type-checks every handler, then call .handler on each procedure and assemble them with .router. Declare required context with .$context and attach middleware with .use.

When should I use contract-first vs router-first in oRPC?▼

Use contract-first when server and client are separate packages or teams, when starting from an OpenAPI spec, or when publishing a client to npm. Stay router-first with os when one codebase holds both sides, since a plain router already works as a router contract.

Can I generate an oRPC contract from an OpenAPI spec?▼

Yes, use Hey API's orpc plugin via @hey-api/openapi-ts with compatibilityVersion 2 and a validator like zod. It generates orpc.gen.ts with one procedure contract per operation plus a combined router contract you can implement or consume with OpenAPILink.

Why is my oRPC client output type unknown?▼

The contract procedure is missing an .output schema, so clients infer the output as unknown. Add .output with a Zod, Valibot, or ArkType schema, or use the type utility from @orpc/contract for schema-free typing.

How do I publish a typed oRPC client to npm?▼

Export a factory function that pairs the contract with an RPCLink and returns createORPCClient typed as RouterContractClient. Bundle with tsdown, list @orpc/client and @orpc/contract as dependencies, and minify the contract with minifyRouterContract if it derives from a router.