database-sql

A skill for designing databases and working with SQL, the language used to store, retrieve, and change structured data. It also covers migrations, ORMs, indexes, and query performance.

In plain words
What is it for?
It is for designing schemas, writing or optimizing SQL, creating migrations, configuring database libraries, debugging slow queries, and adding indexes.
Why use it?
It helps avoid inconsistent data models and slow or difficult-to-maintain database queries.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/asgarovf/locusai/database-sql
Any agent
npx skills add asgarovf/locusai --skill database-sql
Clone the repo
git clone --depth 1 https://github.com/asgarovf/locusai

Made for: Claude Code, Codex.

Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,702 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00035 $0.01702
Opus 5 $0.00017 $0.00851
Sonnet 5 $0.00007 $0.00340
Haiku 4.5 $0.00003 $0.00170

Measured 2d ago against content hash 65fb517e5fc4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

database-sql 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 2d 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/database-sql/SKILL.md · 260 lines

How it starts

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

Database & SQL

When to use this skill

  • Designing a database schema
  • Writing or optimizing SQL queries
  • Creating database migrations
  • Setting up an ORM (Prisma, Drizzle, TypeORM, SQLAlchemy)
  • Debugging query performance
  • Adding indexes

Schema design principles

Naming conventions

  • Tables: plural, snake_case — users, order_items
  • Columns: snake_case — created_at, first_name
  • Primary keys: id (auto-increment or UUID)
  • Foreign keys: <singular_table>_iduser_id, order_id
  • Indexes: idx_<table>_<columns>idx_users_email
  • Booleans: is_ or has_ prefix — is_active, has_verified

Common patterns

-- Standard table template
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    email VARCHAR(255) NOT NULL UNIQUE,
    name VARCHAR(100) NOT NULL,
    role VARCHAR(20) NOT NULL DEFAULT 'user',
    is_active BOOLEAN NOT NULL DEFAULT true,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

-- Junction table for many-to-many
CREATE TABLE user_roles (
    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    role_id UUID NOT NULL REFERENCES roles(id) ON DELETE CASCADE,
    assigned_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    PRIMARY KEY (user_id, role_id)
);

-- Soft delete pattern
ALTER TABLE users ADD COLUMN deleted_at TIMESTAMPTZ;
CREATE INDEX idx_users_active ON users (id) WHERE deleted_at IS NULL;

Data types guide

Use case PostgreSQL MySQL
Primary key UUID or BIGSERIAL BIGINT AUTO_INCREMENT
Short text VARCHAR(n) VARCHAR(n)
Long text TEXT TEXT
Currency NUMERIC(12,2) DECIMAL(12,2)
Timestamps TIMESTAMPTZ DATETIME
JSON JSONB JSON
Booleans BOOLEAN TINYINT(1)
Enums VARCHAR + CHECK ENUM(...)

Migrations

Prisma

// schema.prisma
model User {
  id        String   @id @default(uuid())
  email     String   @unique
  name      String
  orders    Order[]
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  @@map("users")
}

model Order {
  id        String      @id @default(uuid())
  userId    String      @map("user_id")
  user      User        @relation(fields: [userId], references: [id])
  status    OrderStatus @default(PENDING)
  total     Decimal     @db.Decimal(12, 2)
  createdAt DateTime    @default(now()) @map("created_at")

  @@index([userId])
  @@map("orders")
}

enum OrderStatus {
  PENDING
  CONFIRMED
  SHIPPED
  DELIVERED
  CANCELLED
}

Read the full file on GitHub · 260 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. 2d ago First seen · 260 lines · 35 tokens per session scan A 65fb517e5fc4

Subscribe to this mod's changes

database-sql is a skill published in the GitHub repository asgarovf/locusai (23 stars, last pushed 5mo ago), licensed MIT. It adds 35 tokens to every session and 1,702 once invoked, about $0.0002 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-08-30.