backend-database-patterns

backend-database-patterns is a skill for Claude Code, Codex from j4flmao/agent-skills. It costs 136 tokens per session (4,697 once invoked), scanned A, original, MIT.

A guide for designing database tables and queries in backend applications. It covers schema changes, indexes, migrations, ORMs, transactions, and common query problems such as N+1 queries.

In plain words
What is it for?
Use it to plan schemas, improve slow queries, design backward-compatible migrations, choose indexes, and organize database access through repositories or ORMs.
Why use it?
It helps prevent data-layer designs that are hard to change or queries that become slow and difficult to verify.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument; mentions Codex.

Good fit Use it to plan schemas, improve slow queries, design backward-compatible migrations, choose indexes, and organize database access through repositories or ORMs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/j4flmao/agent-skills/database-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add j4flmao/agent-skills --skill database-patterns
Clone the repo
git clone --depth 1 https://github.com/j4flmao/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for backend-database-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/j4flmao/agent-skills/database-patterns/github.svg)](https://agentmods.dev/skills/j4flmao/agent-skills/database-patterns)
Your own site
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/database-patterns"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/database-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for backend-database-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/database-patterns"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/database-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 136 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,697 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Prompt Injection · line 396
    Subtle instructions detected that may alter agent decision-making or introduce hidden biases.
    Fix: Review content for implicit steering or bias. Ensure instructions are explicit and align with the skill's stated purpose.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00136 $0.04697
Opus 5 $0.00068 $0.02348
Sonnet 5 $0.00027 $0.00939
Haiku 4.5 $0.00014 $0.00470

Measured 8d ago against content hash 9785fc2294cd, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

backend-database-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/backend/universal/database-patterns/SKILL.md · 536 lines

How it starts

The opening of the file, as written. The whole thing — 536 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.
  • Transaction boundaries are documented.

Max Response Length

Schema: unlimited. Query fix: 6 lines. Migration: 10 lines.

Architecture Decision Tree

Normalize or Denormalize?

Is the data write-heavy with complex relationships?
  ├── Yes → Normalize (3NF by default)
  └── No → Is there a proven read performance problem (profiled)?
            ├── Yes → Denormalize (with documented trade-offs)
            └── No → Normalize first, optimize later

Primary Key Choice

Is the system single-node with no sharding?
  ├── Yes → BIGSERIAL (auto-increment)
  └── No → Is time-sortable ordering needed?
            ├── Yes → UUID v7 (time-ordered, distributed-safe)
            └── No → UUID v4 (random, distributed-safe)

Read the full file on GitHub · 536 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 536 lines · 136 tokens per session scan A 9785fc2294cd

Subscribe to this mod's changes

backend-database-patterns is a skill published in the GitHub repository j4flmao/agent-skills (23 stars, last pushed 5d ago), licensed MIT. It adds 136 tokens to every session and 4,697 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

event-store-design

Design and implement event stores for event-sourced systems. Use when building event sourcing infrastructure, choosing event store technologies, or implementing event persistence patterns.

wshobson/agents · 33 tokens

convex-explain-app

Explain an existing Convex app — data model + relationships, public vs internal functions, auth/ownership model, components, a request→data flow — read from the schema and function surface. Read-only.

openclaw/clawhub · 47 tokens

platform-custom-field-generate

Use this skill when users need to create, generate, or validate Salesforce Custom Field metadata. Trigger when users mention custom fields, field types, Roll-up Summary fields, Master-Detail relationships, Lookup relationships, formula fields, picklists, dependent (controlling) picklists, referencing a value set from…

forcedotcom/sf-skills · 194 tokens

durable-objects

Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

fcakyon/claude-codex-settings · 22 tokens

field-service-sobject-create-configure

Headless 360 REST API deployment step for creating sObject records. Handles describe-based field discovery, required-field derivation, entity-relationship ordering, and composite graph transactions. Use this skill when a designer skill (or a user directly) needs to create sObject records after design confirmation…

forcedotcom/sf-skills · 74 tokens

nornicdb-grpc

Drive NornicDB over gRPC — the Qdrant-compatible surface (Collections, Points, Snapshots) plus the additive NornicSearch service. Use when ingesting via Qdrant SDKs, migrating from Qdrant, or running hybrid text+vector search from a non-Bolt client. Covers connection, RPC catalog, collection→database mapping…

orneryd/NornicDB · 98 tokens