pgx
CLAUDE.md14k starsChanged 3 years agoMITView on GitHub
pgx is a PostgreSQL driver and toolkit for Go (github.com/jackc/pgx/v5). It provides both a native PostgreSQL interface and a database/sql compatible driver. Requires Go 1.25+ and supports PostgreSQL 14+ and CockroachDB. Every checkout has its own PostgreSQL 14-18 and CockroachDB instances, supervised by process-compose. mise run dev starts PostgreSQL 18; tests start other targets on demand and stop them afterwards unless they were explicitly prewarmed. See DEVELOPMENT.md. Do not hardcode database ports. They are allocated per checkout by port-tamer and…
- Reads credentials
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Every checkout has its own PostgreSQL 14-18 and CockroachDB instances, supervised by process-compose.
- Very specific: line 40
Do not hardcode database ports.
- Very specific: line 61
Do not automatically provision or update references/.
- Very specific: line 62
Never run rake references:setup, rake references:update, or any large download on your own initiative.
- Distinctive: line 63
If reference sources are missing, work without them or ask the user.
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
pgx is a PostgreSQL driver and toolkit for Go (github.com/jackc/pgx/v5). It provides both a native PostgreSQL interface and a database/sql compatible driver. Requires Go 1.25+ and supports PostgreSQL 14+ and CockroachDB.
Build & Test Commands
Every checkout has its own PostgreSQL 14-18 and CockroachDB instances, supervised by
process-compose. mise run dev starts PostgreSQL 18; tests start other targets on demand and stop
them afterwards unless they were explicitly prewarmed. See DEVELOPMENT.md.
mise run dev # start PostgreSQL 18 and the database supervisor
mise run dev:all # eagerly start every available database
mise run dev -- -D # ... detached; then `mise run dev:wait`, and
# `mise run dev:down` when finished. Agents must do this.
./test.sh # Full suite against PostgreSQL 18 (the default target)
./test.sh pg16 # Against PostgreSQL 16
./test.sh crdb # Against CockroachDB
./test.sh all # Every target (pg14-18 + crdb)
./test.sh pg16 -run TestConnect # Trailing arguments are passed to `go test`
go test ./... # Also works: mise loads the default target's PGX_TEST_*
go test -race ./... # With the race detector
goimports -w . # Format (always run after making changes)
golangci-lint run ./... # Lint
mise run dev:ports # This checkout's ports and where each server's data lives
mise run db:start pg16 crdb # Prewarm targets; tests then leave them running
mise run db:stop pg16 crdb # Stop prewarmed targets
mise run db:psql # psql against PostgreSQL 18; `mise run db:psql 16` for another
process-compose process logs pg16 # One server's outputDo not hardcode database ports. They are allocated per checkout by port-tamer and read from the
environment (PGPORT, PGPORT_16, CRDB_PORT) or .dev/ports.env; 5432 and 26257 mean nothing
here.
The PGX_TEST_* connection strings have one definition, scripts/lib/test_targets.rb. Add or
change a target there, never in a second copy.
Test Database Setup
The lifecycle scripts handle setup: a PostgreSQL server initializes its cluster on first start and
creates pgx_test with the extensions and auth roles from testsetup/postgresql_setup.sql.
CockroachDB recreates pgx_test after each in-memory restart. Nothing needs to be set up by hand.
Contributors who would rather point pgx at a PostgreSQL server they already have can set
PGX_TEST_DATABASE themselves; see CONTRIBUTING.md. Many tests are skipped unless additional
PGX_TEST_* variables are set (for TLS, SCRAM, MD5, unix socket, PgBouncer testing).
Reference Material
references/ holds read-only reference checkouts used when building pgx — currently the PostgreSQL source tree pinned to REL_18_STABLE. It is gitignored and provisioned on demand: bare mirrors are cached at a machine-level path (/persist/shared/references in a devcontainer, ~/.local/share/pgx/references natively; REFERENCES_MIRROR_DIR overrides) and lightweight local checkouts are created in references/ with rake references:setup. Each checkout has per-instance Git metadata while borrowing the shared mirror's object store. Related tasks: rake references:update, rake references:status, rake references:clean.
- Do not automatically provision or update
references/. - Never run
rake references:setup,rake references:update, or any large download on your own initiative. - If reference sources are missing, work without them or ask the user.
Architecture
The codebase is a layered architecture, bottom-up:
- pgproto3/ — PostgreSQL wire protocol v3 encoder/decoder. Defines
FrontendMessageandBackendMessagetypes for every protocol message. - pgconn/ — Low-level connection layer (roughly libpq-equivalent). Handles authentication, TLS, query execution, COPY protocol, and notifications.
PgConnis the core type. - pgx (root package) — High-level query interface built on
pgconn. ProvidesConn,Rows,Tx,Batch,CopyFrom, and generic helpers likeCollectRows/ForEachRow. Includes automatic statement caching (LRU). - pgtype/ — Type system mapping between Go and PostgreSQL types (70+ types). Key interfaces:
Codec,Type,TypeMap. Custom types (enums, composites, domains) are registered throughTypeMap. - pgxpool/ — Concurrency-safe connection pool built on
puddle/v2.Poolis the main type; wrapspgx.Conn. - stdlib/ —
database/sqlcompatibility adapter.
Supporting packages:
- internal/stmtcache/ — Prepared statement cache with LRU eviction
- internal/sanitize/ — SQL query sanitization
- tracelog/ — Logging adapter that implements tracer interfaces
- multitracer/ — Composes multiple tracers into one
- pgxtest/ — Test helpers for running tests across connection types
Key Design Conventions
- Semantic versioning — strictly followed. Do not break the public API (no removing or renaming exported types, functions, methods, or fields; no changing function signatures).
- Minimal dependencies — adding new dependencies is strongly discouraged (see CONTRIBUTING.md).
- Context-based — all blocking operations take
context.Context. - Tracer interfaces — observability via
QueryTracer,BatchTracer,CopyFromTracer,PrepareTraceronConnConfig.Tracer. - Formatting — always run
goimports -w .after making changes to ensure code is properly formatted. CI checks formatting viagofmt -l -s -w . && git diff --exit-code.gofumptwith extra rules is also enforced viagolangci-lint. - Linters —
govet,ineffassign, andunconvertonly (configured in.golangci.yml). - CI matrix — tests run against Go 1.25/1.26 × PostgreSQL 14-18 + CockroachDB, on Linux and Windows. Race detector enabled on Linux only.
Trending
Less talk lately.about the whole repository
Who's talking about jackc/pgx
- Golang Estonia“PGX Top to Bottom”YouTube · Aug 30, 2023 · 21k views
- Mario Carrion“Golang Microservices: PostgreSQL: sqlx, pgx and sql”YouTube · Feb 4, 2021 · 18k views
- Mario Carrion“Learning Golang: Relational Databases - Introduction to database/sql”YouTube · Nov 19, 2021 · 15k views
- codeHeim“#74 Golang - PostgreSQL with PGX in Go: Step-by-Step Tutorial”YouTube · Jan 29, 2025 · 9.9k views
- Mario Carrion“Learning Golang: Relational Databases - Transactions with PostgreSQL”YouTube · Nov 26, 2021 · 8k views
The biggest 5 of 82 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 82
Talked about on GitHub, YouTube, Stack Overflow, Bluesky, the web and Hacker News (82 times).
On GitHub · 39
- May 21, 2024database/sql/driver: allow driver to entirely override Scan — golang/go82 reactions · 87 comments
- Aug 29, 2022Add support for v5 of the pgx Go driver — sqlc-dev/sqlc49 reactions · 24 comments
- Aug 28, 2018Fails with import errors with modules on Go 1.11 — vektra/mockery31 reactions · 10 comments
- Jan 12, 2021PLEASE REMOVE THE ADVICE TO USE PGX FROM YOUR PAGE — lib/pq29 reactions · 6 comments
- Sep 4, 2024Please add a PGX adapter — go-jet/jet26 reactions · 92 comments
34 more on GitHub
- Feb 17, 2019Too many dependencies — golang-migrate/migrate23 reactions · 29 comments
- Jul 18, 2020proposal: integrate with github.com/jackc/pgx — DataDog/dd-trace-go22 reactions · 25 comments
- Apr 7, 2026x/vulndb: suggestion regarding GO-2026-4772 — golang/vulndb14 reactions · 5 comments
- Aug 13, 2021Migrate to pgx — Masterminds/squirrel14 reactions · 3 comments
- Jul 13, 2020v3 agent: Support jackc/pgx as a postgres driver — newrelic/go-agent14 reactions · 3 comments
- Sep 18, 2024Possible memory leak on macOS running in Docker — golangci/golangci-lint12 reactions · 9 comments
- Sep 7, 2018Context support — lib/pq12 reactions · 14 comments
- Jun 23, 2026fix: cache package facts — golangci/golangci-lint11 reactions · 4 comments
- Apr 7, 2026x/vulndb: suggestion regarding GO-2026-4771 — golang/vulndb11 reactions · 4 comments
- Aug 5, 2019PostgreSQL multiple hosts configuration and database cluster failover — hashicorp/vault11 reactions · 6 comments
- Apr 8, 2025Build fails — caddy-dns/cloudflare10 reactions · 1 comment
- Oct 17, 2022Question: migrate or implement pgx v5 driver — golang-migrate/migrate10 reactions · 3 comments
- Apr 23, 2022ON CONFLICT DO UPDATE requires inference specification or constraint name — ent/ent10 reactions · 4 comments
- Nov 4, 2021Save time.Time type data(local time) with pg timestamp(without timezone) type,fetched data is not correct(force marked as UTC) — go-gorm/gorm9 reactions · 9 comments
- Feb 1, 2020Retry logic can cause queries to be silently performed twice — lib/pq9 reactions · 1 comment
- Nov 6, 2020Why is this in maintenance mode? — lib/pq8 reactions · 11 comments
- Jan 5, 2025Bump pgx to v5.7.2 and update transactionID type to pgtype.Uint64 — ThreeDotsLabs/watermill-sql6 reactions · 4 comments
- Apr 23, 2026chore(deps): bump github.com/jackc/pgx/v5 from 5.8.0 to 5.9.2 — go-gorm/postgres5 reactions · 4 comments
- Mar 12, 2021Normalize UTC timestamps to comply with stdlib — jackc/pgtype5 reactions · 3 comments
- Jun 29, 2026chore(deps): bump github.com/jackc/pgx/v5 from 5.9.2 to 5.10.0 — KooshaPari/zz-aa-dep-CliproxyApiPlusPlus4 reactions · 4 comments
- Apr 22, 2026chore(deps): bump pgx/v5 to 5.9.0 + fix telegram-service security vulns — irfndi/NeuraTrade4 reactions · 4 comments
- Jun 4, 2026chore: bump backend Go security dependencies — KooshaPari/BytePort3 reactions · 3 comments
- May 27, 2026chore(deps): update helm release falco to v9 — pablodelarco/kubernetes-homelab3 reactions · 1 comment
- Apr 23, 2026Bump pgx version to v5 — stripe/pg-schema-diff3 reactions · 2 comments
- Jan 27, 2026feat(components): add pgvector indexer and retriever with pgvector-go — cloudwego/eino-ext3 reactions · 1 comment
- Sep 20, 2024feat: migrate to github.com/jackc/pgx/v5 — dataddo/pgq3 reactions · 2 comments
- Jan 8, 2024Go Api Migration — Bisonai/orakl3 reactions · 2 comments
- Dec 1, 2023Feature: query with Apache Arrow result — marcboeker/go-duckdb3 reactions · 22 comments
- Jun 24, 2026Bump github.com/jackc/pgx/v5 from 5.7.5 to 5.9.2 in /tools/tests in the go_modules group across 1 directory — CaffeeLake/pogocache2 reactions
- Jun 8, 2026build(deps): bump github.com/jackc/pgx/v5 from 5.9.1 to 5.10.0 in /integration — shtdu/ai-together2 reactions · 1 comment
- Apr 23, 2026Bump github.com/jackc/pgx/v5 from 5.9.1 to 5.9.2 in /examples/mobile_flow — Dustin4444/go-oversync2 reactions · 3 comments
- Apr 23, 2026Bump github.com/jackc/pgx/v5 from 5.8.0 to 5.9.2 — Dustin4444/actions-runner-controller2 reactions · 3 comments
- Apr 23, 2026Bump github.com/jackc/pgx/v5 from 5.9.1 to 5.9.2 — Dustin4444/go-oversync2 reactions · 3 comments
- Apr 22, 2026build(deps): bump github.com/jackc/pgx/v5 from 5.4.3 to 5.9.2 — Dustin4444/eth2-beaconchain-explorer2 reactions · 3 comments
On YouTube · 21
- Aug 30, 2023PGX Top to Bottom — Golang Estonia21k views · 16 comments
- Feb 4, 2021Golang Microservices: PostgreSQL: sqlx, pgx and sql — Mario Carrion18k views · 13 comments
- Nov 19, 2021Learning Golang: Relational Databases - Introduction to database/sql — Mario Carrion15k views · 20 comments
- Jan 29, 2025#74 Golang - PostgreSQL with PGX in Go: Step-by-Step Tutorial — codeHeim9.9k views · 9 comments
- Nov 26, 2021Learning Golang: Relational Databases - Transactions with PostgreSQL — Mario Carrion8k views · 18 comments
16 more on YouTube
- Dec 2, 2021Learning Golang: Relational Databases - Bulk Insert with PostgreSQL — Mario Carrion7.1k views · 14 comments
- Feb 9, 2021Golang CRUD via pgx — web 075.5k views · 5 comments
- Jan 15, 2025[1] Расширяем функционал pgx - golang livecoding — laxcity5k views · 3 comments
- Oct 22, 2021Software Architecture in Golang: Security - Databases, SQL Injection and Permissions — Mario Carrion2k views · 8 comments
- Aug 21, 2026¿Postgres en Go sin ORM? Curso completo: database/sql, pgx, sqlc y migraciones — Golandia1.1k views · 1 comment
- Oct 27, 2026Golang SQL: ¿el SQL va en Go o en archivos .sql? Migraciones, go:embed y sqlc — Golandia579 views · 6 comments
- Oct 28, 2026Build a Go API with PostgreSQL | HTTP, JSON & Neon for Beginners — code with lari554 views · 5 comments
- Aug 8, 2026Supabase + Go: Postgres, Auth y Storage sin montar backend (2026) — Golandia471 views · 1 comment
- Jan 25, 2025[2] Расширяем функционал pgx - golang livecoding — laxcity391 views · 6 comments
- Nov 29, 2025Golang - App Go com Neon PostgreSQL - Banco de Dados — Rodrigo M.S.273 views
- Nov 26, 2024PostGIS and Go: A Match Made in Large Z Values with Tom Payne — Crunchy Data207 views
- Oct 14, 2026Sharding, medido: la clave de reparto, el cliente grande y lo que cuesta crecer de 4 a 5 — Cultura DevOps83 views
- Apr 20, 2026🎬+🎶 Forgejo [6cd3f02] — GVG80 views
- Jun 21, 2021jackc/pgx - Grource visualisation — Gourcer71 views
- Nov 1, 2024GitHub - jackc/pgx: PostgreSQL driver and toolkit for Go — GitHub Daily Trend AI Podcast35 views
- Apr 7, 2025How to Fix pgx Scanning Issues with int4range in PostgreSQL — vlogize12 views
On Stack Overflow · 15
- Jan 23, 2022Bulk INSERT in Postgres in GO using pgx15 votes
- Oct 1, 2021Transaction in Golang with PGX5 votes · 1 answer
- Nov 25, 2020GORM create record that might already exist5 votes
- Mar 3, 2024Executing Multiple SQL Statements in Go using pgx3 votes
- Feb 26, 2022How to determine which goroutine is blocking execution?3 votes · 1 answer
10 more on Stack Overflow
- Jun 15, 2021postgres enum with golang pgx3 votes
- Sep 2, 2020How do I batch sql statements with package database/sql3 votes
- Dec 10, 2019How to get Postgresql procedure warning messages?3 votes
- Feb 21, 2024How to run PostgreSql queries without package "database/sql" in Go?1 vote
- Nov 6, 2023How to set an OID for a specifical row column Postgres database table using Go1 vote
- Apr 5, 2023Error while trying to open sql connection via pgx1 vote
- Feb 15, 2023Go type cast fails despite the type being the same1 vote
- Nov 22, 2022Cannot unmarshal string into Go struct field * of type pgtype.Range[github.com/jackc/pgx/v5/pgtype.Date]1 vote
- Mar 26, 2022Create User in postgres with pgx (SQLSTATE 42601)1 vote · 2 answers
- Jun 12, 2019Unmarshaling postgresql jsonb query response string into golang nested struct1 vote
On Bluesky · 4
- Apr 12, 2025Periodic callout to Jackc's Pgx, which is just *absurdly* solid software. Every time I think I've found a bug in it, it turns out to… — @brandur.org11 likes and reposts · 1 reply
- Oct 14, 2023Bonjour et bon samedi ! Vous faites du Go ? Vous utilisez PostgreSQL ? Alors pgx est pour vous ! C'est un drivers et un toolkit pg pour go,… — @ponceto91.bsky.social11 likes and reposts · 1 reply
- Oct 31, 2024📦 jackc / pgx ⭐ 10,677 (+10) 🗒 Go PostgreSQL driver and toolkit for Go — @github-trending.bsky.social2 likes and reposts
- Oct 16, 2023🚀 Skyrocketing! 🚀 (200+ new stars) 📦 jackc / pgx ⭐ 8,261 (+291) 🗒 Go PostgreSQL driver and toolkit for Go — @github-trending.bsky.social0 likes and reposts · 1 reply
On the web · 2
- Feb 13, 2025pgx package - github.com/op0xA5/pgx/v5 - Go Packages — pkg.go.dev
- Jun 1, 2016PGX statements can't handle float64 · Issue #150 · jackc/pgx — google.com
On Hacker News · 1
- Feb 27, 2017Pgx: a PostgreSQL client library for Go – 73% faster than pqsays it tested it1 point
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

