Backend Database Patterns

Use when the user asks about database schema design, slow queries, indexes, EXPLAIN ANALYZE, N+1 problems, transactions, keyset pagination, connection pooling or repository pattern. Produces schema, index and query fixes. Not for engine internals (use architecture-postgresql-internals) or migrations tooling (use database-migration).

45 stars 6 forksDatabases

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add j4flmao/agent-skills --skill backend-database-patterns
Manual install
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p ~/.claude/skills
cp -r /tmp/agent-skills/skills/backend/universal/database-patterns ~/.claude/skills/backend-database-patterns

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Backend Database Patterns

## Purpose
Design efficient, maintainable database schemas and queries. Every schema change must be backward-compatible. Every query must be verifiable with EXPLAIN ANALYZE.

## Agent Protocol

### Trigger
Exact user phrases: "database design", "schema design", "query optimization", "slow query", "migration", "index", "ORM pattern", "repository pattern", "N+1 problem", "transaction", "table design", "data model".

### Input Context
Before activating, verify:
- The database type is known (PostgreSQL, MySQL, MongoDB, SQLite).
- The ORM or query framework is known (TypeORM, Prisma, SQLAlchemy, Diesel, GORM, Spring Data JDBC/JPA).
- The specific schema, query, or problem is described.

### Output Artifact
No file output unless requested. Produces text guidance.

### Response Format
Schema design:
```
## {entity}
| Field | Type | Constraints | Index |
|-------|------|-------------|-------|
```

Query fix:
```
## Problem: {description}
Root cause: {specific cause}
Fix: {specific change}
Verification: EXPLAIN ANALYZE {query}
```

Migration:
```
## Migration: {description}
Up: {SQL}
Down: {SQL}
Backward-compatible: {yes/no}
```

### Completion Criteria
- [ ] Schema design follows normalization principles (3NF by default).
- [ ] Indexes are specified for every foreign key and filtered column.
- [ ] N+1 queries are identified and fixed.
- [ ] Migration includes up AND down scripts.
- [ ] Migration is verified to be backward-compatible.
Read the full skill on GitHub

Details

Skill name
backend-database-patterns
Path
skills/backend/universal/database-patterns/SKILL.md
License
MIT
Repo updated
17 November 2026

FAQ

What does the Backend Database Patterns skill do?

Use when the user asks about database schema design, slow queries, indexes, EXPLAIN ANALYZE, N+1 problems, transactions, keyset pagination, connection pooling or repository pattern. Produces schema, index and query fixes. Not for engine internals (use architecture-postgresql-internals) or migrations tooling (use database-migration).

How do I install the Backend Database Patterns skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add j4flmao/agent-skills --skill backend-database-patterns. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Backend Database Patterns popular?

It lives in j4flmao/agent-skills, which has 45 GitHub stars and 6 forks.

Related skills

Agent Observability

45

j4flmao/agent-skills

Use when the user asks about agent observability, tracing agent reasoning, debugging an agent loop, OpenTelemetry GenAI spans for LLM calls, LLM cost tracking per agent, agent audit logs or hallucination/eval monitoring in production. Produces instrumentation config, trace schema, dashboards, alerts and cost attribution. Not for generic service tracing without LLMs (use devops-opentelemetry).

DevOps & Cloud

AI Agent Architectures

45

j4flmao/agent-skills

Use when the user asks to build an AI agent, design an agent that calls tools and keeps memory, write an agent system prompt or pick an agent framework (Claude Agent SDK, OpenAI Agents SDK, LangGraph). Produces an architecture brief covering loop, tools, memory, guardrails and evals, routing depth to child skills. Not for workflow patterns (use ai-agentic-workflows).

AI, LLMs & Agents

AI Agent Core Loop

45

j4flmao/agent-skills

Use when the user asks about the agent loop, ReAct vs plan-and-solve, re-planning, Reflexion, an agent stuck in a loop, max iterations or termination conditions. Produces a loop spec or patch with state, success predicate, caps and no-progress detection. Not for overall agent design (use ai-agent-architectures) or tool schemas (use tool-calling-principles).

AI, LLMs & Agents

Cloud Native GCP Bigquery

45

j4flmao/agent-skills

Use when the user asks about BigQuery cost, bytes scanned, partitioning and clustering, slots and editions, slow BigQuery queries, or Dremel and Capacitor internals. Produces table designs, query fixes and a pricing-model choice. Not for warehouse vendor comparison (use data-data-warehouse) or dbt projects (use data-science-analytics-engineering).

Databases

Architecture Database Scaling

45

j4flmao/agent-skills

Use when the user asks how to scale the database, read replicas, table partitioning, sharding, choosing a shard key, Citus, Vitess, resharding or hot partitions. Produces a scaling ladder plan, shard key and routing design. Not for PostgreSQL engine internals (use architecture-postgresql-internals) or NoSQL selection (use data-nosql-database).

Databases

Data Airflow DBT Orchestration

45

j4flmao/agent-skills

Use when the user asks to run dbt from Airflow, Astronomer Cosmos, DbtCloudRunJobOperator, dbt in an Airflow 3 DAG, Asset-based scheduling or orchestrate a daily ETL with Airflow and dbt. Produces the integration pattern, DAG code, model-level retries and CI. Not for general ETL architecture (use data-etl-pipeline).

Databases

Browse the most popular Claude skills, all databases skills, or write your own with the skills generator.