Back to guide/AI Tool Configs

CLAUDE.md — Go + Chi Router + PostgreSQL

CLAUDE.md template for Go APIs using Chi, pgx, and idiomatic Go project structure.

claude-mdgochipostgresqlai-config
Edit View
Prompt
# CLAUDE.md

## Project Overview
{{project_name}}{{one-line description}}

## Tech Stack
- Language: Go 1.22+
- Router: chi v5
- Database: PostgreSQL via pgx
- Migrations: goose
- Testing: standard library + testify
- Config: envconfig

## Commands
```bash
go run ./cmd/server          # Start server
go test ./...                # Run all tests
goose -dir migrations up     # Apply migrations
golangci-lint run            # Lint
```

## Directory Structure
```
cmd/
└── server/main.go       # Entrypoint
internal/
├── api/                 # HTTP handlers
│   ├── middleware/       # Auth, logging, CORS
│   └── handlers/        # Route handlers
├── domain/              # Business logic + types
├── repository/          # Database queries
└── config/              # Environment config
pkg/                     # Shared/exported packages
migrations/              # SQL migration files
```

## Conventions
- Follow standard Go project layout
- Errors are values — return them, don't panic
- Use context.Context for cancellation and timeouts
- Interfaces defined by consumers, not providers
- Table-driven tests with clear subtest names
- No init() functions — explicit initialization in main
- Use pgx directly, not GORM

Variables to customize

{{project_name}}{{one-line description}}

Why this prompt works

'Use pgx directly, not GORM' is the kind of specific instruction that prevents Claude from defaulting to the most popular library. Opinionated rules produce consistent code.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.