orpc-contract-first

Installation
Summary

Contract-first API patterns for Dify frontend using oRPC with TanStack Query integration.

  • Define contracts in web/contract/* as single source of truth; consume via useQuery(consoleQuery.xxx.queryOptions(...)) at call sites for 1:1 endpoint mappings
  • Use .key() for partial matching in invalidation/refetch, .queryKey() for specific query identity, and .mutationKey() for mutation defaults or status filtering
  • Extract queryOptions helpers only when 3+ call sites share identical options; create use-* hooks only for multi-query orchestration or domain-level derived state
  • Follow input structure { params, query?, body? } in contracts; omit .input(...) for GET endpoints without input; group router nesting by API prefix
SKILL.md

oRPC Contract-First Development

Intent

  • Keep contract as single source of truth in web/contract/*.
  • Default query usage: call-site useQuery(consoleQuery|marketplaceQuery.xxx.queryOptions(...)) when endpoint behavior maps 1:1 to the contract.
  • Keep abstractions minimal and preserve TypeScript inference.

Minimal Structure

web/contract/
├── base.ts
├── router.ts
├── marketplace.ts
└── console/
    ├── billing.ts
    └── ...other domains
web/service/client.ts
Related skills

More from langgenius/dify

Installs
717
Repository
langgenius/dify
GitHub Stars
141.3K
First Seen
Jan 20, 2026