orpc-contract-first

Implement oRPC contract-first API patterns in Dify frontend projects.

Updated Mar 13, 2026
One-click install
npx skills add https://github.com/jason23452/dify-open-parent_message_id --skill orpc-contract-first-jason23452
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: orpc-contract-first
Source: https://github.com/jason23452/dify-open-parent_message_id/tree/main/.agents/skills/orpc-contract-first
Command: npx skills add https://github.com/jason23452/dify-open-parent_message_id --skill orpc-contract-first-jason23452

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a standardized approach to implementing oRPC contract-first API patterns, ensuring consistency and maintainability in Dify frontend development.

Core Features & Use Cases

  • Contract as Source of Truth: Enforces defining API contracts in a central location (web/contract/*).
  • Simplified Query Usage: Guides on when to use useQuery with *.queryOptions directly versus extracting helpers or use-* hooks.
  • Mutation Handling: Standardizes mutation implementation, preferring oRPC clients for custom flows.
  • Use Case: When developing a new feature that requires fetching data from a backend API, use this Skill's guidelines to define the contract and consume it efficiently in the frontend, ensuring type safety and clear separation of concerns.

Quick Start

Define your API contract in web/contract/console/{domain}.ts and register it in web/contract/router.ts.

Frequently Asked Questions about orpc-contract-first

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

FAQPage Schema
How do I implement contract-first API patterns with oRPC in a frontend project?

To implement contract-first API patterns with oRPC, you define your API contracts in a central directory like `web/contract/*` and register them in a router file, ensuring the contract serves as the single source of truth for API definitions.

What is the best way to integrate TanStack Query with oRPC contracts?

The best way to integrate TanStack Query with oRPC contracts is by using `useQuery` with `*.queryOptions` directly for standard fetches, or extracting helpers and `use-*` hooks when logic needs to be shared or reused across components.

How should I handle mutations when using an oRPC contract-first approach?

When using an oRPC contract-first approach, you should handle mutations by standardizing the implementation and preferring oRPC clients to manage any custom data flows or specific mutation requirements.

Where do I define API contracts for a new feature in a Dify frontend project?

You define API contracts for a new feature in a Dify frontend project within `web/contract/console/{domain}.ts` and subsequently register the domain contract in `web/contract/router.ts`.

When do I need a contract-first API design with TypeScript?

You need a contract-first API design with TypeScript when developing new features that fetch backend data and require strict type safety, clear separation of concerns, and long-term maintainability across the frontend.

Can I migrate existing service calls to an oRPC contract-first architecture?

Yes, you can migrate existing service calls by redefining the endpoints as contracts in the central `web/contract/*` location and updating the frontend consumption to use the standardized oRPC client and query options.