← ClaudeAtlas

write-sqllisted

Write, review, and maintain PostgreSQL SQL for Agora backend services. Use whenever creating or editing SQL — DAO query files (internal/dao/*.sql), schema migrations (internal/models/migrations/*.sql), or raw SQL embedded in Go: SELECT/INSERT/UPDATE/DELETE queries, DDL (tables, views, indexes, constraints), materialized views, pg_cron jobs.
a-novel-kit/stack · ★ 1 · API & Backend · score 67
Install: claude install-skill a-novel-kit/stack
# SQL Writing Skill SQL appears in two contexts — **DAO query files** and **schema migrations** — each with its own lifecycle and risk profile. Read the section for the task at hand; the PostgreSQL conventions at the end apply to both. **Before writing any SQL**, read the existing files in the same directory and follow their patterns exactly. For migrations, also read the most recent `.up.sql` and `.down.sql` to learn the current schema state before changing it. --- ## After Every Edit Run these in order after changing any SQL file: ``` pnpm format # prettier — this is what formats SQL (via prettier-plugin-sql) pnpm format:go # only when the SQL change rippled into Go files pnpm lint:go # catches any Go-level issues introduced by the SQL change ``` **`pnpm format` is the one that matters for SQL.** The Go-only `pnpm format:go` does not touch `.sql`, so running just that after a SQL edit leaves indentation, comment, and whitespace drift in place. CI's `lint-node` stage runs `prettier --check` and fails on the unformatted file even when Go lint is clean. Run `pnpm format` before pushing any `.sql` edit. Then invoke the **`write-go-tests` skill** to verify or update the DAO test for the changed query. SQL changes often shift query results in ways existing fixtures surface. --- ## DAO Query Files (`internal/dao/*.sql`) DAO query files hold the raw SQL for a single database operation. They are embedded into the companion Go file with `//go:embed` and executed vi