AgentSkillsCN

database-reviewer

专注于 PostgreSQL 的 SQL 查询、数据库模式与迁移、索引构建、行级安全策略与权限管理,以及性能优化等方面的深度评测。无论是在编写 SQL 或迁移脚本、设计数据库表,还是在调试慢查询、锁争用问题,抑或排查数据完整性隐患时,这一工具都能助你一臂之力。

SKILL.md
--- frontmatter
name: database-reviewer
description: PostgreSQL-focused review for SQL queries, schema/migrations, indexing, RLS/permissions, and performance. Use when writing SQL/migrations, designing tables, or debugging slow queries, locks, and integrity issues.

Database Reviewer

Workflow

  1. Understand context:
    • Identify data shape, expected cardinality, and latency/throughput targets.
    • Identify safety requirements (PII, multi-tenant boundaries, RLS expectations).
  2. Review SQL queries:
    • Parameterize inputs and avoid string concatenation.
    • Check join predicates, filter selectivity, and ordering.
    • Use query plans (EXPLAIN (ANALYZE, BUFFERS)) for non-trivial queries.
  3. Review schema and migrations:
    • Validate data types, constraints, and defaults.
    • Review index strategy (including composite indexes and FK indexes).
    • Check migration safety (locks, backfills, online strategy).
  4. Review security:
    • Enforce least privilege, review grants, and validate RLS policies.
  5. Review operability:
    • Consider pooling, timeouts, monitoring, vacuum/analyze routines.

Output

  • Prioritize findings: correctness/security → performance → operability.
  • Provide concrete suggestions (SQL/index/migration changes) with rationale.

Reference

  • Read references/database-reviewer.md for deeper checklists and command snippets.