Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Sequelize Pro

ASecurity

Sequelize ORM guidance — models, associations, migrations, transactions, and production-safe configuration.

2 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentsgosqlnodeexpressapidatabasebackendperformance

Works with

cliapi

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add aicodedecode/awesome-muse-skills --skill sequelize-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sequelize Pro?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Sequelize Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aicodedecode-sequelize-pro/badge)](https://www.skillsdirectory.com/skills/aicodedecode-sequelize-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: sequelize-pro
description: Sequelize ORM guidance — models, associations, migrations, transactions, and production-safe configuration.
category: development
---

## Overview

Sequelize is the battle-tested Node.js ORM with support for Postgres, MySQL, MariaDB, SQLite, and MSSQL. Its model-definition API, rich association system, and mature migration tooling (via sequelize-cli) have powered Node backends for over a decade. It's less fashionable than newer ORMs but deeply understood — and its sharp edges are well documented.

The keys to Sequelize are: define models explicitly, use `include` deliberately (it's a join — understand the SQL), migrate with the CLI, and never let `sync()` near production. This skill covers idiomatic Sequelize for apps that need to run reliably for years.

## When to use

- Maintaining or building a Node.js app on Sequelize.
- Defining models, associations, and indexes.
- Writing migrations with sequelize-cli.
- Fixing N+1 queries or slow `include` usage.
- Managing transactions correctly.
- Configuring connection pooling for production.
- Migrating from Sequelize to another ORM (or vice versa).

## Core concepts

- **Model definitions.** `sequelize.define` or `Model.init` with explicit attribute types, `allowNull`, defaults, and validations. Explicit beats inferred — declare everything the table needs.
- **Associations.** `hasMany`/`belongsTo`/`belongsToMany` declare relations and generate both the foreign keys and the `include` machinery. Define both sides; through-models for many-to-many carry their own attributes.
- **`include` is a join.** Eager loading via `include` generates JOINs (or separate queries with `separate: true`). Understand which one you're getting — the SQL shape determines performance.
- **Migrations via CLI.** `sequelize-cli` generates timestamped migration files with `up`/`down`; `db:migrate` applies them. Write `down` properly — rollbacks happen at 3am and must work.
- **Transactions.** `sequelize.transaction(async (t) => {...})` with the transaction passed to every query inside (`{ transaction: t }`). Forgetting to pass `t` is the classic Sequelize bug — the query runs outside the transaction silently.
- **CLS for implicit transactions.** `cls-hooked` namespace can propagate transactions implicitly, removing the need to pass `t` everywhere — at the cost of spooky action at a distance. Explicit passing is easier to reason about.
- **Scopes.** `defaultScope` and named scopes encapsulate common filters (e.g., excluding soft-deleted or draft records). Beware `defaultScope` hiding data in surprising contexts — prefer explicit named scopes.
- **Hooks.** `beforeCreate`/`afterUpdate` etc. for audit fields, denormalization, and side effects. Keep them light; heavy hooks create invisible coupling and slow bulk operations.
- **Paranoid (soft deletes).** `paranoid: true` adds `deletedAt` filtering to all queries — remember it affects unique constraints and counts, and use `paranoid: false` explicitly when you need the truth.
- **Connection pooling.** Configure `pool: { max, min, acquire, idle }` per environment; set `acquire` timeouts so a saturated pool fails fast instead of hanging.
- **Raw queries.** `sequelize.query` with replacements (never string interpolation) for reporting, CTEs, and anything the model API can't express cleanly.
- **Dialect options.** Each supported database has quirks (MySQL backticks, MSSQL top, Postgres returning) — Sequelize abstracts most, but test against your real dialect.
- **Migrations vs sync.** `sequelize.sync()` is for prototypes and tests; production schema changes go through migrations, always.
- **Bulk operations.** `bulkCreate`/`update`/`destroy` with `individualHooks` considerations — hooks don't run by default on bulk ops, which surprises people relying on them.

## Practical workflow

1. **Define models explicitly.** Attributes with types and constraints, associations on both sides, indexes for hot paths, `underscored: true` if your DB convention is snake_case.
   ```js
   const Order = sequelize.define("Order", {
     status: { type: DataTypes.STRING, allowNull: false, defaultValue: "pending" },
     total: { type: DataTypes.DECIMAL(10, 2), allowNull: false },
   }, { underscored: true, indexes: [{ fields: ["status", "created_at"] }] });
   Order.hasMany(OrderItem, { foreignKey: "order_id" });
   OrderItem.belongsTo(Order, { foreignKey: "order_id" });
   ```
2. **Write migrations for every schema change.** `npx sequelize-cli migration:generate --name add-orders`; implement `up` and `down`; run `db:migrate` in the deploy pipeline, not at app boot.
3. **Query with intent.** `findAll` with explicit `attributes` and `include` (with nested `attributes`); paginate with `limit`/`offset` or keyset; avoid `findAll` without limits.
   ```js
   const orders = await Order.findAll({
     attributes: ["id", "status", "total"],
     include: [{ model: OrderItem, attributes: ["sku", "qty"] }],
     where: { status: "paid" },
     order: [["created_at", "DESC"]],
     limit: 20,
   });
   ```
4. **Transact explicitly.** Pass `{ transaction: t }` to every query inside the callback; keep transactions short; retry on serialization failures.
   ```js
   await sequelize.transaction(async (t) => {
     const order = await Order.create({...}, { transaction: t });
     await Inventory.update({...}, { where: {...}, transaction: t });
   });
   ```
5. **Use scopes deliberately.** Named scopes for common filters (`Order.scope("paid")`); avoid `defaultScope` magic that hides rows.
6. **Handle raw SQL safely.** `sequelize.query("SELECT ... WHERE status = :status", { replacements: { status }, type: QueryTypes.SELECT })` — replacements, never interpolation.
7. **Configure pooling per environment.** Dev small, prod sized to workload; `acquire` timeout to fail fast; monitor pool wait times.
8. **Test with migrations.** Test databases built via `db:migrate` (not `sync`) so tests exercise the real schema path; seed with factories.

## Common pitfalls

- **Forgetting `{ transaction: t }`** — queries silently running outside the transaction; the #1 Sequelize bug.
- **`sync()` in production** — schema drift and data loss; migrations only.
- **N+1 via lazy access** — touching associations in loops; `include` them up front.
- **Unbounded `findAll`** — no limit on a growing table; always paginate.
- **`include` without attribute limits** — selecting entire joined tables; restrict `attributes` at every level.
- **Hooks not running on bulk ops** — `bulkCreate` skipping `beforeCreate`; know when hooks fire.
- **Paranoid surprises** — soft-deleted rows breaking unique constraints and counts; design for it.
- **`defaultScope` hiding data** — filters applied where you forgot; prefer explicit named scopes.
- **String-interpolated raw queries** — SQL injection; always use `replacements`.
- **Pool exhaustion** — too-small pools under load with no `acquire` timeout; size and monitor.
- **Missing `down` migrations** — rollbacks impossible at 3am; write both directions.
- **Timezone mishandling** — configure `timezone` explicitly; store UTC, convert at the edge.

Attribution

aicodedecodeaicodedecode
View sourceSee grades on GitHubMore from aicodedecode →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →