Skip to main content

Claude/ChatGPT Prompt to Build a Go Microservice with gRPC + Connect-go

Go microservice exposing gRPC and REST via Connect-go (buf): proto definitions, auth/logging interceptors, OTel tracing, and Docker for local dev.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt instructs the model to act as a senior Go engineer and build a real, buildable microservice that exposes both gRPC and REST through Connect-go. You fill in [service], the [rpcs] you want, the [datastore], and your [module_path], and it returns proto definitions, buf.yaml / buf.gen.yaml, a wired service implementation, interceptors, OpenTelemetry tracing, a multi-stage Dockerfile, and a docker-compose for local dev.

The structure works because it forces concrete deliverables instead of advice. [rpcs] drives both the proto schema and the generated Connect handlers, so one definition serves internal gRPC callers and a plain REST surface for the frontend. [datastore] shapes the service implementation and the compose file, and [module_path] anchors the file tree and import paths so the output drops cleanly into a repo. Because the prompt demands buildable code rather than pseudocode, the model has to commit to real types, real error mapping to Connect codes, and a generation config that actually runs.

When to use it

  • You're adding a new Go service to a system and want gRPC and REST from a single definition.
  • You need a hot path that's fast and boring, with tracing and auth baked in from the start.
  • You want buf-based codegen scaffolding without hand-wiring buf.gen.yaml yourself.
  • You're standing up a service plus its datastore for local dev via docker-compose.
  • You want auth and structured logging interceptors in place before handlers multiply.
  • You need OpenTelemetry spans crossing the RPC boundary and into DB calls.
  • You want a reproducible local stack you can hand to a teammate to run with one command.

Example output

Expect the full file tree under your [module_path] first, then the key files: the .proto for your [rpcs], the buf config, the server implementation against [datastore], the auth and logging interceptors, the multi-stage Dockerfile, and the compose file. The implementation maps datastore and validation failures to appropriate Connect error codes rather than leaking raw errors. It closes with a curl example hitting REST and a grpcurl example hitting gRPC, so you can verify both surfaces immediately.

Pro tips

  • Name [rpcs] precisely (e.g. CreateUser, GetUser, ListUsers) — they become both proto methods and Connect handlers, so vague names produce vague schemas.
  • Get interceptors in early. Bolting auth and tracing onto [rpcs] later means touching every handler.
  • Set [datastore] to what you'll actually run; it drives the compose service and the error mapping to Connect codes.
  • Use a real [module_path] matching your VCS host so generated imports and the file tree are correct on first paste.
  • If the model returns pseudocode, push back and ask it to make buf generate succeed — the prompt's whole point is buildable output.
  • Ask for the curl and grpcurl examples to be runnable against the compose stack so you can smoke-test both protocols.

Frequently Asked Questions

Why use Connect-go instead of plain gRPC or REST?
Connect-go lets one proto definition serve both gRPC for internal callers and ordinary REST for the frontend, so you avoid maintaining two API layers. The prompt generates the buf config and handlers for both surfaces from your single set of `[rpcs]`.
Does the generated code actually build with buf?
The prompt explicitly demands working code that builds with buf and runs, not pseudocode. If the model returns sketches, ask it again to ensure `buf generate` succeeds, since buildable output is the stated requirement.
Can I swap PostgreSQL for another datastore?
Yes. Set the `[datastore]` variable to whatever you use, and it shapes the service implementation, the error mapping to Connect codes, and the docker-compose service for local development.
Does it include observability out of the box?
Yes. It asks for OpenTelemetry tracing with spans across the RPC boundary and into DB calls, plus structured request logging via an interceptor, so you get traces and logs without retrofitting them later.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Rust & Go Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support