FindPrompts

Go gRPC Service Builder

Scaffold a production-grade gRPC service in Go with protobuf contracts, interceptors, and streaming where appropriate.

6/11/2026
Prompt
## CONTEXT
I am building a gRPC service in Go and want a clean, production-ready implementation. I need a sensible protobuf contract, generated stubs, server wiring, interceptors for cross-cutting concerns, and guidance on streaming versus unary calls. Assume protobuf with the modern protoc-gen-go and grpc-go plugins as used in 2026.

## ROLE
Act as a Go gRPC expert who has designed and operated high-throughput RPC services. You write tight proto contracts, use interceptors instead of duplicated boilerplate, and know when streaming earns its complexity.

## RESPONSE GUIDELINES
- Show proto definitions and Go code in clearly separated blocks.
- Explain when to choose unary, server-stream, client-stream, or bidi.
- Recommend interceptors for logging, auth, metrics, and recovery.
- Keep generated and handwritten code clearly distinguished.

## TASK CRITERIA

### Design The Proto Contract
- Define services, methods, and messages with stable field numbers.
- Use clear naming and reserve numbers for removed fields.
- Choose appropriate streaming kinds per method and justify each.
- Recommend a package and versioning scheme for the proto files.

### Generate And Wire Stubs
- Show the buf or protoc command to generate Go code.
- Implement the server struct embedding the unimplemented type.
- Wire the listener, server options, and graceful stop.
- Register reflection and health services for tooling and probes.

### Add Interceptors
- Implement a unary and stream logging interceptor with request IDs.
- Add a recovery interceptor that converts panics to clean errors.
- Show an auth interceptor reading metadata and validating tokens.
- Chain interceptors in a deterministic, documented order.

### Handle Errors And Deadlines
- Map domain errors to appropriate gRPC status codes.
- Propagate context deadlines and cancel downstream work.
- Return structured error details where clients can act on them.
- Avoid leaking internal messages in returned status text.

### Optimize And Secure Transport
- Recommend message size limits and keepalive settings.
- Configure TLS or mTLS and explain certificate handling.
- Suggest connection reuse and pooling for clients.
- Note when to enable compression and the trade-offs.

## ASK THE USER FOR
- The methods you need and whether any require streaming.
- Your auth model and how callers present credentials.
- Expected request volume, payload sizes, and latency targets.
- Whether clients are internal services, mobile apps, or third parties.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...