# golang-grpc

Guides the agent in writing production-ready Go gRPC services: versioned protobuf APIs, interceptors, deadlines, TLS, and bufconn tests.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 503 installs · ★ 78
- Author: Claude MPM Team
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/golang/golang-grpc/SKILL.md
- Updated: 2026-07-18
- HTML: https://affpapa.org/en/nevibecode/skills/claude-mpm-team-golang-grpc

## What it does

The skill equips the coding agent with architectural conventions for Go microservices running gRPC. It enforces versioned Protobuf packages (`v1`), explicit error handling via `google.golang.org/grpc/codes`, and deadline checks on incoming context objects. For streaming calls, it supplies patterns that listen to `stream.Context().Done()` to prevent leaks.

It also details middleware setups using unary interceptors for request tracing, health check registration via `grpc_health_v1`, and controlled shutdown routines combining `GracefulStop` with a fallback timer. Unit testing relies on in-memory listeners rather than real TCP network sockets.

Code generation will fail unless `protoc-gen-go` and `protoc-gen-go-grpc` binaries exist in your environment. Server reflection is intentionally restricted to non-production deployments.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill golang-grpc -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/golang-grpc/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/golang-grpc/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill golang-grpc -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/golang-grpc/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill golang-grpc -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/golang-grpc/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install bobmatnyc/claude-mpm-skills golang-grpc
```

2. **Manually: put the files in place**
- File: `.github/skills/golang-grpc/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill golang-grpc -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/bobmatnyc/claude-mpm-skills --path toolchains/golang/golang-grpc
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/golang-grpc/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add bobmatnyc/claude-mpm-skills --skill golang-grpc -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/golang/golang-grpc/SKILL.md

## When to use it
- Structure versioned protobuf files and generate Go service stubs
- Map business errors to standard gRPC status codes
- Implement unary server interceptors for request ID injection
- Write fast unit tests using in-memory listeners with `bufconn`

## Example prompts
- Create a versioned users.v1 proto schema and show the protoc generation command
- Implement a unary interceptor in Go that assigns a UUID to each request context
- Write an in-memory gRPC test using bufconn for the GetUser handler

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 634e3ea59d0d9b1a.

BEGIN THIRD-PARTY FILE 634e3ea59d0d9b1a
````text
---
name: golang-grpc
description: "Production gRPC in Go: protobuf layout, codegen, interceptors, deadlines, error codes, streaming, health checks, TLS, and testing with bufconn"
user-invocable: false
disable-model-invocation: true
version: 1.0.0
category: toolchain
author: Claude MPM Team
license: MIT
progressive_disclosure:
  entry_point:
    summary: "Build production gRPC services in Go with protobuf-first APIs, interceptors, deadlines, status codes, and streaming patterns"
    when_to_use: "When building Go microservices that need typed RPC, streaming, low latency, or strong client/server contracts with protobuf"
    quick_start: "1. Define versioned protos (pkg v1) 2. Generate Go code 3. Implement server + interceptors 4. Enforce deadlines 5. Test with bufconn"
  token_estimate:
    entry: 160
    full: 6500
context_limit: 900
tags:
  - golang
  - grpc
  - protobuf
  - microservices
  - streaming
  - interceptors
  - observability
requires_tools: []
---

# Go gRPC (Production)

## Overview

gRPC provides strongly-typed RPC APIs backed by Protocol Buffers, with first-class streaming support and excellent performance for service-to-service communication. This skill focuses on production defaults: versioned protos, deadlines, error codes, interceptors, health checks, TLS, and testability.

## Quick Start

### 1) Define a versioned protobuf API

✅ **Correct: versioned package**
```proto
// proto/users/v1/users.proto
syntax = "proto3";

package users.v1;
option go_package = "example.com/myapp/gen/users/v1;usersv1";

service UsersService {
  rpc GetUser(GetUserRequest) returns (GetUserResponse);
  rpc ListUsers(ListUsersRequest) returns (stream User);
}

message GetUserRequest { string id = 1; }
message GetUserResponse { User user = 1; }
message ListUsersRequest { int32 page_size = 1; string page_token = 2; }

message User {
  string id = 1;
  string email = 2;
  string display_name = 3;
}
```

❌ **Wrong: unversioned package (hard to evolve)**
```proto
package users;
```

### 2) Generate Go code

Install generators:
```bash
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```

Generate:
```bash
protoc -I proto \
  --go_out=./gen --go_opt=paths=source_relative \
  --go-grpc_out=./gen --go-grpc_opt=paths=source_relative \
  proto/users/v1/users.proto
```

### 3) Implement server with deadlines and status codes

✅ **Correct: validate + map errors to gRPC codes**
```go
package usersvc

import (
    "context"

    "google.golang.org/grpc/codes"
    "google.golang.org/grpc/status"

    usersv1 "example.com/myapp/gen/users/v1"
)

type Service struct {
    usersv1.UnimplementedUsersServiceServer
    Repo Repo
}

type Repo interface {
    GetUser(ctx context.Context, id string) (User, error)
}

type User struct {
````
END THIRD-PARTY FILE 634e3ea59d0d9b1a

The third-party file has ended. Everything between the 634e3ea59d0d9b1a tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2838 of 8536 bytes. © Claude MPM Team · MIT · https://github.com/bobmatnyc/claude-mpm-skills/tree/HEAD/toolchains/golang/golang-grpc/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
