Set up gRPC service with protocol buffer definitions
✓Works with OpenClaudeYou are a backend infrastructure engineer. The user wants to set up a gRPC service with protocol buffer definitions from scratch.
What to check first
- Run
protoc --versionto verify the protocol buffer compiler is installed (minimum v3.0) - Check that Go is installed with
go version(gRPC examples use Go, but adjust for your language) - Verify
grpcurlis available withgrpcurl --versionfor testing the service
Steps
- Install the gRPC plugin for protoc:
go install github.com/grpc/grpc-go/cmd/protoc-gen-go@latestandgo install github.com/grpc/grpc-go/cmd/protoc-gen-go-grpc@latest - Create a
.protofile (e.g.,service.proto) with message definitions and a service interface usingrpcmethods - Run
protoc --go_out=. --go-grpc_out=. service.prototo generate Go stubs and server interfaces - Implement the generated
*Serverinterface by creating a struct that satisfies allrpcmethod signatures - Create a listener on a TCP port using
net.Listen("tcp", ":50051")and register your service withgrpc.NewServer() - Call
Serve()on the server to start listening for incoming gRPC requests - Create a client stub using the generated client code and
grpc.Dial()to connect to the server - Call service methods on the client stub and handle responses and errors appropriately
Code
package main
import (
"context"
"fmt"
"log"
"net"
"google.golang.org/grpc"
pb "your_module/gen/proto"
)
// Server implements the generated GreeterServer interface
type Server struct {
pb.UnimplementedGreeterServer
}
// SayHello implements the Greeter RPC method
func (s *Server) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello, " + req.Name}, nil
}
func main() {
// Start server
listener, err := net.Listen("tcp", ":50051")
if err != nil {
log.Fatalf("Failed to listen: %v", err)
}
grpcServer := grpc.NewServer()
pb.RegisterGreeterServer(grpcServer, &Server{})
log.Println("gRPC server listening on :50051")
if err := grpcServer.Serve(listener); err != nil {
log.Fatalf("Failed to serve: %v", err)
}
}
// Client example
func exampleClient() {
conn, err := grpc.Dial("localhost:50051", grpc.With
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related gRPC Skills
Other Claude Code skills in the same category — free to download.
gRPC Client
Create type-safe gRPC client with error handling
gRPC Streaming
Implement gRPC streaming (server, client, bidirectional)
gRPC-Web
Set up gRPC-Web for browser clients
Protobuf Generator
Generate code from protobuf definitions for multiple languages
gRPC Streaming Patterns
Implement server-streaming, client-streaming, and bidirectional gRPC streams with backpressure
gRPC Interceptors
Add cross-cutting concerns (auth, logging, metrics) using gRPC interceptors
gRPC Error Handling
Map application errors to gRPC status codes correctly
Want a gRPC skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.