db-generation-hygiene

Align sqlc-generated Go bindings with migrations and SQL queries.

49|15|Updated Mar 26, 2026
One-click install
npx skills add https://github.com/block/proto-fleet --skill db-generation-hygiene
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-generation-hygiene
Source: https://github.com/block/proto-fleet/tree/main/.claude/skills/db-generation-hygiene
Command: npx skills add https://github.com/block/proto-fleet --skill db-generation-hygiene

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Server DB access goes through sqlc-generated bindings, with the source of truth split between migrations (server/migrations/) and queries (server/sqlc/queries/). Generated Go lives under server/generated/sqlc/.

Core Features & Use Cases

  • Maintains alignment between migrations, queries, and generated sqlc bindings to prevent drift.
  • Guides safe changes to migrations by requiring coordinated generation and commits.
  • Supports review and CI by ensuring generated output reflects SQL source changes.

Quick Start

After completing SQL edits, run just gen from the repo root, verify the expected diffs land under server/generated/sqlc/, and commit SQL sources and generated output together.

Frequently Asked Questions about db-generation-hygiene

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep sqlc generated bindings in sync with database migrations?

To keep sqlc generated bindings in sync with database migrations, run the generation command after editing SQL files and commit both the SQL sources and the generated Go output together to prevent drift.

What causes drift between sqlc queries and generated server bindings?

Drift between sqlc queries and generated server bindings occurs when SQL source files in migrations or queries directories are updated without regenerating the bindings and committing the corresponding Go output.

How do I apply new SQL migrations and update sqlc bindings correctly?

To apply new SQL migrations and update sqlc bindings correctly, create your migration file, run the generation command from the repo root, verify the diffs under the generated directory, and commit all changes together.

Do I need to commit generated sqlc Go files alongside SQL queries?

Yes, you need to commit generated sqlc Go files alongside SQL queries. Committing both the source SQL files and the generated output together maintains consistency and ensures review and CI workflows reflect actual schema changes.

When do I need to regenerate sqlc server bindings?

You need to regenerate sqlc server bindings whenever you edit SQL query files, update the sqlc configuration file, or create new migration files to ensure the generated Go code accurately reflects the current database schema.