Home › Go › Go backend CLAUDE.md

Go backend CLAUDE.md

CLAUDE.md for idiomatic Go HTTP services using the standard library, sqlc and table-driven tests.

Claude Code (CLAUDE.md)Go

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

CLAUDE.mdDownload  
# CLAUDE.md

## Commands
- Build: `go build ./...` · Test: `go test ./... -race` · Lint: `golangci-lint run`
- Generate SQL code: `sqlc generate` (after editing `db/queries/*.sql`)

## Layout
- `cmd/server/main.go` wiring only · `internal/http` handlers · `internal/service` logic · `internal/db` sqlc output (do not edit)

## Style
- Idiomatic Go: small interfaces defined by the consumer, accept interfaces return structs.
- Use `net/http` with Go 1.22+ routing patterns (`mux.HandleFunc("GET /users/{id}", ...)`). No web framework unless asked.
- Pass `context.Context` as the first arg through every I/O call.
- Wrap errors: `fmt.Errorf("load user %d: %w", id, err)`. Never ignore an error; never `panic` in request paths.
- Use `log/slog` for structured logs.
- Tests are table-driven with `t.Run`; use `httptest` for handlers.

## Before finishing
- `gofmt` clean, `go vet` clean, tests pass with `-race`.

Related rules

AWS CDK (TypeScript) CLAUDE.md

CLAUDE.md for AWS CDK v2 apps in TypeScript: constructs, least-privilege grants, snapshot tests, and safe deploys.

Claude Code (CLAUDE.md)AWS CDK

Bun runtime CLAUDE.md

CLAUDE.md for TypeScript projects on Bun 1.2+: bun test, Bun.serve, built-in SQLite/Postgres, and bundling.

Claude Code (CLAUDE.md)Bun

Claude Agent SDK CLAUDE.md

CLAUDE.md for building agents with the Claude Agent SDK (Python/TypeScript): options, tools, permissions, and hooks.

Claude Code (CLAUDE.md)LLM apps & agents

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.