Agent skill
sqlc
Working with sqlc and database queries
Install this agent skill to your Project
npx add-skill https://github.com/kalbasit/ncps/tree/main/.agent/skills/sqlc
SKILL.md
SQLC Skill
This skill provides instructions for working with sqlc and database queries in the NCPS repository. NCPS supports multiple database engines (SQLite, PostgreSQL, MySQL), and sqlc is used to generate type-safe Go code from SQL queries for each engine.
Configuration
- SQLC Config:
sqlc.yml - Queries:
- SQLite:
db/query.sqlite.sql - PostgreSQL:
db/query.postgres.sql - MySQL:
db/query.mysql.sql
- SQLite:
- Output:
- SQLite:
pkg/database/sqlitedb - PostgreSQL:
pkg/database/postgresdb - MySQL:
pkg/database/mysqldb
- SQLite:
Workflow for Query Changes
Any time a query file (db/query.<engine>.sql) is updated, you MUST follow these steps:
1. Generate SQLC Code
Run the sqlc generate command to update the generated Go files for all engines.
sqlc generate
2. Regenerate Database Wrappers and Models
Run go generate for the pkg/database package. This command uses sqlc-multi-db (via go tool) to automatically:
- Extract the
Querierinterface from thepostgresdbbackend. - Generate the common
Querierinterface inpkg/database/querier.go. - Generate common domain models in
pkg/database/models.go. - Generate database wrappers (
wrapper_sqlite.go,wrapper_postgres.go,wrapper_mysql.go).
go generate ./pkg/database
[!IMPORTANT] Do NOT manually edit
pkg/database/querier.goorpkg/database/models.go. They are fully automated.
Best Practices
-
Consistency: Ensure that equivalent queries exist for all supported engines unless the feature is engine-specific.
-
Linting: Use
sqlfluffto lint and format SQL files before runningsqlc generate.bashsqlfluff lint db/query.*.sql sqlfluff format db/query.*.sql
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
openspec-propose
Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.
openspec-archive-change
Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
openspec-explore
Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
openspec-apply-change
Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
openspec-ff-change
Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.
openspec-continue-change
Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.
Didn't find tool you were looking for?