---
name: "sqlx-general-purpose-sql-extensions"
description: "Query databases and map rows directly to Go structs without heavy ORM overhead using sqlx."
metadata:
  author: "Jason Moiron"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "query into struct sqlx"
  - "sqlx namedexec"
  - "sqlx select slice"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# sqlx Ergonomic SQL Extensions for Go database/sql

Implements jmoiron/sqlx: db.Get for single rows, db.Select for row slices, NamedExec for named parameters (:name), automatic db tag mapping, transactions, and maintaining 100% database/sql compatibility.

## When to Invoke
Invoke this skill whenever you need to:
- query into struct sqlx
- sqlx namedexec
- sqlx select slice

## Execution SOP & Rules
1. Connect: db, err := sqlx.Connect('postgres', connStr); db.SetMaxOpenConns(50).
2. Scan into struct slice: var users []User; err = db.Select(&users, 'SELECT * FROM users WHERE active = $1', true).
3. Query single row: var user User; err = db.Get(&user, 'SELECT * FROM users WHERE id = $1', userID).
4. Tag model structs with db tags: type User struct { ID int `db:'id'`, Name string `db:'name'` }.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
