Files
dbsetup/CLAUDE.md
T
argoyleandClaude Opus 5.5 7bc9f5c2fa
dbsetup / vulnerabilities (pull_request) Successful in 37s
dbsetup / test (pull_request) Successful in 3m47s
pre-commit / pre-commit (pull_request) Successful in 3m49s
feat: move module path to git.unbound.se
The module is now git.unbound.se/unboundsoftware/dbsetup. The API is unchanged. Tags up to v0.1.4 declare gitea.unbound.se/unboundsoftware/dbsetup and stay resolvable through that alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kko4x3MYEcWMMdkx12WpBa
2026-10-17 19:54:58 +02:00

1.8 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

dbsetup is a Go helper module for database connection pool initialization with OpenTelemetry (OTEL) instrumentation. It wraps database connections with OTEL to automatically add SQL queries to tracing spans.

  • Module path: git.unbound.se/unboundsoftware/dbsetup
  • Primary dependencies: sqlx, goose (migrations), otelsqlx (OTEL wrapper)

Common Commands

# Download dependencies
go mod download

# Run tests with race detection and coverage
CGO_ENABLED=1 go test -race -coverprofile=coverage.txt ./...

# Generate coverage report
go tool cover -html=coverage.txt -o coverage.html

# Check for security vulnerabilities
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

# Run pre-commit hooks (add all files first)
git add -A && pre-commit run --all-files

Architecture

Single-package module with one source file (database.go):

  • DatabaseConfig: Configuration struct with connection URL, driver name, and pool settings. Uses struct tags compatible with kong CLI parser.
  • Database: Main handler providing:
    • SetupDB() - Validates database connection and returns Database instance
    • Connect() - Creates OTEL-wrapped connection pool via otelsqlx
    • RunMigrations() - Executes goose migrations from an fs.FS filesystem

Code Quality

Pre-commit hooks enforce:

  • gofumpt formatting (stricter than gofmt)
  • golangci-lint
  • go-imports with local path git.unbound.se/unboundsoftware/
  • Conventional commits format (feat:, fix:, chore:, etc.)
  • Gitleaks for secret detection

CI/CD

Self-hosted Gitea Actions (.gitea/workflows/) run: dependency download → tests with race detector → coverage check → vulnerability scanning → coverage baseline upload/comparison.