mcpField
S
supabase-cli

supabase-cli

github.com/fcakyon开发1.2k72 次安装今天更新
代码仓库

关于 supabase-cli

Supabase CLI Skill 为开发者提供使用 `supabase` 命令行进行本地开发、数据库迁移、Edge Functions 和项目管理的指引。内容按任务场景组织,并包含常见命令和工作流。

主要功能

  1. 01初始化并运行本地环境
  2. 02创建和应用数据库迁移
  3. 03开发与部署 Edge Functions
  4. 04管理项目、密钥和组织
  5. 05检查数据库并生成类型

适用场景

  1. 01搭建 Supabase 本地开发环境
  2. 02将本地数据库变更保存为迁移
  3. 03本地调试并部署 Edge Function
  4. 04检查慢查询和表大小

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/fcakyon/claude-codex-settings --skill supabase-cli

安装后在 Claude Code 中输入/supabase-cli确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
examples.yaml
references/commands/
functions.md
gen.md
init.md
link.md
login.md
network-bans.md
projects.md
pull.md
secrets.md
start.md
status.md
stop.md
vanity-subdomains.md
references/config/
diff.md
pull.md
push.md
references/db/
advisors.md
diff.md
dump.md
lint.md
pull.md
push.md
query.md
reset.md
schema-declarative-generate.md
schema-declarative-sync.md
references/domains/
activate.md
references/functions/
new.md
serve.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