agentsclimarketplace

Database

Skill iceflower/agent-skills/database

Agent Skills 오픈 표준 기반 AI 코딩 에이전트용 스킬 컬렉션 (Java, Kotlin, Spring, NestJS, K8s, Terraform, GraphQL, gRPC, OpenTelemetry, a11y, i18n 등 60개)

Install
npx -y skills add iceflower/agent-skills --skill database

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Framework-agnostic database rules including migration conventions, query performance, transaction management, concurrency control (optimistic/pessimistic locking), backup strategies, replication patterns, connection pool tuning, and CDC. Includes MySQL and PostgreSQL specific guides. Use when writing SQL or designing database access.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.2 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it

Database Rules

1. Migration File Conventions

Naming Format

V{version}__{description}.sql
ElementRuleExample
VersionSequential number or timestampV1, V20240115
SeparatorDouble underscore __V1__
DescriptionSnake_case, descriptivecreate_users_table

Migration Examples

V1__create_users_table.sql
V2__add_email_index_to_users.sql
V3__create_orders_table.sql
V4__add_status_column_to_orders.sql

Migration Rules

  • Never modify a migration that has been applied to any environment
  • Each migration must be idempotent where possible (use IF NOT EXISTS, IF EXISTS)
  • Include both schema and essential seed data in migrations
  • Test migrations against a copy of production data before applying

Migration Safety Checklist

OperationRiskPrecaution
Add column (nullable)LowSafe — no data rewrite needed
Add column (NOT NULL)MediumRequires default value or backfill
Drop columnHighEnsure no application code references it
Rename columnHighUse two-phase: add new → migrate → drop old
Add indexMediumUse CONCURRENTLY on large tables (Postgres)
Drop tableHighVerify no foreign keys or application refs
Change column typeHighMay require full table rewrite

Rollback Strategy

  • Write corresponding rollback scripts for each migration
  • For irreversible changes (drop column), document the decision and ensure backups exist
  • Test rollback scripts in staging before production deployment

2. Query Performance

Index Guidelines

  • Add indexes on columns used in WHERE, JOIN, ORDER BY
  • Use composite indexes for multi-column queries (column order matters)
  • Avoid over-indexing — each index slows down writes
  • Monitor slow query logs to identify missing indexes

Composite Index Column Order

Index (a, b, c) supports:
  ✅ WHERE a = ?
  ✅ WHERE a = ? AND b = ?
  ✅ WHERE a = ? AND b = ? AND c = ?
  ✅ WHERE a = ? ORDER BY b
  ❌ WHERE b = ?           (leftmost prefix not satisfied)
  ❌ WHERE b = ? AND c = ? (leftmost prefix not satisfied)
  • Place equality columns before range columns
  • Place high-selectivity columns first

Query Best Practices

  • Use pagination for list queries — never fetch unbounded result sets
  • Avoid SELECT * — specify only needed columns for large tables
  • Use EXISTS instead of COUNT for existence checks
  • Avoid complex subqueries — prefer JOIN for readability and performance

Pagination Patterns

PatternProsConsBest For
Offset-basedSimple, page navigationSlow on large offsetsSmall datasets
Cursor-basedConsistent, fastNo random page accessLarge datasets
Keyset-basedFast, no offset overheadRequires unique sort keyFixed sort order
-- Offset-based (simple but slow for large offsets)
SELECT * FROM users ORDER BY id LIMIT 20 OFFSET 100;

-- Cursor-based (fast and consistent)
SELECT * FROM users WHERE id > :last_seen_id ORDER BY id LIMIT 20;

N+1 Query Detection

Symptom: N similar queries in logs for a single operation

-- 1 query to fetch users
SELECT * FROM users WHERE status = 'ACTIVE';

-- N queries to fetch each user's orders (BAD)
SELECT * FROM orders WHERE user_id = 1;
SELECT * FROM orders WHERE user_id = 2;
...

-- Fix: single join query
SELECT u.*, o.* FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.status = 'ACTIVE';

3. Transaction Management Principles

General Rules

RuleReason
Keep transactions as short as possibleReduces lock contention
No external API calls inside transactionsPrevents long-held locks on timeout
Use read-only transactions for readsEnables query optimizations
Default to reusing existing transactionAvoids unnecessary overhead
Use independent transactions sparinglyCan cause deadlocks

Scope Example

1. Read data (inside transaction or read-only)
2. Call external API (outside transaction)
3. Write result (separate transaction)

Isolation Levels

LevelDirty ReadNon-Repeatable ReadPhantom ReadUse Case
READ UNCOMMITTEDPossiblePossiblePossibleAlmost never appropriate
READ COMMITTEDNoPossiblePossibleDefault for most databases
REPEATABLE READNoNoPossibleFinancial calculations
SERIALIZABLENoNoNoCritical consistency needs
  • Default to database's built-in isolation level (usually READ COMMITTED)
  • Only increase isolation when business logic requires stronger guarantees
  • Higher isolation = more locking = lower concurrency

Deadlock Prevention

  • Always acquire locks in a consistent, predictable order
  • Keep lock scope as small as possible
  • Set statement/query timeouts to avoid indefinite waits
  • Log and monitor deadlock occurrences

4. Data Integrity

Constraints

ConstraintPurposeWhen to Use
PRIMARY KEYUnique row identityEvery table
FOREIGN KEYReferential integrityRelated tables
UNIQUEPrevent duplicate valuesBusiness-unique columns (email, etc.)
NOT NULLPrevent missing valuesRequired fields
CHECKValidate value range/formatEnum-like or bounded values
DEFAULTProvide fallback valueOptional fields with sensible default

Rules

  • Enforce data integrity at the database level, not just application level
  • Application validations may be bypassed; database constraints are the last line of defense
  • Use ON DELETE CASCADE cautiously — prefer explicit application-level deletion

5. Anti-Patterns

  • Unbounded queries without pagination
  • SELECT * on large tables
  • N+1 query patterns (loop of individual queries)
  • Long-running transactions with external calls
  • Missing indexes on frequently queried columns
  • Modifying applied migration files
  • No slow query monitoring
  • Using database as a message queue
  • Storing large blobs in relational tables without evaluating object storage
  • Missing foreign key constraints on related tables
  • Using FLOAT/DOUBLE for monetary values (use DECIMAL/NUMERIC)

Additional References

What ships with it: 5 files

35.5 KB alongside SKILL.md, 1 of them executable

scripts/

Gives 0 of the 12 instructions most databases sql skills give in ~1.6k tokens

Counted across 589 of the 662 authors here whose files we hold, read 2026-08-07

  • Use parameterized queriesin 37 of 589, across 34 files
  • Use timestamptz for timestampsin 30 of 589, across 14 files
  • Index foreign keysin 29 of 589, across 18 files
  • Create indexes concurrentlyin 29 of 589, across 24 files
  • Use numeric type for moneyin 25 of 589, across 8 files
  • Use cursor pagination instead of offsetin 24 of 589, across 17 files
  • Select only required columnsin 24 of 589, across 20 files
  • Add indexes manually on foreign key columnsin 22 of 589, across 12 files
  • Normalize to third normal formin 19 of 589, across 10 files
  • Configure connection poolingin 19 of 589, across 17 files
  • Put equality columns before range columns in indexesin 18 of 589, across 10 files
  • Read individual rule files for detailed explanationsin 18 of 589, across 4 files

Said here and by no other author read

  • paginate list queries

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 327,069. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.