backend-dev-guidelines
Supabase Edge Functionsでバックエンドを構築
也可從以下取得: diet103,Dimon94,BrianDai22
Supabaseのバックエンドコード作成は、多くの要素が絡み合い複雑になりがちです。このスキルは、Edge Functions、データベース設計、Row-Level Security、統合機能に関する実用的なパターンを提供し、より少ないバグでより早く開発できるようサポートします。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「backend-dev-guidelines」。 ブログ投稿作成用のEdge Functionを作成
預期結果:
- CORSプリフライト処理を含むDeno.serveハンドラー
- title、content、オプションのtagsのためのZodスキーマ
- supabase.auth.getUser()によるJWT検証
- 認証済みユーザーのuser_idを使用したデータベースinsert
- RLSポリシーでユーザーが自身の投稿のみinsert可能に制限
- ステータスコード(400, 401, 500)による適切なエラー処理
- 201ステータスと作成された投稿データを含む成功レスポンス
正在使用「backend-dev-guidelines」。 テーブルにRow-Level Securityを設定
預期結果:
- ALTER TABLE table ENABLE ROW LEVEL SECURITY
- auth.uid() = user_idを使用したSELECT用CREATE POLICY
- CHECK auth.uid() = user_idを含むINSERT用CREATE POLICY
- RLSポリシーで使用されるカラムにCREATE INDEX
- 異なるユーザーロールでポリシーをテスト
正在使用「backend-dev-guidelines」。 ユーザー登録入力のバリデーション
預期結果:
- email、password、usernameフィールドを含むZodスキーマ
- 正規表現によるメール形式バリデーション
- パスワードの最小長と複雑さチェック
- データベースに対するユーザー名の一意性チェック
- 各バリデーション失敗に対する明確なエラーメッセージを返す
安全審計
安全Pure documentation skill containing only markdown guidance files. Static scanner flagged 755 issues but all are false positives caused by pattern-matching on code examples within documentation. Previous Claude audit confirmed no security concerns. All code examples demonstrate legitimate security best practices for Supabase backends.
風險因素
品質評分
你能建構什麼
サーバーレスAPIの構築
Webまたはモバイルアプリケーション向けに、適切な認証とバリデーションを備えたSupabase Edge Functionsを作成します。
セキュアなデータベース設計
Row-Level SecurityによるPostgreSQLスキーマを設計し、データベースレベルでアクセスポリシーを適用します。
決済とメールの統合
Stripeサブスクリプション処理とResendトランザクションメールをアプリケーションに追加します。
試試這些提示
Create a new Supabase Edge Function called create-user that validates input with Zod, verifies the JWT token, and inserts a record into the users table with RLS policies.
Design a PostgreSQL schema for a posts table with user ownership, published status, and proper indexes. Include RLS policies for read and write access.
Add JWT verification to an existing Edge Function and implement role-based access control using custom claims in the user metadata.
Create a Stripe webhook handler Edge Function that verifies the signature, handles checkout.session.completed events, and updates user subscription status in the database.
最佳實務
- 不正アクセスを防ぐため、すべてのEdge Functionの開始時にJWTトークンを必ず検証する
- データベースレベルの保護のため、ユーザーデータを含むすべてのテーブルでRow-Level Securityを有効化する
- データベース操作やビジネスロジックの前に、すべての入力をZodスキーマで検証する
- すべての秘密情報とAPIキーには環境変数を使用し、コード内に認証情報を直接記述しない
避免
- 本番環境のEdge FunctionでJWT検証をスキップすると、APIが不正アクセスにさらされる
- 開発を簡略化するためにRLSを無効化すると、Supabaseのセキュリティ機能の目的が損なわれる
- エラー処理にconsole.errorを使用し、適切なHTTPレスポンスを返さないとクライアント統合が壊れる
- Supabaseクライアントをバイパスしてデータベースに直接クエリすると、RLS保護が迂回される