agentsclimarketplace

Database patterns

Skill subhansh-dev/agent-maxxing/engineering/database-patterns

95+ agent skills, 19 UI components, 7 system prompts from Claude Fable 5, GPT-5.5, Gemini CLI & more. Self-fine-tune your agent: paste one prompt and it reads every skill, internalizes patterns, and becomes elite. Works with Claude Code, Codex, Cursor, OpenCode + 60 more agents.

Install
npx -y skills add subhansh-dev/agent-maxxing --skill database-patterns

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

  • 2 stars2 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

Database design patterns — schema design, indexing, migrations, query optimization.

SKILL.md

2.1 KB, 512 tokens by cl100k_base, as published. Nobody here has run it

Database Patterns

Schema Design

Naming

  • Tables: plural, snake_case (users, order_items)
  • Columns: snake_case (created_at, user_id)
  • Primary keys: id (auto-increment or UUID)
  • Foreign keys: <table>_id (user_id, order_id)
  • Timestamps: created_at, updated_at, deleted_at

Data Types

  • Strings: VARCHAR(n) for known max, TEXT for unlimited
  • Numbers: INTEGER for whole numbers, DECIMAL(p,s) for money
  • Booleans: BOOLEAN or TINYINT(1)
  • Dates: TIMESTAMP for date+time, DATE for date only
  • JSON: JSONB (PostgreSQL) for flexible structure

Relationships

  • One-to-many: foreign key on the many side
  • Many-to-many: junction table
  • One-to-one: foreign key with unique constraint

Indexing

When to Index

  • Columns used in WHERE clauses
  • Columns used in JOIN conditions
  • Columns used in ORDER BY
  • Columns with high cardinality (many unique values)

When NOT to Index

  • Small tables (< 1000 rows)
  • Columns with low cardinality (boolean, status)
  • Columns that are frequently updated
  • Tables with heavy write loads

Index Types

  • B-tree: default, good for most queries
  • Hash: exact match only, very fast
  • GIN: full-text search, JSON queries
  • Partial: index with WHERE clause

Migrations

Rules

  • Every migration must be reversible
  • Never modify a deployed migration
  • Add columns as nullable first, then backfill
  • Create index CONCURRENTLY in production
  • Test migrations on a copy of production data

Safe Migration Pattern

-- Step 1: Add nullable column
ALTER TABLE users ADD COLUMN bio TEXT;

-- Step 2: Backfill
UPDATE users SET bio = '' WHERE bio IS NULL;

-- Step 3: Add NOT NULL constraint
ALTER TABLE users ALTER COLUMN bio SET NOT NULL;

Query Optimization

  • Use EXPLAIN ANALYZE to check query plans
  • Avoid SELECT * — select only needed columns
  • Use LIMIT for large result sets
  • Batch inserts instead of single inserts
  • Use connection pooling
  • Avoid N+1 queries — use JOINs or eager loading

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Gives 1 of the 12 instructions most databases sql skills give in 512 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 concurrentlyhere, and in 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

  • use jsonb for flexible structure

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 328,083. 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.