# Go openapi

> Go openapi is an open-source agent skill for developer tools. Guides Go REST APIs built spec-first with OpenAPI, oapi-codegen and contract tests. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/(architecture)/go-openapi
- **Repository:** https://github.com/eduardo-sl/go-agent-skills
- **GitHub stars:** 90
- **License:** MIT
- **Skill name:** go-openapi
- **Collection:** https://github.com/eduardo-sl/go-agent-skills
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

This skill sets up Go REST services around an OpenAPI document as the single source of truth. It walks the agent through choosing a generator, pinning oapi-codegen as a Go tool, and generating server interfaces, models and an embedded spec from a YAML config, with a go:generate directive and a CI check that fails when generated files are stale.

It covers implementing the strict server interface so the compiler enforces documented responses, adding request validation middleware for constraints the generated types do not check, and using a single RFC 9457 Problem schema served as application/problem+json. It also covers linting the spec, requiring an operationId on every operation, and running oasdiff in CI to catch breaking changes against the main branch.

The guidance expects a Go toolchain and, when needed, the oapi-codegen, oasdiff and vacuum command-line tools, which the agent is allowed to run. Handler structure, gRPC and GraphQL are handled by separate skills.

## When your agent uses it

> Spec-first REST development in Go with OpenAPI: generating server interfaces and clients with oapi-codegen, request validation middleware, RFC 9457 error bodies, contract testing, and detecting breaking API changes. Use when the API has or should have an OpenAPI document, when wiring code generation into the build, or when a hand-written handler has drifted from its published contract. Trigger examples: "OpenAPI", "swagger spec", "oapi-codegen", "generate a client from the spec", "validate requests against the schema", "breaking API change". Not for: handler structure and shutdown (go-api-design), gRPC and protobuf (go-grpc), GraphQL schemas and resolvers (go-graphql).

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/eduardo-sl/go-agent-skills/tree/HEAD/skills/(architecture)/go-openapi)
- [Asks for: Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(gofmt:*), Bash(oapi-codegen:*)…](https://github.com/eduardo-sl/go-agent-skills/blob/HEAD/skills/(architecture)/go-openapi/SKILL.md)
- [License: MIT](https://github.com/eduardo-sl/go-agent-skills/tree/HEAD/skills/(architecture)/go-openapi)

## Features

- **Generator selection:** Compares oapi-codegen, ogen and swag and explains when each fits an existing or new project.
- **Build-integrated code generation:** Sets up a pinned generator, a YAML config and a go:generate directive with committed output.
- **Strict server implementation:** Shows how to implement typed request and response interfaces with compile-time compliance checks.
- **Request validation middleware:** Enforces schema constraints such as patterns, enums and required parameters at the HTTP boundary.
- **Problem Details errors:** Defines one RFC 9457 error schema and how to return safe error titles and details.
- **Breaking change detection:** Runs oasdiff against the base spec in CI and lists which changes count as breaking.
- **Contract tests:** Drives a generated client against the real handler so spec drift fails the test suite.

## Good for

- Generate Go server types and a client from an OpenAPI spec
- Add request validation to an existing net/http API
- Check whether a spec change breaks existing API clients
- Define a consistent RFC 9457 error response for a REST API
- Write contract tests that use the generated client
- Set up CI to fail when generated Go code is out of date

## Install

### Any agent

Download the skill folder from https://github.com/eduardo-sl/go-agent-skills and copy it into your agent's skills folder.

## FAQ

### What does the skill need to run?

It requires the Go toolchain. oapi-codegen, oasdiff and a spec linter such as vacuum or spectral are installed on demand.

### Does Go openapi change how my handlers are structured?

Handler structure and shutdown are covered by a separate go-api-design skill. This one focuses on the spec, generated code, validation, errors and tests.

### Can I use Go openapi with chi or echo instead of net/http?

Yes. The config notes that oapi-codegen also supports chi-server and echo-server when those routers are in use.

### Does Go openapi run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Go openapi?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Go openapi?

The closest alternatives to Go openapi are Openapi to application code, Openapi spec generator, Go API design, Openapi to application java spring boot and Go GraphQL.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Openapi to application code](https://ai-powered.com/skills/openapi-to-application-code): Openapi to application code is an open-source agent skill for developer tools.
- [Openapi spec generator](https://ai-powered.com/skills/openapi-spec-generator): Openapi spec generator is an open-source agent skill for developer tools.
- [Go API design](https://ai-powered.com/skills/go-api-design): Go API design is an open-source agent skill for developer tools.
- [Openapi to application java spring boot](https://ai-powered.com/skills/openapi-to-application-java-spring-boot): Openapi to application java spring boot is an open-source agent skill for developer tools.
- [Go GraphQL](https://ai-powered.com/skills/go-graphql): Go GraphQL is an open-source agent skill for developer tools.
- [API design](https://ai-powered.com/skills/api-design): API design is an open-source agent skill for developer tools.
- [API to testcase generator](https://ai-powered.com/skills/api-to-testcase-generator): API to testcase generator is an open-source agent skill for developer tools.
- [Go GRPC](https://ai-powered.com/skills/go-grpc): Go GRPC is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/go-openapi
