sqlc-go

Generate type-safe Go data access code from PostgreSQL SQL queries.

Updated Nov 7, 2025
One-click install
npx skills add https://github.com/m-brady/claude-plugins --skill sqlc-go
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlc-go
Source: https://github.com/m-brady/claude-plugins/tree/main/plugins/sqlc-go-plugin
Command: npx skills add https://github.com/m-brady/claude-plugins --skill sqlc-go

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sqlc, golang-migrate, pgx.

What problem does it solve?

Writing SQL queries and manually mapping them to Go structs is error-prone and time-consuming. This Skill automates Go code generation from SQL, ensuring type safety and significantly reducing boilerplate, so you can focus on application logic.

Core Features & Use Cases

  • Type-Safe Go Code Generation: Automatically generates Go code from your SQL queries, eliminating manual mapping errors and ensuring robust database interactions.
  • PostgreSQL Best Practices: Provides expert guidance on advanced PostgreSQL features like JSONB, arrays, Common Table Expressions (CTEs), and window functions.
  • Migration Management: Seamlessly integrates with golang-migrate for robust and reversible database schema evolution, simplifying your development workflow.
  • Use Case: Need to add a new feature requiring complex database interactions? This Skill helps you define your SQL, generate the Go code, and manage schema changes effortlessly, letting you focus on building features, not fighting with ORMs.

Quick Start

Help me configure sqlc for a new Go project using PostgreSQL and generate a query to list users by email.

Frequently Asked Questions about sqlc-go

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

FAQPage Schema
How do I generate type-safe Go code from SQL queries?

Type-safe Go code generation from SQL queries eliminates manual struct mapping errors. sqlc automatically generates Go types and query methods from your SQL, ensuring compile-time type safety and reducing boilerplate so you focus on application logic.

Can I use sqlc with PostgreSQL and golang-migrate together?

Yes. sqlc integrates seamlessly with golang-migrate for schema management. Configure sqlc v2 for your PostgreSQL engine, organize queries and migrations in separate directories, and golang-migrate handles reversible schema evolution while sqlc generates type-safe data access code.

How do I handle complex PostgreSQL features like JSONB and arrays in Go?

sqlc supports PostgreSQL JSONB and array parameters through type mappings and overrides. Configure emit_json_tags for JSON serialization, specify array handling in overrides, and sqlc generates proper Go types—structs with json tags and slice types—eliminating manual conversion logic.

What's the best way to reduce SQL boilerplate in a Go application?

Automated code generation from SQL queries is the most effective approach. sqlc reads your SQL, generates type-safe Go structs and query functions, and integrates pgx for database operations, cutting boilerplate by 60–80% while maintaining type safety and performance.

Do I need to manually write database interfaces for my Go queries?

No. sqlc can emit Go interfaces automatically via the emit_interface configuration option. This generates query interfaces that match your SQL operations, allowing you to mock and test your data layer without manual interface writing.

When should I not use code generation for my Go SQL layer?

Code generation is less suitable for highly dynamic queries or when queries change at runtime. If your application requires ad hoc, user-defined SQL or complex metaprogramming, a traditional ORM or manual query construction may be more appropriate than static code generation.

Related Skills