Skip to main content
prompt GP ChatGPT

Go Service taste — Claude prompt for Go backend conventions

A backend engineer's Go preferences handed to the model: which router to use, how to lay out packages, how to handle errors and logs. Handy when the agent scaffolds a service.

Open on GitHub

What Go Service taste does

This prompt gives the model a set of Go conventions to follow. Start with the net/http router shipped in Go 1.22; reach for a framework only when the standard one truly falls short. Layout is cmd/<service>/main.go plus packages under internal/, with pkg/ left out. Keep main.go thin: load config, assemble dependencies, start the server.

Then come the rules people skip. Every function doing I/O takes a context.Context first. Errors get wrapped with fmt.Errorf and %w, and callers check them through errors.Is and errors.As. Logging goes through log/slog as JSON, request ID on each line. Configuration lands in one typed struct at startup, read from environment variables, and a missing required value kills the process right there instead of surfacing later.

On data: hand-written SQL, typed code generated by sqlc, no ORM, and pgx as the Postgres driver behind a connection pool. Interfaces belong in the consuming package, not next to the implementation. Tests are table-driven with t.Run subtests; CI runs go test -race on every pull request, and golangci-lint with a short linter list keeps style in check. The prompt also asks for graceful shutdown on SIGTERM, explicit read, write and idle timeouts on both http.Server and http.Client, /healthz and /readyz endpoints, and no global state or side-effecting init. Goroutines need a named owner and a stop condition, with errgroup for batches.

What it helps with

  • pick a router and package layout for a fresh Go service
  • make error handling consistent with %w and errors.Is
  • switch logging to JSON with a request ID on every line
  • add graceful shutdown and server timeouts before shipping
  • strip global state and side-effecting init from the codebase

Example prompts for the agent

  • Build a Go order service with the standard library router, cmd/orders/main.go plus internal/ packages, and config from environment variables.
  • Refactor this file: wrap errors with %w and replace the logger with log/slog JSON including a request ID.
  • Add SIGTERM graceful shutdown, timeouts on http.Server, and /healthz plus /readyz endpoints.

How to install Go Service taste

How to use

Paste the text at the start of a chat or into project instructions

Questions about Go Service taste

How do I install Go Service taste in Claude?

There is no install command for a prompt: paste its text into the chat or into project instructions. In Claude it sits as the file .claude/commands/prompts.csv.md.

What does Go Service taste do?

It feeds the model Go backend conventions: standard router, cmd/ and internal/ layout, wrapped errors, log/slog, pgx with sqlc, table-driven tests, graceful shutdown.

Do I have to follow every rule?

Each rule carries a confidence score between 0.70 and 0.95. The weakest are generics and sqlc over an ORM, so discuss those with the agent on a small service.

Source text

prompts.csv · CC0-1.0
# Go service taste of a backend engineer
- Use the standard library net/http router from Go 1.22 before reaching for a framework. Confidence: 0.85
- Lay the project out as cmd/<service>/main.go plus internal/ packages, and skip pkg/. Confidence: 0.80
- Keep main.go thin: read config, wire dependencies and start the server. Confidence: 0.90
- Pass context.Context as the first argument to every function that does I/O. Confidence: 0.95
- Wrap errors with fmt.Errorf and %w, and check them with errors.Is and errors.As. Confidence: 0.95
- Log with log/slog in JSON format and include a request ID on every line. Confidence: 0.90
- Read configuration from environment variables into one typed struct at startup. Confidence: 0.85
- Fail fast at startup when required configuration is missing. Confidence: 0.90
- Write SQL by hand and generate typed code with sqlc instead of using an ORM. Confidence: 0.80
- Use pgx as the Postgres driver with a connection pool. Confidence: 0.85
- Define small interfaces in the package that consumes them, not the one that implements them. Confidence: 0.85
- Use table-driven tests with t.Run subtests. Confidence: 0.90
- Run go test with -race in CI on every pull request. Confidence: 0.90
- Lint with golangci-lint using a short, curated list of linters. Confidence: 0.80
- Shut down gracefully on SIGTERM with signal.NotifyContext and server.Shutdown. Confidence: 0.90
- Set explicit read, write and idle timeouts on every http.Server and http.Client. Confidence: 0.90
- Expose /healthz for liveness and /readyz for readiness. Confidence: 0.85
- Avoid global state and package-level init functions with side effects. Confidence: 0.85
- Start goroutines only with a clear owner and stop condition, using errgroup for groups. Confidence: 0.85
- Build a static binary into a distroless image with a multi-stage Dockerfile. Confidence: 0.80
- Add generics only when they remove real duplication. Confidence: 0.70

© f · CC0-1.0 · f/prompts.chat

Similar prompts

All prompts for Backend and APIs →

From the same set91

The whole set →
Error Handling taste A prompt that gives an AI assistant the error-handling taste of a TypeScript backend engineer: validate input, split expected errors from bugs, log once, answer with problem+json. GP ChatGPT ★ 174,676repo stars Kubernetes taste A prompt that hands your AI assistant a platform team's Kubernetes rules: GitOps, probes, resources, pod security. Useful when you ask a model to write or review manifests. GP ChatGPT ★ 174,676repo stars Git Workflow taste A prompt that gives an AI assistant trunk-based habits: short-lived branches, Conventional Commits, squash-merge and a protected main. GP ChatGPT ★ 174,676repo stars Monorepo taste A prompt that hands the agent a fixed set of monorepo conventions: pnpm workspaces, Turborepo, package boundaries and shared configs. Useful when repo structure keeps drifting. GP ChatGPT ★ 174,676repo stars Rust CLI taste A prompt that tells the model how to write a Rust command-line tool: argument parsing, error handling, output streams, tests. GP ChatGPT ★ 174,676repo stars React State Management taste A ruleset for picking React state tools: when to use useState, Zustand, Context and TanStack Query. Helps avoid overbuilt global stores and duplicated state. GP ChatGPT ★ 174,676repo stars Observability taste A prompt that tells an AI assistant how to wire traces, metrics and logs into a service. Handy when you ask a model to write instrumented code. GP ChatGPT ★ 174,676repo stars Python Packaging taste A prompt that hands the model a fixed set of Python packaging rules: pyproject.toml, src/, uv, Ruff. Useful when a new package needs one consistent style. GP ChatGPT ★ 174,676repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor