supabase-best-practices by pedrobarretocw/supabase-best-practices
npx skills add https://github.com/pedrobarretocw/supabase-best-practices --skill supabase-best-practices包含 Clerk 身份验证集成的 Supabase 应用程序的全面安全和性能优化指南。涵盖 10 个类别超过 40 条规则,按影响优先级排序,以指导安全开发和代码审查。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 行级安全 | 关键 | rls- |
| 2 | Clerk 集成 | 关键 | clerk- |
| 3 | 数据库安全 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 高 |
db- |
| 4 | 身份验证模式 | 高 | auth- |
| 5 | API 安全 | 高 | api- |
| 6 | 存储安全 | 中高 | storage- |
| 7 | 实时安全 | 中 | realtime- |
| 8 | Edge Functions | 中 | edge- |
| 9 | 测试 | 中 | test- |
| 10 | 安全 | 中 | security- |
rls-always-enable - 始终在公共模式表上启用 RLSrls-wrap-functions-select - 使用 (SELECT ...) 包装身份验证函数以提高性能rls-add-indexes - 在 RLS 策略使用的列上添加索引rls-specify-roles - 使用 TO authenticated 子句指定角色rls-security-definer - 对复杂策略使用 SECURITY DEFINER 函数rls-minimize-joins - 尽量减少 RLS 策略中的连接rls-explicit-auth-check - 使用显式的 auth.uid() 检查rls-restrictive-policies - 使用 RESTRICTIVE 策略进行额外约束clerk-setup-third-party - 使用第三方身份验证集成clerk-client-server-side - 对服务器端客户端使用 accessToken 回调clerk-client-client-side - 对客户端客户端使用 useSession() 钩子clerk-role-claim - 在 Clerk 中配置 role: authenticated 声明clerk-org-policies - 为多租户 RLS 使用组织声明clerk-mfa-policies - 使用 RESTRICTIVE 策略强制执行 MFAclerk-no-jwt-templates - 切勿使用已弃用的 JWT 模板集成db-migrations-versioned - 对模式更改使用版本化迁移db-schema-design - 遵循正确的模式设计模式db-indexes-strategy - 实施正确的索引策略db-foreign-keys - 始终使用外键约束db-triggers-security - 正确保护触发器函数db-views-security-invoker - 对视图使用 SECURITY INVOKERauth-jwt-claims-validation - 始终验证 JWT 声明auth-user-metadata-safety - 将 user_metadata 视为不可信数据auth-app-metadata-authorization - 使用 app_metadata 进行授权auth-session-management - 实施适当的会话管理api-filter-queries - 即使启用了 RLS 也要始终过滤查询api-publishable-keys - 正确使用可发布密钥api-service-role-server-only - 切勿将服务角色密钥暴露给客户端storage-rls-policies - 在 storage.objects 上启用 RLSstorage-bucket-security - 配置存储桶级别的安全性storage-signed-urls - 对私有文件使用签名 URLrealtime-private-channels - 对敏感数据使用私有频道realtime-rls-authorization - RLS 策略适用于实时功能realtime-cleanup-subscriptions - 在卸载时清理订阅edge-verify-jwt - 始终在 Edge Functions 中验证 JWTedge-cors-handling - 正确处理 CORSedge-secrets-management - 对敏感数据使用密钥test-pgtap-rls - 使用 pgTAP 测试 RLS 策略test-isolation - 正确隔离测试test-helpers - 使用测试辅助函数security-validate-inputs - 在处理前验证所有输入security-audit-advisors - 定期运行安全顾问检查阅读单个规则文件以获取详细说明和代码示例:
references/rules/rls-always-enable.md
references/rules/clerk-setup-third-party.md
references/rules/_sections.md
每个规则文件包含:
获取包含所有扩展规则的完整指南:references/supabase-guidelines.md
每周安装次数
306
代码仓库
首次出现
2026 年 1 月 20 日
安全审计
安装于
claude-code217
gemini-cli192
opencode190
antigravity179
cursor171
codex171
Comprehensive security and performance optimization guide for Supabase applications with Clerk authentication integration. Contains 40+ rules across 10 categories, prioritized by impact to guide secure development and code review.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Row Level Security | CRITICAL | rls- |
| 2 | Clerk Integration | CRITICAL | clerk- |
| 3 | Database Security | HIGH | db- |
| 4 | Authentication Patterns | HIGH | auth- |
| 5 | API Security | HIGH | api- |
| 6 | Storage Security | MEDIUM-HIGH | storage- |
| 7 | Realtime Security | MEDIUM | realtime- |
| 8 | Edge Functions | MEDIUM | edge- |
| 9 | Testing | MEDIUM | test- |
| 10 | Security | MEDIUM | security- |
rls-always-enable - Always enable RLS on public schema tablesrls-wrap-functions-select - Wrap auth functions with (SELECT ...) for performancerls-add-indexes - Add indexes on columns used in RLS policiesrls-specify-roles - Specify roles with TO authenticated clauserls-security-definer - Use SECURITY DEFINER functions for complex policiesrls-minimize-joins - Minimize joins in RLS policiesrls-explicit-auth-check - Use explicit auth.uid() checksrls-restrictive-policies - Use RESTRICTIVE policies for additional constraintsclerk-setup-third-party - Use Third-Party Auth integration (not JWT templates)clerk-client-server-side - Use accessToken callback for server-side clientsclerk-client-client-side - Use useSession() hook for client-side clientsclerk-role-claim - Configure role: authenticated claim in Clerkclerk-org-policies - Use organization claims for multi-tenant RLSclerk-mfa-policies - Enforce MFA with RESTRICTIVE policiesclerk-no-jwt-templates - Never use deprecated JWT template integrationdb-migrations-versioned - Use versioned migrations for schema changesdb-schema-design - Follow proper schema design patternsdb-indexes-strategy - Implement proper indexing strategydb-foreign-keys - Always use foreign key constraintsdb-triggers-security - Secure trigger functions properlydb-views-security-invoker - Use SECURITY INVOKER for viewsauth-jwt-claims-validation - Always validate JWT claimsauth-user-metadata-safety - Treat user_metadata as untrustedauth-app-metadata-authorization - Use app_metadata for authorizationauth-session-management - Implement proper session managementapi-filter-queries - Always filter queries even with RLSapi-publishable-keys - Use publishable keys correctlyapi-service-role-server-only - Never expose service role key to clientstorage-rls-policies - Enable RLS on storage.objectsstorage-bucket-security - Configure bucket-level securitystorage-signed-urls - Use signed URLs for private filesrealtime-private-channels - Use private channels for sensitive datarealtime-rls-authorization - RLS policies apply to realtimerealtime-cleanup-subscriptions - Clean up subscriptions on unmountedge-verify-jwt - Always verify JWT in edge functionsedge-cors-handling - Handle CORS properlyedge-secrets-management - Use secrets for sensitive datatest-pgtap-rls - Test RLS policies with pgTAPtest-isolation - Isolate tests properlytest-helpers - Use test helper functionssecurity-validate-inputs - Validate all inputs before processingsecurity-audit-advisors - Regularly run Security Advisor checksRead individual rule files for detailed explanations and code examples:
references/rules/rls-always-enable.md
references/rules/clerk-setup-third-party.md
references/rules/_sections.md
Each rule file contains:
For the complete guide with all rules expanded: references/supabase-guidelines.md
Weekly Installs
306
Repository
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code217
gemini-cli192
opencode190
antigravity179
cursor171
codex171
OpenClaw 安全 Linux 云部署指南:私有优先、SSH隧道、Podman容器化
19,500 周安装