supabase-cli について
Supabase CLI Skillは、`supabase` CLIを使う開発者向けに、ローカル開発、データベースのマイグレーション、Edge Functions、プロジェクト管理を案内します。タスク別に一般的なコマンドやワークフローをまとめています。
主な機能
- 01ローカル環境の初期化と起動
- 02データベースマイグレーションの作成と適用
- 03Edge Functionsの開発とデプロイ
- 04プロジェクト、シークレット、組織の管理
- 05データベースの調査と型の生成
活用シーン
- 01Supabaseのローカル開発環境を構築
- 02ローカルのDB変更をマイグレーションとして保存
- 03Edge Functionをローカルでデバッグしてデプロイ
- 04遅いクエリやテーブルサイズを調査
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ fcakyon/ claude-codex-settings --skill supabase-cliインストール後、Claude Code で/supabase-cliを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/examples.yamlreferences/commands/functions.mdgen.mdinit.mdlink.mdlogin.mdnetwork-bans.mdprojects.mdpull.mdsecrets.mdstart.mdstatus.mdstop.mdvanity-subdomains.mdreferences/config/diff.mdpull.mdpush.mdreferences/db/advisors.mddiff.mddump.mdlint.mdpull.mdpush.mdquery.mdreset.mdschema-declarative-generate.mdschema-declarative-sync.mdreferences/domains/activate.mdreferences/functions/new.mdserve.md詳細
Supabase CLI スキル
supabase CLI を使用したローカル開発、マイグレーション、エッジ関数、プロジェクト管理のためのスキルです。公式ドキュメント:https://supabase.com/docs/reference/cli/about
インストール
# macOS / Linux (Homebrew)
brew install supabase/tap/supabase
# npm
npm install -g supabase
# Windows (Scoop)
scoop bucket add supabase https://github.com/supabase/scoop-bucket.git
scoop install supabase
認証
# Login with access token from https://supabase.com/dashboard/account/tokens
supabase login
# Link to a project
supabase link --project-ref <project-id>
クイック決定ツリー
「ローカル開発が必要な場合」
Local dev?
├─ Initialize project → supabase init
├─ Start local stack → supabase start
│ ├─ Without specific services → supabase start -x studio,imgproxy
│ └─ Status → supabase status
├─ Stop local stack → supabase stop
│ └─ Clean up data → supabase stop --no-backup
├─ View service URLs → supabase status
└─ Bootstrap from template → supabase bootstrap
「データベースのマイグレーションが必要な場合」
Migrations?
├─ Create new migration → supabase migration new <name>
├─ Apply pending migrations → supabase migration up
│ └─ Rollback → supabase migration down
├─ Diff local changes → supabase db diff
│ └─ Save as migration → supabase db diff -f <name>
├─ Pull remote schema → supabase db pull
├─ Push local migrations → supabase db push
├─ Reset local database → supabase db reset
├─ List migrations → supabase migration list
├─ Squash migrations → supabase migration squash
├─ Run arbitrary SQL → supabase db query 'SELECT 1'
├─ Run pgTAP tests → supabase test db
└─ Lint schema → supabase db lint
「エッジ関数が必要な場合」
Edge Functions?
├─ Create new function → supabase functions new <name>
├─ Serve locally → supabase functions serve
│ └─ With env file → supabase functions serve --env-file .env.local
├─ Deploy to project → supabase functions deploy <name>
│ └─ Deploy all → supabase functions deploy
├─ Delete function → supabase functions delete <name>
├─ List functions → supabase functions list
└─ Download function → supabase functions download <name>
「シークレットの管理が必要な場合」
Secrets?
├─ Set secrets → supabase secrets set KEY=value KEY2=value2
├─ Set from .env file → supabase secrets set --env-file .env
├─ List secrets → supabase secrets list
└─ Unset secrets → supabase secrets unset KEY KEY2
「コード生成が必要な場合」
Code gen?
├─ TypeScript types from DB → supabase gen types typescript --project-id <id>
│ └─ From local DB → supabase gen types typescript --local
├─ Signing key → supabase gen signing-key
└─ Bearer JWT → supabase gen bearer-jwt --project-ref <ref>
「データベースの調査が必要な場合」
Inspect?
├─ Database stats → supabase inspect db db-stats
├─ Slow queries → supabase inspect db outliers
├─ Lock monitoring → supabase inspect db locks / blocking
├─ Long running queries → supabase inspect db long-running-queries
├─ Index analysis → supabase inspect db index-usage / unused-indexes
├─ Table sizes → supabase inspect db table-sizes / table-record-counts
├─ Cache hit ratio → supabase inspect db cache-hit
├─ Bloat → supabase inspect db bloat
├─ Vacuum stats → supabase inspect db vacuum-stats
└─ Replication slots → supabase inspect db replication-slots
「プロジェクト管理が必要な場合」
Project management?
├─ Create project → supabase projects create <name> --org-id <id> --db-password <pw> --region <r>
├─ List projects → supabase projects list
├─ Delete project → supabase projects delete --project-ref <ref>
├─ API keys → supabase projects api-keys --project-ref <ref>
├─ Organizations → supabase orgs list / create
├─ Custom domains → supabase domains create / get / activate
├─ Preview branches → supabase branches create / list / delete
├─ Backups (PITR) → supabase backups list / restore
├─ SSO management → supabase sso add / list / remove
└─ Push config → supabase config push
よくあるワークフロー
新しいプロジェクトのセットアップ
supabase init
supabase start
# Make schema changes in Supabase Studio (http://127.0.0.1:54323)
supabase db diff -f initial_schema
supabase stop
マイグレーションのワークフロー
# Create migration from local changes
supabase db diff -f add_profiles_table
# Or write SQL directly
supabase migration new add_profiles_table
# Edit supabase/migrations/<timestamp>_add_profiles_table.sql
# Test locally
supabase db reset
supabase test db
# Deploy to remote
supabase db push
エッジ関数の開発
supabase functions new my-function
# Edit supabase/functions/my-function/index.ts
supabase functions serve # local dev with hot reload
supabase functions deploy my-function
スキーマ変更後の型生成
# From remote project
supabase gen types typescript --project-id <id> > database.types.ts
# From local running instance
supabase gen types typescript --local > database.types.ts
リファレンスインデックス
| カテゴリ | リファレンス | 説明 |
|---|---|---|
| トップレベルのコマンド | references/commands/ | init、start、stop、status、login、link |
| データベース | references/db/ | diff、dump、lint、pull、push、reset、query |
| マイグレーション | references/migration/ | list、new、repair、squash、up、down |
| エッジ関数 | references/functions/ | new、serve、deploy、delete |
| 調査 | references/inspect/ | 20 以上のデータベース調査用サブコマンド |
| 設定 | references/config/ | リモートへの設定のプッシュ |
| ドメイン | references/domains/ | カスタムドメインの管理 |
| テスト | references/test/ | pgTAP データベーステスト |
| 例 | references/examples.yaml | すべてのコマンドの使用例 |
コメント
Markdown 対応