Guide for implementing oRPC contract-first API patterns in Dify frontend. Triggers when creating new API contracts, adding service endpoints, integrating TanStack Query with typed contracts, or migrating legacy service calls to oRPC. Use for all API layer work in web/contract and web/service directories.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
skills listSkill Instructions
name: orpc-contract-first description: Guide for implementing oRPC contract-first API patterns in Dify frontend. Triggers when creating new API contracts, adding service endpoints, integrating TanStack Query with typed contracts, or migrating legacy service calls to oRPC. Use for all API layer work in web/contract and web/service directories.
oRPC Contract-First Development
Project Structure
web/contract/
├── base.ts # Base contract (inputStructure: 'detailed')
├── router.ts # Router composition & type exports
├── marketplace.ts # Marketplace contracts
└── console/ # Console contracts by domain
├── system.ts
└── billing.ts
Workflow
-
Create contract in
web/contract/console/{domain}.ts- Import
basefrom../baseandtypefrom@orpc/contract - Define route with
path,method,input,output
- Import
-
Register in router at
web/contract/router.ts- Import directly from domain file (no barrel files)
- Nest by API prefix:
billing: { invoices, bindPartnerStack }
-
Create hooks in
web/service/use-{domain}.ts- Use
consoleQuery.{group}.{contract}.queryKey()for query keys - Use
consoleClient.{group}.{contract}()for API calls
- Use
Key Rules
- Input structure: Always use
{ params, query?, body? }format - Path params: Use
{paramName}in path, match inparamsobject - Router nesting: Group by API prefix (e.g.,
/billing/*→billing: {}) - No barrel files: Import directly from specific files
- Types: Import from
@/types/, usetype<T>()helper
Type Export
export type ConsoleInputs = InferContractRouterInputs<typeof consoleRouterContract>
More by langgenius
View allTrigger when the user requests a review of frontend files (e.g., `.tsx`, `.ts`, `.js`). Support both pending-change reviews and focused file reviews while applying the checklist rules.
Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
Generate Vitest + React Testing Library tests for Dify frontend components, hooks, and utilities. Triggers on testing, spec files, coverage, Vitest, RTL, unit tests, integration tests, or write/review test requests.
