File contents Orval OpenAPI Best Practices
Comprehensive guide for generating type-safe TypeScript clients from OpenAPI specifications using Orval. Contains 42 rules across 8 categories, prioritized by impact to guide automated configuration, client generation, and testing setup.
When to Apply
Reference these guidelines when:
Configuring Orval for a new project
Setting up OpenAPI-based TypeScript client generation
Integrating React Query, SWR, or Vue Query with generated hooks
Creating custom mutators for authentication and error handling
Generating MSW mocks for testing
Rule Categories by Priority
Priority
Category
Impact
Prefix
1
OpenAPI Specification Quality
CRITICAL
spec-
2
Configuration Architecture
CRITICAL
orvalcfg-
3
Output Structure & Organization
HIGH
output-
4
Custom Client & Mutators
HIGH
mutator-
5
Query Library Integration
MEDIUM-HIGH
oquery-
6
Type Safety & Validation
MEDIUM
types-
7
Mock Generation & Testing
MEDIUM
mock-
8
Advanced Patterns
LOW
adv-
Quick Reference
1. OpenAPI Specification Quality (CRITICAL)
spec-operationid-unique - Use unique and descriptive operationIds
spec-schemas-reusable - Define reusable schemas in components
spec-tags-organization - Organize operations with tags
spec-response-types - Define all response types explicitly
spec-required-fields - Mark required fields explicitly
2. Configuration Architecture (CRITICAL)
orvalcfg-mode-selection - Choose output mode based on API size
orvalcfg-client-selection - Select client based on framework requirements
orvalcfg-separate-schemas - Separate schemas into dedicated directory
orvalcfg-input-validation - Validate OpenAPI spec before generation
orvalcfg-baseurl-setup - Configure base URL properly
orvalcfg-prettier-format - Enable automatic code formatting
3. Output Structure & Organization (HIGH)
output-file-extension - Use distinct file extensions for generated code
output-index-files - Generate index files for clean imports
output-naming-convention - Configure consistent naming conventions
output-clean-target - Enable clean mode for consistent regeneration
output-headers-enabled - Enable headers in generated functions
4. Custom Client & Mutators (HIGH)
mutator-custom-instance - Use custom mutator for HTTP client configuration
mutator-error-types - Export custom error types from mutator
mutator-body-wrapper - Export body type wrapper for request transformation
mutator-interceptors - Use interceptors for cross-cutting concerns
mutator-token-refresh - Handle token refresh in mutator
mutator-fetch-client - Use fetch mutator for smaller bundle size
5. Query Library Integration (MEDIUM-HIGH)
oquery-hook-options - Configure default query options globally
oquery-key-export - Export query keys for cache invalidation
oquery-infinite-queries - Enable infinite queries for paginated endpoints
oquery-suspense-support - Enable suspense mode for streaming UX
oquery-signal-cancellation - Pass AbortSignal for request cancellation
oquery-mutation-callbacks - Use generated mutation options types
6. Type Safety & Validation (MEDIUM)
types-zod-validation - Generate Zod schemas for runtime validation
types-zod-strict - Enable Zod strict mode for safer validation
types-zod-coerce - Use Zod coercion for type transformations
types-use-dates - Enable useDates for Date type generation
types-bigint-support - Enable useBigInt for large integer support
7. Mock Generation & Testing (MEDIUM)
mock-msw-generation - Generate MSW handlers for testing
mock-use-examples - Use OpenAPI examples for realistic mocks
mock-delay-config - Configure mock response delays
mock-http-status - Generate mocks for all HTTP status codes
mock-index-files - Generate mock index files for easy setup
8. Advanced Patterns (LOW)
adv-input-transformer - Use input transformer for spec preprocessing
adv-operation-override - Override settings per operation
adv-output-transformer - Use output transformer for generated code modification
adv-form-data-handling - Configure form data serialization
How to Use
Read individual reference files for detailed explanations and code examples:
Section definitions - Category structure and impact levels
Rule template - Template for adding new rules
Example: spec-operationid-unique
Related Skills
For consuming generated hooks, see tanstack-query skill
For mocking generated API clients, see test-msw skill
For schema validation, see zod skill
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
1 --- 2 name: orval 3 description: Orval OpenAPI Best Practices 4 --- 5 # Orval OpenAPI Best Practices 6 7 Comprehensive guide for generating type-safe TypeScript clients from OpenAPI specifications using Orval. Contains 42 rules across 8 categories, prioritized by impact to guide automated configuration, client generation, and testing setup. 8 9 ## When to Apply 10 11 Reference these guidelines when: 12 - Configuring Orval for a new project 13 - Setting up OpenAPI-based TypeScript client generation 14 - Integrating React Query, SWR, or Vue Query with generated hooks 15 - Creating custom mutators for authentication and error handling 16 - Generating MSW mocks for testing 17 18 ## Rule Categories by Priority 19 20 | Priority | Category | Impact | Prefix | 21 |----------|----------|--------|--------| 22 | 1 | OpenAPI Specification Quality | CRITICAL | `spec-` | 23 | 2 | Configuration Architecture | CRITICAL | `orvalcfg-` | 24 | 3 | Output Structure & Organization | HIGH | `output-` | 25 | 4 | Custom Client & Mutators | HIGH | `mutator-` | 26 | 5 | Query Library Integration | MEDIUM-HIGH | `oquery-` | 27 | 6 | Type Safety & Validation | MEDIUM | `types-` | 28 | 7 | Mock Generation & Testing | MEDIUM | `mock-` | 29 | 8 | Advanced Patterns | LOW | `adv-` | 30 31 ## Quick Reference 32 33 ### 1. OpenAPI Specification Quality (CRITICAL) 34 35 - `spec-operationid-unique` - Use unique and descriptive operationIds 36 - `spec-schemas-reusable` - Define reusable schemas in components 37 - `spec-tags-organization` - Organize operations with tags 38 - `spec-response-types` - Define all response types explicitly 39 - `spec-required-fields` - Mark required fields explicitly 40 41 ### 2. Configuration Architecture (CRITICAL) 42 43 - `orvalcfg-mode-selection` - Choose output mode based on API size 44 - `orvalcfg-client-selection` - Select client based on framework requirements 45 - `orvalcfg-separate-schemas` - Separate schemas into dedicated directory 46 - `orvalcfg-input-validation` - Validate OpenAPI spec before generation 47 - `orvalcfg-baseurl-setup` - Configure base URL properly 48 - `orvalcfg-prettier-format` - Enable automatic code formatting 49 50 ### 3. Output Structure & Organization (HIGH) 51 52 - `output-file-extension` - Use distinct file extensions for generated code 53 - `output-index-files` - Generate index files for clean imports 54 - `output-naming-convention` - Configure consistent naming conventions 55 - `output-clean-target` - Enable clean mode for consistent regeneration 56 - `output-headers-enabled` - Enable headers in generated functions 57 58 ### 4. Custom Client & Mutators (HIGH) 59 60 - `mutator-custom-instance` - Use custom mutator for HTTP client configuration 61 - `mutator-error-types` - Export custom error types from mutator 62 - `mutator-body-wrapper` - Export body type wrapper for request transformation 63 - `mutator-interceptors` - Use interceptors for cross-cutting concerns 64 - `mutator-token-refresh` - Handle token refresh in mutator 65 - `mutator-fetch-client` - Use fetch mutator for smaller bundle size 66 67 ### 5. Query Library Integration (MEDIUM-HIGH) 68 69 - `oquery-hook-options` - Configure default query options globally 70 - `oquery-key-export` - Export query keys for cache invalidation 71 - `oquery-infinite-queries` - Enable infinite queries for paginated endpoints 72 - `oquery-suspense-support` - Enable suspense mode for streaming UX 73 - `oquery-signal-cancellation` - Pass AbortSignal for request cancellation 74 - `oquery-mutation-callbacks` - Use generated mutation options types 75 76 ### 6. Type Safety & Validation (MEDIUM) 77 78 - `types-zod-validation` - Generate Zod schemas for runtime validation 79 - `types-zod-strict` - Enable Zod strict mode for safer validation 80 - `types-zod-coerce` - Use Zod coercion for type transformations 81 - `types-use-dates` - Enable useDates for Date type generation 82 - `types-bigint-support` - Enable useBigInt for large integer support 83 84 ### 7. Mock Generation & Testing (MEDIUM) 85 86 - `mock-msw-generation` - Generate MSW handlers for testing 87 - `mock-use-examples` - Use OpenAPI examples for realistic mocks 88 - `mock-delay-config` - Configure mock response delays 89 - `mock-http-status` - Generate mocks for all HTTP status codes 90 - `mock-index-files` - Generate mock index files for easy setup 91 92 ### 8. Advanced Patterns (LOW) 93 94 - `adv-input-transformer` - Use input transformer for spec preprocessing 95 - `adv-operation-override` - Override settings per operation 96 - `adv-output-transformer` - Use output transformer for generated code modification 97 - `adv-form-data-handling` - Configure form data serialization 98 99 ## How to Use 100 101 Read individual reference files for detailed explanations and code examples: 102 103 - [Section definitions](references/_sections.md) - Category structure and impact levels 104 - [Rule template](assets/templates/_template.md) - Template for adding new rules 105 - Example: [spec-operationid-unique](references/spec-operationid-unique.md) 106 107 ## Related Skills 108 109 - For consuming generated hooks, see `tanstack-query` skill 110 - For mocking generated API clients, see `test-msw` skill 111 - For schema validation, see `zod` skill 112 113 ## Full Compiled Document 114 115 For the complete guide with all rules expanded: `AGENTS.md`
ComeOnOliver/skillshub/tree/main/skills/pproenca/dot-skills/orval commit 90d8032275
Frequently asked questions How do I install the Orval skill? Run npx skillmds@latest add comeonoliver/orval in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Orval skill do? Orval OpenAPI Best Practices It is listed under Coding & Dev Tools on SkillMD.
Is Orval safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Orval? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Orval free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Orval? ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.