Use when generating SDKs, Terraform providers, or MCP servers with Speakeasy, or when needing best practices for SDK/Terraform generation, customization, testing, or OpenAPI spec management...
Comprehensive best-practices reference for generating SDKs and Terraform providers with Speakeasy. Covers the full lifecycle: OpenAPI spec preparation, code-first extraction, generation workflows, language-specific guides, customization, and testing.
This skill contains detailed guides in the content/ subdirectory relative to this file. Read the specific guide for the user's task rather than trying to answer from this index alone.
These guides are also accessible via the Speakeasy CLI:
speakeasy agent context [path]
To find the right guide, use the routing table below or the decision tree.
What are you trying to do?
| Goal | Start Here |
|---|---|
| Generate an SDK from an OpenAPI spec | content/plans/sdk-generation.md |
| Generate a Terraform provider | content/plans/tf-provider-generation.md |
| Extract OpenAPI from existing code | content/code-first/[framework].md |
| Fix OpenAPI validation errors | content/spec-first/validation.md |
| Customize SDK generation | content/sdk-customization/ |
| Generate multiple SDK variants (Azure, GCP, etc.) | content/sdk-customization/multi-target-sdks.md |
| Set up a multi-SDK monorepo | content/plans/sdk-generation.md#advanced-multi-sdk-monorepos |
| Use overlay recipes (open enums, global headers) | content/spec-first/overlays.md#overlay-recipes |
| Use multi-overlay workflows | content/spec-first/overlays.md#multi-overlay-workflow-patterns |
| Track overlay changes with metadata | content/spec-first/overlays.md#overlay-metadata-tracking |
| Implement custom security (HMAC, signatures) | content/spec-first/overlays.md#custom-security-schemes-via-overlay |
| Add SDK hooks (user-agent, telemetry) | content/sdk-customization/hooks.md |
| Implement HTTP signature authentication | content/sdk-customization/hooks.md#custom-security-hook-http-signature-authentication |
| Configure SDK retries, timeouts, pagination | content/sdk-customization/runtime-configuration.md |
| Configure SDK authentication and security | content/sdk-customization/authentication-config.md |
| Customize SDK error handling | content/sdk-customization/error-handling.md |
| Persist custom code changes across regenerations | content/sdk-customization/custom-code.md |
| Generate MCP server for AI assistants | content/sdk-customization/mcp-server.md |
| Orchestrate multi-repo SDK generation | content/sdk-customization/multi-repo-workflows.md |
| Understand SDK language specifics | content/sdk-languages/[language].md |
| Add custom utilities to Python SDKs | content/sdk-languages/python.md#extending-the-sdk-with-sidecar-utilities |
| Publish Java SDK to Maven Central | content/sdk-languages/java.md#maven-central-publishing |
| Add custom code to TypeScript SDKs | content/sdk-languages/typescript.md#custom-code-regions |
| Publish TypeScript SDK to JSR (Deno) | content/sdk-languages/typescript.md#jsr-deno-publishing |
| Configure Ruby SDK with Sorbet typing | content/sdk-languages/ruby.md#sorbet-type-checking |
| Publish Ruby SDK to RubyGems | content/sdk-languages/ruby.md#rubygems-publishing |
| Configure PHP SDK with Laravel integration | content/sdk-languages/php.md#laravel-integration |
| Publish PHP SDK to Packagist | content/sdk-languages/php.md#publishing-to-packagist |
| Generate Go SDK with interfaces for testing | content/sdk-languages/go.md#interface-generation |
| Use Go SDK in Kubernetes operators | content/sdk-languages/go.md#kubernetes-operator-integration |
| Set up SDK integration tests | content/sdk-testing/integration-testing.md |
| Configure Arazzo API testing | content/sdk-testing/arazzo-testing.md |
| Disable tests for specific endpoints | content/sdk-testing/arazzo-testing.md#disabling-tests-via-overlay |
| Run AI-powered contract tests | content/sdk-testing/contract-testing.md |
| Fix ResponseValidationError at runtime | content/sdk-testing/contract-testing.md |
| Validate spec matches live API | content/spec-first/validation.md#dynamic-validation-contract-testing |
| Upgrade Speakeasy version in workflow.yaml | content/plans/sdk-generation.md#version-management |
| Bump pinned speakeasyVersion to latest | content/plans/sdk-generation.md#version-management |
| Regenerate SDK after spec or version change | content/plans/sdk-generation.md |
| Customize SDK README with documentation | content/sdk-customization/readme-customization.md |
| Add branding, examples, or guides to SDK README | content/sdk-customization/readme-customization.md |
| Add examples to OpenAPI spec via overlay | content/spec-first/overlays.md#add-examples |
| Add API-response-based examples to spec | content/spec-first/overlays.md#add-examples |
| Test SDK against live API | content/sdk-testing/integration-testing.md |
| Run contract tests for generated SDK | content/sdk-testing/contract-testing.md |
content/
āāā INDEX.md # This index (SKILL.md)
āāā plans/ # Decision trees for workflows
ā āāā sdk-generation.md # Full SDK generation workflow
ā āāā tf-provider-generation.md
āāā code-first/ # Extract OpenAPI from code
ā āāā fastapi.md
ā āāā flask.md
ā āāā django.md
ā āāā spring-boot.md
ā āāā nestjs.md
ā āāā hono.md
ā āāā rails.md
ā āāā laravel.md
āāā spec-first/ # OpenAPI validation and fixes
ā āāā validation.md
ā āāā overlays.md # OpenAPI overlays and recipes
ā āāā security-schemes.md
ā āāā pagination.md
ā āāā schemas.md
āāā sdk-languages/ # Language-specific SDK guides
ā āāā python.md
ā āāā typescript.md # TS: code regions, extra modules, Zod
ā āāā go.md # Go: hooks, interfaces, mocks, K8s
ā āāā java.md
ā āāā csharp.md
ā āāā ruby.md # Ruby: Sorbet typing, RubyGems publishing
ā āāā php.md
āāā sdk-customization/ # Cross-language SDK customization
ā āāā hooks.md # SDK hooks (UA, telemetry, custom security)
ā āāā runtime-configuration.md # Retries, timeouts, pagination, servers
ā āāā authentication-config.md # Global/per-op security, env vars
ā āāā error-handling.md # Custom error classes and schemas
ā āāā custom-code.md # Persist changes across regenerations
ā āāā multi-target-sdks.md # Multiple variants from one repo
ā āāā multi-repo-workflows.md # Cross-repo SDK orchestration (CI/CD)
ā āāā mcp-server.md # MCP server for AI assistant integration
ā āāā readme-customization.md # SDK README branding
āāā sdk-testing/ # SDK testing patterns
ā āāā integration-testing.md # Integration test infrastructure
ā āāā arazzo-testing.md # Arazzo API testing format
ā āāā contract-testing.md # AI-powered contract testing
āāā terraform/ # Terraform provider specifics
ā āāā crud-mapping.md
ā āāā customization.md
ā āāā testing-guide.md
ā āāā publishing.md
āāā CLI_REFERENCE.md # Canonical CLI command documentation
START
ā
āā Do you have an OpenAPI/Swagger spec?
ā ā
ā āā YES āāāŗ Is the spec valid?
ā ā ā
ā ā āā YES āāāŗ What do you want to generate?
ā ā ā ā
ā ā ā āā SDK āāāŗ plans/sdk-generation.md
ā ā ā āā Terraform Provider āāāŗ plans/tf-provider-generation.md
ā ā ā
ā ā āā NO/UNSURE āāāŗ spec-first/validation.md
ā ā
ā āā NO āāāŗ Do you have API code?
ā ā
ā āā YES āāāŗ What framework?
ā ā āā FastAPI āāāŗ code-first/fastapi.md
ā ā āā Flask āāāŗ code-first/flask.md
ā ā āā Django āāāŗ code-first/django.md
ā ā āā Spring Boot āāāŗ code-first/spring-boot.md
ā ā āā NestJS āāāŗ code-first/nestjs.md
ā ā āā Hono āāāŗ code-first/hono.md
ā ā āā Rails āāāŗ code-first/rails.md
ā ā āā Laravel āāāŗ code-first/laravel.md
ā ā
ā āā NO āāāŗ Cannot proceed without spec or code
PROBLEM
ā
āā Getting ResponseValidationError at runtime?
ā ā
ā āā SDK types don't match server responses
ā āā Run contract tests to identify all mismatches
ā ā ā sdk-testing/contract-testing.md
ā āā Fix spec or create overlay to correct types
ā ā spec-first/validation.md#dynamic-validation-contract-testing
ā
āā SDK doesn't match live API behavior?
ā ā
ā āā Spec may have drifted from API
ā ā ā Run contract tests to detect drift
ā ā sdk-testing/contract-testing.md
ā ā
ā āā Third-party spec may be inaccurate
ā ā Validate with contract testing before trusting
ā sdk-testing/contract-testing.md
ā
āā Type mismatch errors in generated SDK?
ā ā
ā āā At compile time āāāŗ Check spec schema definitions
ā ā spec-first/validation.md
ā ā
ā āā At runtime āāāŗ Server returns unexpected types
ā ā Contract testing required
ā sdk-testing/contract-testing.md
ā
āā Enum value not recognized?
ā
āā API returned value not in spec enum
āā Add missing value to spec/overlay
ā ā spec-first/overlays.md
āā Or use open enums for anti-fragility
ā spec-first/overlays.md#overlay-recipes
OpenAPI specs can be thousands of lines. Do not load the full spec into context. Use yq (YAML) or jq (JSON) to extract only the sections you need.
# List all paths
yq '.paths | keys' spec.yaml
# Inspect a specific endpoint
yq '.paths["/users/{id}"]' spec.yaml
# List all schema names
yq '.components.schemas | keys' spec.yaml
# Inspect a specific schema
yq '.components.schemas.User' spec.yaml
# Check server URLs
yq '.servers' spec.yaml
# List all operationIds
yq '[.paths[][].operationId // empty] | unique' spec.yaml
# For JSON specs, use jq
jq '.paths | keys' spec.json
jq '.components.schemas.User' spec.json
Note: If
yq/jqaren't available, use targetedgrepsearches instead of copying the full spec into context:grep -n 'operationId:' spec.yaml grep -n 'x-speakeasy-entity' spec.yaml
content/plans/sdk-generation.mdspeakeasy quickstart --skip-interactive --output console -s spec.yaml -t python -o ./sdkcontent/code-first/speakeasy lint openapi --non-interactive -s spec.yamlcontent/spec-first/ guidescontent/plans/sdk-generation.mdgen.yaml exists (from quickstart)content/sdk-customization/ guidesgen.yamlspeakeasy run -y --output consolecontent/sdk-customization/multi-target-sdks.mdworkflow.yamlpackages/ subdirectoriescontent/sdk-customization/custom-code.mdcontent/sdk-customization/hooks.mdcontent/sdk-languages/typescript.md#custom-code-regionscontent/sdk-languages/typescript.md#extra-modules-patternspeakeasyVersion in .speakeasy/workflow.yamlspeakeasyVersion to latest or a specific version ā content/plans/sdk-generation.md#version-managementspeakeasy run ā content/plans/sdk-generation.mdcontent/sdk-testing/integration-testing.md or content/sdk-testing/contract-testing.md| Command | Purpose |
|---|---|
speakeasy quickstart --skip-interactive --output console -s spec.yaml -t python -o ./sdk |
Non-interactive SDK setup |
speakeasy run -y --output console |
Regenerate SDK from gen.yaml |
speakeasy lint openapi --non-interactive -s spec.yaml |
Validate OpenAPI spec |
speakeasy auth login |
Authenticate with Speakeasy |
speakeasy auth logincontent/spec-first/validation.mdcontent/sdk-languages/content/CLI_REFERENCE.md or run speakeasy --helpIf you encounter missing documentation, unclear instructions, or incorrect examples in this agent context, submit feedback directly:
# General feedback
speakeasy agent feedback -m "Description of the issue or suggestion"
# Feedback about a specific document
speakeasy agent feedback -m "Description of the issue" --context-path "path/to/document.md"
Feedback helps improve these documents for all agents. Submit feedback when:
start-new-sdk-project - Quick interactive setup with speakeasy quickstartregenerate-sdk - Re-run generation after config changesvalidate-openapi-spec - Lint and validate OpenAPI specsdiagnose-generation-failure - Troubleshoot failed generation runscreate-openapi-overlay - Create overlays for spec customizationfix-validation-errors-with-overlays - Fix lint errors with overlays