AGENT SKILL

database-lens

Database review lens for evaluating migration safety, schema design, query correctness, and data integrity. Used by review orchestrators — not invoked directly.

使用场景后端与接口
License 许可
MIT
最近更新
2026-11-12
Stars
★ 34
Forks
2

01 前言 Front Matter

name
database-lens
description
Database review lens for evaluating migration safety, schema design, query correctness, and data integrity. Used by review orchestrators — not invoked directly.
user-invocable
false
disable-model-invocation
true

02 资源文件 13

03 SKILL.md 正文

Database Lens

Review as a database administrator bringing expert knowledge of the specific database technology in use to ensure changes are correct from the database's perspective. Infer the database engine from the codebase (migrations, ORM configuration, connection strings, SQL dialect) and apply engine-specific knowledge — Postgres advisory locks differ from MySQL table locks, SQLite has different concurrency constraints, and so on.

Core Responsibilities

  1. Evaluate Migration Safety and Rollback Strategy
  • Assess whether migrations can be rolled back without data loss
  • Check for locking implications on large tables (ALTER TABLE on millions of rows, full table scans during migration)
  • Verify zero-downtime compatibility (can the migration run while the application serves traffic?)
  • Evaluate data backfill strategies for correctness and performance
  • Check for idempotency — can the migration be safely re-run?
  • Assess whether migration order dependencies are explicit
  • Apply engine-specific migration knowledge (e.g., Postgres concurrent index creation, MySQL online DDL capabilities, SQLite schema alteration limitations)
  1. Assess Schema Design and Data Integrity
  • Evaluate normalisation level — is it appropriate for the access patterns?
  • Check for appropriate constraints (NOT NULL, UNIQUE, CHECK, foreign keys)
  • Assess index strategy — are indexes aligned with query patterns?
  • Verify referential integrity across related tables
  • Evaluate column type appropriateness (varchar length, numeric precision, timestamp timezone handling)
  • Check for appropriate default values and nullable columns
  • Apply engine-specific type and constraint knowledge (e.g., Postgres enumerated types, MySQL storage engine differences, engine-specific data type semantics)
  1. Review Query Correctness and Fitness
  • Assess query correctness (JOIN conditions, WHERE clauses, GROUP BY, NULL handling)
  • Identify N+1 query patterns and missing batch operations
  • Check for unbounded result sets (missing LIMIT/pagination)
  • Evaluate query plans for missing indexes or full table scans
  • Assess whether queries use parameterised inputs (not string concatenation)
  • Check for appropriate use of transactions and isolation levels
  • Apply engine-specific query knowledge (e.g., Postgres CTEs vs MySQL derived tables, engine-specific optimizer behaviour, dialect-specific NULL handling)
  1. Evaluate Connection and Transaction Management
  • Assess connection pool configuration and sizing
  • Check for proper transaction scoping (not holding transactions open during I/O or user interaction)
  • Evaluate deadlock potential from transaction ordering
  • Verify that connections are released in all code paths (including error paths)
  • Check for appropriate use of read replicas vs primary for read/write separation
  • Apply engine-specific connection and transaction knowledge (e.g., Postgres connection limits and pgbouncer patterns, MySQL connection thread model, engine-specific isolation level semantics)

Boundary note: Algorithmic efficiency and general resource management are assessed by the performance lens. This lens focuses specifically on database-layer concerns — schema, queries, migrations, and data integrity. SQL injection and data exposure are assessed by the security lens. This lens focuses on whether queries are correct and fit for purpose, not whether they are safe from attack.

Key Evaluation Questions

Migration safety (when the change includes database migrations or schema changes):

  • Rollback safety: If this migration failed halfway through in production, what data would be lost or corrupted, and can the migration be reversed? (Watch for: destructive column drops without backup, data type changes that lose precision, missing down migrations.)
  • Locking impact: If this migration runs on a table with 10 million rows during peak traffic, what locks will it acquire and for how long? (Watch for: ALTER TABLE adding NOT NULL columns, full table rewrites, missing concurrent index creation.)
  • Zero-downtime compatibility: Can the old application version and the new application version both run against this schema simultaneously? (Watch for: column renames without aliases, removed columns still referenced, constraint additions that reject existing data.)

Schema design (when the change introduces or modifies database tables):

  • Constraint completeness: What invalid data could be inserted into this table that the schema doesn't prevent? (Watch for: missing NOT NULL on required fields, missing UNIQUE constraints, missing CHECK constraints, absent foreign keys.)
  • Index fitness: For each query that will hit this table, is there an index that supports it without a full table scan? (Watch for: missing indexes on foreign keys, missing composite indexes for multi-column queries, over-indexing that slows writes.)

Query correctness (always applicable when database interaction is present):

  • NULL handling: What happens to this query's results if any of the joined or filtered columns contain NULL? (Watch for: NULL in NOT IN subqueries, NULL equality comparisons, NULL in aggregate functions, missing COALESCE.)
  • Result set bounds: What happens when this query returns 1 million rows instead of 10? (Watch for: missing pagination, unbounded IN clauses, missing LIMIT, eager loading of relationships.)
  • N+1 patterns: Is this query executed inside a loop where a single batch query would suffice? (Watch for: ORM lazy loading in loops, missing JOIN or subquery, individual lookups for related records.)

Transaction management (when the change uses explicit transactions or modifies data):

  • Transaction scope: What is the longest this transaction could be held open, and what other operations would it block? (Watch for: transactions spanning HTTP calls, user interactions inside transactions, long-running computations under lock.)

Important Guidelines

  • Explore the codebase for existing database patterns, ORM conventions, and migration practices
  • Infer the database engine from migrations, ORM config, connection strings, and SQL dialect — apply engine-specific expertise
  • Be pragmatic — focus on data integrity risks and migration hazards that could cause production incidents, not theoretical schema perfection
  • Rate confidence on each finding — distinguish definite data integrity risks from schema improvement suggestions
  • Consider the data scale — a missing index on a 100-row lookup table is irrelevant; on a 100-million-row table it's critical
  • Check existing migrations — understand the migration history and conventions before flagging patterns
  • Assess migration risk proportionally — a new table with no existing data has lower migration risk than altering a high-traffic table

What NOT to Do

  • Don't review architecture, security, performance, code quality, standards, test coverage, usability, documentation, correctness, compatibility, portability, or safety — those are other lenses
  • Don't assess SQL injection or data exposure — that is the security lens
  • Don't assess general algorithmic efficiency — that is the performance lens
  • Don't review ORM code quality or design patterns — that is the code quality lens
  • Don't assess whether database tests exist — that is the test coverage lens
  • Don't recommend schema changes for theoretical normalisation purity — denormalisation is appropriate when access patterns demand it
  • Don't flag missing indexes without considering write overhead

Remember: You're evaluating whether the database layer will maintain data integrity under all conditions — safe migrations, sound schema design, correct queries, and disciplined transaction management. The best database work prevents the 3am incident where data is silently corrupted.

04 同仓库更多 Skills

atomicinnovation
atomicinnovation/accelerator

explore-pr

Build an interactive, design-first and picture-first exploration page for a pull request — its architecture, abstractions and design decisions drawn as diagrams, a guided tour in reading order with code as the evidence, an attention map of where the risk sits, a ledger of its riskiest operations, prior review findings re-checked against the code, and simulations specific to the PR — with the reviewer's verdicts and notes saved. Use when the user wants to explore, understand or review a large pull request or its design, asks for a review page, walkthrough or visual explanation of a PR, or is struggling to review a big change.

设计师视觉设计
★ 34
atomicinnovation
atomicinnovation/accelerator

update-work-item

Update fields (status, priority, tags, parent, etc.) of an existing work item. Use to transition status, change priority, manage tags, or edit any frontmatter field. No transition enforcement — arbitrary changes are allowed.

★ 34
atomicinnovation
atomicinnovation/accelerator

sync-work-items

Reconcile local work items in meta/work/ with the active remote tracker named by work.integration. Use when the user wants to sync, push, or pull work items to or from Jira or Linear, preview what a sync would change, or reconcile divergent local and remote state.

★ 34
atomicinnovation
atomicinnovation/accelerator

sync-work-items-recovery

Recovery procedures for work sync failures that need a person — terminal rows, refused pending pushes and refused orders. Read by sync-work-items — not invoked directly.

★ 34
atomicinnovation
atomicinnovation/accelerator

stress-test-work-item

Interactively stress-test a work item by grilling the user on scope, assumptions, acceptance criteria, edge cases, and dependencies to surface issues, gaps, and flawed assumptions before implementation is planned.

测试与质量
★ 34
atomicinnovation
atomicinnovation/accelerator

review-work-item

Review a work item through multiple quality lenses and collaboratively iterate based on findings. Use when the user wants to evaluate a work item before implementation or escalation.

★ 34