Skip to content
Back to skills

Orpc Define Contract

ASecurity

Define a contract for contract-first development in oRPC.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 12, 2026
developmentgitapi

Works with

  • cursor
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 12, 2026

npx -y skills add ali-master/skills --skill orpc-define-contract --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Orpc Define Contract?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Orpc Define Contract
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ali-master-orpc-define-contract/badge)](https://www.skillsdirectory.com/skills/ali-master-orpc-define-contract)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: oRPC Define Contract
description: Define a contract for contract-first development in oRPC.
license: MIT
metadata:
  author: Ali Torki
  homepage: https://github.com/ali-master
  version: "1.0.0"
---

# Define Contract

**Contract-first development** is a design pattern where you define the API contract before writing implementation code.

## Installation

```sh
npm install @orpc/contract@latest
```

## Procedure Contract

```ts
import { oc } from '@orpc/contract'
import * as z from 'zod'

export const exampleContract = oc
  .input(z.object({ name: z.string(), age: z.number().int().min(0) }))
  .output(z.object({ id: z.number().int().min(0), name: z.string(), age: z.number().int().min(0) }))
```

## Contract Router

```ts
export const routerContract = {
  example: exampleContract,
  nested: { example: exampleContract },
}
```

## Full Example

```ts
import * as z from 'zod'
import { oc } from '@orpc/contract'

export const PlanetSchema = z.object({
  id: z.number().int().min(1),
  name: z.string(),
  description: z.string().optional(),
})

export const listPlanetContract = oc
  .input(z.object({
    limit: z.number().int().min(1).max(100).optional(),
    cursor: z.number().int().min(0).default(0),
  }))
  .output(z.array(PlanetSchema))

export const findPlanetContract = oc
  .input(PlanetSchema.pick({ id: true }))
  .output(PlanetSchema)

export const createPlanetContract = oc
  .input(PlanetSchema.omit({ id: true }))
  .output(PlanetSchema)

export const contract = {
  planet: {
    list: listPlanetContract,
    find: findPlanetContract,
    create: createPlanetContract,
  },
}
```

## Utilities

```ts
import type { InferContractRouterInputs, InferContractRouterOutputs } from '@orpc/contract'

export type Inputs = InferContractRouterInputs<typeof contract>
export type Outputs = InferContractRouterOutputs<typeof contract>

type FindPlanetInput = Inputs['planet']['find']
type FindPlanetOutput = Outputs['planet']['find']
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.