openapi-to-typescript — Claude Code skill: type generation
This skill turns an OpenAPI 3.0 file into TypeScript interfaces and type guards. Use it when API schemas need corresponding types in your codebase.
npx claude-code-templates@latest --skill development/openapi-to-typescriptWhat openapi-to-typescript does
The skill reads an OpenAPI file in JSON or YAML, checks its structure, then uses components/schemas and paths to build TypeScript output. Generated types cover schemas as well as endpoint parameters and responses. Required properties stay required; optional ones receive ?. Enums and $ref links are handled too.
The document must identify an OpenAPI 3.0.x version and contain paths; components.schemas is needed when the spec defines types. Validation failures stop generation, so a spec from another version will not pass this check. The output also includes an ApiError interface and a guard for it. The skill asks where to write the result, with types/api.ts in the current directory as its suggested path.
What it helps with
- generate TypeScript interfaces from OpenAPI schemas
- model API request parameters and responses
- add runtime checks for required fields
- represent enums and
$reflinks as TypeScript types
Example prompts for the agent
- Generate TypeScript types from the
api.yamlspecification. - Turn
openapi.jsoninto interfaces and guards for its API endpoints. - Check this OpenAPI 3.0 file and save the result as
types/api.ts.
How to install openapi-to-typescript
1claude-code-templates
npx claude-code-templates@latest --skill development/openapi-to-typescript2Skills CLI (Vercel)
npx skills add davila7/claude-code-templates --skill openapi-to-typescript -a claude-code3Manually: put the files in place
~/.claude/skills/openapi-to-typescript/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/openapi-to-typescript/
Manually: put the files in place
.agents/skills/openapi-to-typescript/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/openapi-to-typescript/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install davila7/claude-code-templates openapi-to-typescript2Manually: put the files in place
.github/skills/openapi-to-typescript/SKILL.mdPlatform CLI
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/development/openapi-to-typescriptManually: put the files in place
.devin/skills/openapi-to-typescript/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about openapi-to-typescript
How do I install openapi-to-typescript in Claude Code?
Run npx claude-code-templates@latest --skill development/openapi-to-typescript. Then give the agent the path to your OpenAPI file.
What does openapi-to-typescript do?
It reads an OpenAPI 3.0 specification and generates TypeScript interfaces for schemas, requests, and responses, along with type guards.
Which OpenAPI files can openapi-to-typescript process?
It accepts JSON or YAML for OpenAPI 3.0.x. The spec needs openapi and paths; components.schemas is needed when types are defined.