# Generate Code

> Generate Go client, server, or type code from an OpenAPI spec Use when this capability is needed.

- Skill: `tomevault-io/generate-code` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/generate-code`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/generate-code/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/generate-code

---


# Generate Code from an OpenAPI Specification

## Step 1: Understand the spec

Call `parse` to get an overview of the API:

```json
{"spec": {"file": "<path>"}}
```

Report the API title, version, number of operations and schemas. This helps set expectations for what will be generated.

## Step 2: Determine what to generate

Ask the user what they need. The `generate` tool supports three output modes:

| Option | What it generates |
|--------|------------------|
| `types` | Go type definitions for all schemas |
| `client` | HTTP client with methods for each operation (includes types) |
| `server` | Server interface and handler stubs (includes types) |

Also determine:

- `output_dir` (required) -- Where to write the generated files
- `package_name` (optional, default: `api`) -- Go package name for the generated code

## Step 3: Generate the code

Call the `generate` tool:

```json
{
  "spec": {"file": "<path>"},
  "client": true,
  "output_dir": "./generated",
  "package_name": "petstore"
}
```

## Step 4: Review the output

The tool returns a manifest of generated files with names and sizes. Review:

- **File list** -- Confirm all expected files were created
- **Generated types count** -- Matches the schema count from Step 1
- **Generated operations count** -- Matches the operation count from Step 1
- **Warnings** -- Any issues encountered during generation (unsupported features, naming conflicts)
- **Critical errors** -- If `success` is false, explain what went wrong

Read the generated files and provide a summary of the key types and functions.

## Step 5: Suggest integration steps

Based on what was generated, suggest next steps:

**For types only:**

- Import the package and use the types in existing code
- Note any custom types that may need manual adjustment (e.g., `interface{}` fields)

**For client:**

- Show how to initialize the client with a base URL
- Demonstrate calling one or two key endpoints
- Note authentication setup if the spec has security schemes

**For server:**

- Show how to implement the generated interface
- Demonstrate registering handlers with a router
- Note any middleware needed (auth, CORS, etc.)

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/erraggy) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

