plugin/skills/sql-database-patterns/SKILL.md
Use this skill when the agent is designing schemas, reviewing migrations, tuning queries, modeling NoSQL access patterns, configuring replication, planning partitioning, auditing indexes, or onboarding to database conventions — the database patterns knowledge base for PostgreSQL, MySQL, SQL Server, MongoDB, Redis, Cassandra, DynamoDB engines, schema design, SQL optimization, indexing strategies (B-tree, hash, GIN, GiST, BRIN, partial, covering), partitioning (range, list, hash), replication topologies, NoSQL data modeling, time-series, graph, monitoring, capacity planning, backup and recovery.
npx skillsauth add avav25/ai-assets sql-database-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reference knowledge for relational and NoSQL database engineering — schema design, query optimization, indexing, partitioning, replication, NoSQL modeling, monitoring, and backup.
python-engineer / java-engineer (reference this skill)data-engineerdevops-engineertimestamptz not timestamp; text not varchar; numeric(p,s) for moneypg_stat_statements, pg_stat_user_tables, pg_stat_activity for diagnosticspgaudit for audit trail; pgcrypto for column-level encryptionpg_repack for online bloat reorganization; REINDEX CONCURRENTLY for index bloatpg_basebackup + WAL archivingpg_auto_failover, or cloud-managedinnodb_buffer_pool_size sizing (60-80% RAM)EXPLAIN FORMAT=JSON for execution plan; performance_schema for diagnosticslong_query_time, log_queries_not_using_indexesutf8 (3-byte) — use utf8mb4 (4-byte) for full UnicodeUPDATE STATISTICS after bulk loadssys.dm_exec_query_stats, sys.dm_db_missing_index_details for tuningOPTION (RECOMPILE) sparingly — parameter sniffing is usually preferableBIGSERIAL, UUID) for most tables. Natural keys only when immutable and uniquesnake_case, plural tables (users, orders). FK: {table_singular}_idcreated_at timestamptz DEFAULT now(), updated_at timestamptz on every tablework_mem for hash joins and sortsjoin_collapse_limit or explicit orderMATERIALIZED only for optimization fencesINSERT ... ON CONFLICT (upsert). COPY for bulk. Avoid row-by-row loopsFOR UPDATE SKIP LOCKED for queues. NOWAIT for fast fail. Advisory locks for app coordinationANALYZE after bulk loads. Increase default_statistics_target for skewed distributionsSELECT * in production code — specify columns explicitly= but no range@>, arrays. gin_trgm_ops for LIKE '%term%'WHERE active = true — index only filtered rowsINCLUDE (col) for index-only scansCREATE INDEX ON t (lower(email)) for case-insensitive lookupsREINDEX CONCURRENTLY for bloat. Monitor pg_stat_user_indexes for unused indexespg_auto_failover, or cloud-managed. Test failover regularlyexplain() with executionStats$lookup on large collections — denormalize instead{w: "majority"} for durability; j: true for journaled{service}:{entity}:{id}:{field} — consistent, scannable, eviction-friendlymaxmemory-policy (allkeys-lru for cache, noeviction for queues). Monitor used_memory vs maxmemoryLOCAL_QUORUM for strong consistency, ONE for eventualgc_grace_seconds tuning critical for deletion-heavy workloadsProjectionExpression to minimize read cost. Batch for bulk ops. TTL for auto-expirationpg_stat_statements (query analysis), pg_stat_user_tables (seq scans, dead tuples), pg_stat_activity (locks)autovacuum per table. Monitor n_dead_tup. VACUUM FULL only in maintenance windowspg_repack for online reorganizationpg_basebackup + WAL archiving for PITR. pg_dump for logical backupsmysqldump (logical), xtrabackup (physical, hot), binlog for PITRFORCE ROW LEVEL SECURITY on the table ownersslmode=verify-full). Encryption at rest via disk/tablespace. Column-level (pgcrypto) for PIIpgaudit for DDL/DML audit trail. Log all privileged operations| Workflow | Apply this knowledge |
|---|---|
| Agent(db-engineer) | Auto-loaded |
| /develop (DB work package) | Spawned db-engineer loads this |
| /code-review (migration PRs) | Indexing + schema sections |
| /architecture-design (data model) | NoSQL + partitioning sections |
| /migrate (schema migrations) | Replication + backup sections |
| /bugfix (query/perf) | EXPLAIN + indexing sections |
db-engineer (primary), data-engineer, python-engineer / java-engineer (ORM review), solution-architectdevelopment
Use this skill when running the recurring (daily) knowledge-base rescan for a repo that already has knowledge/.knowledge-sync.yml — the main-thread dispatcher that reads the config, computes the git delta since last_scanned_sha, maps changed paths to affected doc areas, early-exits cheaply when nothing changed, then fans out one Agent(content-writer) per affected area, applies the propose/direct update policy, advances the baseline only on success, and writes an L4 run log — all with the G1 untrusted-content choke-point, secret-scan, deny-list, and budget controls woven in. For first-time setup use /knowledge-sync-init.
development
Use this skill when bootstrapping scheduled knowledge-base sync for a repo that has no knowledge/.knowledge-sync.yml yet — to run one-time setup that detects the knowledge_root from CLAUDE.md/AGENTS.md, maps doc areas to source globs, records opt-in external sources (Linear/Notion/WebFetch, all disabled by default), captures a baseline last_scanned_sha, sets the per-area update policy, generates or seeds knowledge/CONVENTIONS.md, provisions the L4 memory dir, and offers to register the daily routine. Routes ongoing recurring sync operations to /knowledge-sync.
tools
Use this skill when bootstrapping a target repository to be ai-skills-aware — on the first run of any ai-skills workflow in a fresh repo, when adopting the ai-skills plugin in an existing repo, or after upgrading to a plugin version that adds new memory paths or templates, including when the user does not say "init" but asks to "set up" or "onboard" the repo — to detect codebase type, create CLAUDE.md + AGENTS.md scaffolding, initialize the .ai-skills-memory/ directory tree from L1 templates, and configure .gitignore. Idempotent — safe to re-run. Accepts `--codebase-type <type>` and `--overwrite`. Not for re-initializing only memory — use `/memory-init` instead.
tools
Use this skill when extending, repairing, or improving plugin assets, when ingesting a `/feedback` report as a fix-cycle backlog, or when you do not remember which lower-level command is right for the job — the umbrella workflow for ai-skills plugin-asset authoring and maintenance: creating, auditing, fixing, improving, refactoring, and migrating skills, agents, rules, hooks, prompts, schemas, and rubrics inside the plugin. Auto-classifies the request, loads the right knowledge skills (`@prompt-engineering`, `@context-engineering`, `@team-protocols`), and spawns the right subagents (`prompt-engineer`, `system-architect`, `python-engineer`, `software-engineer`, `qa-engineer`, `eval-judge`) via the `Agent` tool.