db-migration

db-migration is a skill for Claude Code from YuDefine/nuxt-supabase-starter. It costs 16 tokens per session (2,187 once invoked), scanned A, original, MIT.

A procedure for creating Supabase database migrations under project security rules. A migration is a versioned change to database tables, functions, or access policies; Supabase is a hosted PostgreSQL database service.

In plain words
What is it for?
Use it to add or change tables, columns, functions, or row-level security policies in Supabase. It covers creating the migration, writing safe SQL, and running the required checks.
Why use it?
It helps database changes be repeatable, correctly scoped, and less exposed to search-path or access-control problems. It also requires the appropriate local or remote testing path.

Skill for Claude Code

Written for Claude Code: $ARGUMENTS substitution.

Good fit Use it to add or change tables, columns, functions, or row-level security policies in Supabase. It covers creating the migration, writing safe SQL, and running the required checks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/yudefine/nuxt-supabase-starter/db-migration
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 YuDefine/nuxt-supabase-starter --skill db-migration
Clone the repo
git clone --depth 1 https://github.com/YuDefine/nuxt-supabase-starter

Made for: Claude Code.

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 db-migration

README.md
[![agentmods](https://agentmods.dev/badge/skills/yudefine/nuxt-supabase-starter/db-migration/github.svg)](https://agentmods.dev/skills/yudefine/nuxt-supabase-starter/db-migration)
Your own site
<a href="https://agentmods.dev/skills/yudefine/nuxt-supabase-starter/db-migration"><img src="https://agentmods.dev/badge/skills/yudefine/nuxt-supabase-starter/db-migration/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 db-migration

Your own site · 80×15
<a href="https://agentmods.dev/skills/yudefine/nuxt-supabase-starter/db-migration"><img src="https://agentmods.dev/badge/skills/yudefine/nuxt-supabase-starter/db-migration.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 16 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,187 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.
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.00016 $0.02187
Opus 5.5 $0.00006 $0.00875
Sonnet 5.5 $0.00003 $0.00437
Haiku 4.5 $0.00002 $0.00219

Measured 8d ago against content hash ab8b47f53696, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

db-migration 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.

template/.claude/skills/db-migration/SKILL.md · 170 lines

How it starts

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

User Input

$ARGUMENTS

Outline

建立新的 Supabase migration,確保符合 rules/modules/db-schema/supabase/migration.md 的所有規範(該規約帶 paths: gating,三端都投影)。

Step 1: 確認需求

詢問使用者要建立什麼樣的 migration:

  • 新增表格?
  • 修改欄位?
  • 建立函式?
  • 新增 RLS 政策?

Step 2: 建立 Migration 檔案

使用 Supabase CLI 建立 migration(禁止手動建立 .sql 檔案):

supabase migration new <description_in_snake_case>

Step 3: 撰寫 Migration 內容

根據需求撰寫 SQL,必須遵守以下規範:

函式規範(防 search_path injection)
-- ✅ 正確:search_path 必須是空字串
CREATE OR REPLACE FUNCTION schema_name.function_name()
RETURNS return_type
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path = ''  -- 必須是空字串
AS $$
BEGIN
  -- 使用完整路徑:schema_name.table_name
  SELECT * FROM core.users WHERE id = auth.uid();
END;
$$;
-- ❌ 禁止:任何其他 search_path 值
SET search_path = public, pg_temp  -- 禁止
SET search_path = public           -- 禁止
Schema 規範
  • 使用正確的 schema 前綴(如 public.、core.,或專案自訂業務 schema)
  • 所有表格/函式引用使用完整路徑(避免裸表名觸發 search_path resolution)

Step 4: 本地測試與類型產生(自動)

依序執行以下步驟,任何步驟失敗則停止並顯示錯誤。MUST 透過 package.json 偵測 consumer 是走遠端 wrapper(pnpm db:*,含 existing-server / self-hosted)還是本機 Docker。NEVER 看到遠端 wrapper 就改跑本機 supabase start。

set -e   # 多行指令任何一步失敗就整段停(下面用 `|| exit`/`rc=$?` 明列處理的步驟除外)
# 從 package.json 讀 types 路徑(若有自訂);fallback 到 conventional locations
# 避開頂層 return(Node script 不允許)— 用 if/else 與 .find()
TYPES=$(node -e "
  const fs = require('fs');
  const pkg = require('./package.json');
  const custom = pkg.config && pkg.config.dbTypesPath;
  const candidates = [
    'packages/core/app/types/database.types.ts',
    'app/types/database.types.ts',
    'shared/types/database.types.ts',
    'src/types/database.types.ts',
  ];
  const path = custom || candidates.find(function(p) { return fs.existsSync(p); }) || 'app/types/database.types.ts';
  console.log(path);
")

USE_DB_WRAPPER=$(node -e "process.exit(require('./package.json').scripts?.['db:reset'] ? 0 : 1)" 2>/dev/null && echo yes || echo no)
USE_DB_COPY=$(node -e "process.exit(require('./package.json').scripts?.['db:copy'] ? 0 : 1)" 2>/dev/null && echo yes || echo no)

if [ "$USE_DB_COPY" = yes ]; then
  # forward-only 第二段:在臨時副本上重放 + lint + 重生 types,用完 drop;NEVER reset、NEVER 對主線 DB db:migrate
  # (副本契約見 vendor/snippets/worktree-db-isolation/README.md § 10;失敗一律停下,NEVER 退回 db:reset/主線 db:migrate)
  # `--drop` 在副本不存在時本來就 exit 0(契約 § 10);drop 失敗不能吞——否則 `--purpose schema` 沿用殘留舊副本,驗到的是舊狀態
  pnpm db:copy --drop || exit 1
  pnpm db:copy --purpose schema || exit 1
  # set -e 下 `a && b; rc=$?` 會在 a/b 失敗時直接退出、跳過 drop:改 `|| rc=$?` 讓 drop 一定跑
  rc=0
  { pnpm db:migrate --target copy && pnpm db:types --target copy && pnpm db:lint --target copy; } || rc=$?   # lint 必須零警告
  pnpm db:copy --drop || echo '⚠ 臨時副本沒 drop 乾淨:pnpm db:copy --list 查' >&2
  [ "$rc" -eq 0 ] || exit "$rc"
  pnpm typecheck
elif [ "$USE_DB_WRAPPER" = yes ]; then
  # 遠端 / existing-server:走 pnpm db:*(wrapper 會擋本機 Docker;db:reset 內部跑 db:types 寫到 $TYPES)
  # 只有 per-worktree 拓樸(target mode,只重建自己的 clone)才准 reset;
  # shared 拓樸共用 DB NEVER reset(判定見 [[db-topology-invariant]] § Forward-only)→ 交 CI supabase-check,沒接就停
  f=$(ls scripts/supabase/db-reset.sh scripts/db-reset.sh 2>/dev/null | head -1)
  if [ -z "$f" ] || ! grep -qE "reset_target|Target mode never claims" "$f"; then
    if [ ! -f .github/workflows/supabase-check.yml ]; then
      echo 'shared 拓樸且缺 .github/workflows/supabase-check.yml:無處驗 migration 重放,停下;先依 vendor/snippets/supabase-ci/README.md 接上 supabase-check' >&2
      exit 1
    fi
    # 第一段(pnpm db:copy 導入前):reset 重放、lint、types drift 交 PR 的 CI supabase-check
    echo 'DEFERRED_TO_CI: shared 拓樸不 reset 共用 DB;migration 重放、db lint、types drift 交 PR 的 supabase-check'
    pnpm typecheck
    exit $?
  fi
  pnpm db:reset
  pnpm db:lint        # 安全檢查(必須零警告:wrapper 契約沒有 --fail-on,exit code 不擋 warning,要讀輸出確認)
  pnpm typecheck
else
  # 本機 Docker(this-machine;沒有 pnpm db:reset wrapper)
  supabase db reset
  supabase db lint --level warning --fail-on warning
  # 直接重導向到 $TYPES — 不用 tee(pipeline 會吞 supabase gen types 失敗狀態)
  supabase gen types typescript --local > "$TYPES"
  pnpm typecheck
fi

Read the full file on GitHub · 170 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 · 170 lines · 16 tokens per session scan A ab8b47f53696

Subscribe to this mod's changes

db-migration is a skill published in the GitHub repository YuDefine/nuxt-supabase-starter (45 stars, last pushed yesterday), licensed MIT. It adds 16 tokens to every session and 2,187 once invoked, about $0.0001 per session on Opus 5.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-11-22.

Related

db-migration compared with skills from other repositories

db-migration next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
db-migrationYuDefine/nuxt-supabase-starterSkill45yesterdayMITA16Claude Code
explorersupabase/supabaseSkill116ktodayApache-2.0A27Claude Code
nw-database-technology-selectionnWave-ai/nWaveSkill63611d agoMITA38Claude Code
supabasej4flmao/agent-skillsSkill4613d agoMITA71Claude Code, Codex
srtd-clit1mmen/srtdSkill10526d agoMITA75Claude Code
supabasemartineserios/thebranaSkill38d agoMITA58Claude Code
upgrade-people-memorymichelgrolet/people-memory-mcpSkill222d agoMITA94Claude Code, Codex