install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/orval" ~/.claude/skills/comeonoliver-skillshub-orval && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/orval/SKILL.mdsource content
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 | |
| 2 | Configuration Architecture | CRITICAL | |
| 3 | Output Structure & Organization | HIGH | |
| 4 | Custom Client & Mutators | HIGH | |
| 5 | Query Library Integration | MEDIUM-HIGH | |
| 6 | Type Safety & Validation | MEDIUM | |
| 7 | Mock Generation & Testing | MEDIUM | |
| 8 | Advanced Patterns | LOW | |
Quick Reference
1. OpenAPI Specification Quality (CRITICAL)
- Use unique and descriptive operationIdsspec-operationid-unique
- Define reusable schemas in componentsspec-schemas-reusable
- Organize operations with tagsspec-tags-organization
- Define all response types explicitlyspec-response-types
- Mark required fields explicitlyspec-required-fields
2. Configuration Architecture (CRITICAL)
- Choose output mode based on API sizeorvalcfg-mode-selection
- Select client based on framework requirementsorvalcfg-client-selection
- Separate schemas into dedicated directoryorvalcfg-separate-schemas
- Validate OpenAPI spec before generationorvalcfg-input-validation
- Configure base URL properlyorvalcfg-baseurl-setup
- Enable automatic code formattingorvalcfg-prettier-format
3. Output Structure & Organization (HIGH)
- Use distinct file extensions for generated codeoutput-file-extension
- Generate index files for clean importsoutput-index-files
- Configure consistent naming conventionsoutput-naming-convention
- Enable clean mode for consistent regenerationoutput-clean-target
- Enable headers in generated functionsoutput-headers-enabled
4. Custom Client & Mutators (HIGH)
- Use custom mutator for HTTP client configurationmutator-custom-instance
- Export custom error types from mutatormutator-error-types
- Export body type wrapper for request transformationmutator-body-wrapper
- Use interceptors for cross-cutting concernsmutator-interceptors
- Handle token refresh in mutatormutator-token-refresh
- Use fetch mutator for smaller bundle sizemutator-fetch-client
5. Query Library Integration (MEDIUM-HIGH)
- Configure default query options globallyoquery-hook-options
- Export query keys for cache invalidationoquery-key-export
- Enable infinite queries for paginated endpointsoquery-infinite-queries
- Enable suspense mode for streaming UXoquery-suspense-support
- Pass AbortSignal for request cancellationoquery-signal-cancellation
- Use generated mutation options typesoquery-mutation-callbacks
6. Type Safety & Validation (MEDIUM)
- Generate Zod schemas for runtime validationtypes-zod-validation
- Enable Zod strict mode for safer validationtypes-zod-strict
- Use Zod coercion for type transformationstypes-zod-coerce
- Enable useDates for Date type generationtypes-use-dates
- Enable useBigInt for large integer supporttypes-bigint-support
7. Mock Generation & Testing (MEDIUM)
- Generate MSW handlers for testingmock-msw-generation
- Use OpenAPI examples for realistic mocksmock-use-examples
- Configure mock response delaysmock-delay-config
- Generate mocks for all HTTP status codesmock-http-status
- Generate mock index files for easy setupmock-index-files
8. Advanced Patterns (LOW)
- Use input transformer for spec preprocessingadv-input-transformer
- Override settings per operationadv-operation-override
- Use output transformer for generated code modificationadv-output-transformer
- Configure form data serializationadv-form-data-handling
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
skilltanstack-query - For mocking generated API clients, see
skilltest-msw - For schema validation, see
skillzod
Full Compiled Document
For the complete guide with all rules expanded:
AGENTS.md