tsq

Generate type-safe SQL query builders from annotated Go structs.

Updated May 28, 2025
One-click install
npx skills add https://github.com/tmoeish/tsq --skill tsq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tsq
Source: https://github.com/tmoeish/tsq/tree/main/skills/tsq
Command: npx skills add https://github.com/tmoeish/tsq --skill tsq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill eliminates the tedious, error-prone work of manually writing and maintaining raw SQL string helpers in Go projects, reducing runtime database errors and boilerplate code for data access layers.

Core Features & Use Cases

  • Typed Query DSL: Compose SQL queries using a fluent, compile-time type-safe API that catches invalid column references and query structure errors before runtime.
  • Automated Code Generation: Generate table metadata, CRUD helpers, pagination, and search utilities directly from annotated Go structs using @TABLE or @RESULT annotations.
  • Use Case: A Go service managing e-commerce order data can annotate Order and Product structs, generate all required database helpers, and build complex paginated, filtered queries with joins and transactions without writing raw SQL.

Quick Start

Use the tsq skill to add type-safe SQL querying to your Go project by annotating your database structs with @TABLE, running the tsq fmt and tsq gen commands, and building queries with the fluent TSQ DSL.

Frequently Asked Questions about tsq

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

FAQPage Schema
How do I generate type-safe SQL queries in Go without writing raw SQL strings?

You can generate type-safe SQL queries in Go by annotating your database structs with @TABLE tags and running code generation commands. This produces a fluent query builder DSL and CRUD helpers that catch invalid column references at compile time, eliminating handwritten SQL string errors.

How does type-safe code generation work for Go database CRUD operations?

Type-safe code generation works by reading annotated Go structs to automatically generate table metadata, CRUD helpers, and pagination utilities. You use the generated fluent TSQ DSL to compose SQL queries with compile-time safety, ensuring invalid query structures are caught before runtime.

Can I use this Go query builder for complex paginated queries, joins, and transactions?

Yes, this Go query builder supports complex paginated queries, joins, and transactions. It generates the necessary metadata and helpers from your annotated structs, allowing you to build dialect-aware SQL execution flows with optimistic locking and soft-delete support without manual SQL maintenance.

What is the best way to eliminate runtime database errors from handwritten SQL in Go projects?

The best way to eliminate runtime database errors from handwritten SQL is to use a type-safe query builder that generates code directly from Go structs. This approach validates column references and query structures during compilation, preventing invalid SQL from reaching your database at runtime.

Does this generated query builder support standard Go database drivers and multiple SQL dialects?

Yes, the generated query builder integrates with standard Go database drivers and supports dialect-aware SQL execution. It automatically adapts the generated SQL syntax to match your specific database dialect while maintaining type safety across all CRUD operations and complex queries.