一键导入
ec-backend-expert
Backend implementation and fixes for multi-vendor e-commerce projects, including server actions, database and authentication.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Backend implementation and fixes for multi-vendor e-commerce projects, including server actions, database and authentication.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | ec-backend-expert |
| description | Backend implementation and fixes for multi-vendor e-commerce projects, including server actions, database and authentication. |
Next.js Server Actions、Prisma (PostgreSQL)、Clerk認証を使用したサーバーサイドのビジネスロジックやデータアクセスの開発・修正を担当するスキルです。
src/actions/ ディレクトリは絶対に作成・使用しないこと。src/queries/ ディレクトリ配下のドメイン固有ファイル(例: product.ts, user.ts, store.ts)に配置すること。"use server" ディレクティブを明記すること。src/lib/db.ts からエクスポートされた Prisma クライアントを使用すること。Float を使用せず、Prisma.Decimal を使用すること。演算は .add(), .mul(), .sub(), .div() メソッドを使い、浮動小数点誤差を避けること。db.$transaction でラップしアトミック性を保証すること。withAccelerate() 拡張を使用している前提でコードを書くこと。try/catch でラップすること。src/queries/ 内の console.error は [Module:Function] Message 形式のプレフィックスを付け、エラーメッセージとスタックを構造化データとして記録すること。if (error instanceof Error) を用いて安全にエラーメッセージへアクセスすること。/dashboard/*, /checkout, /profile/*)のアクセス制御は、基本的に src/middleware.ts (Clerk) で行われている。src/lib/auth-guards.ts のヘルパーを使うこと:
requireUser() — 認証必須 (USER / SELLER / ADMIN 問わず)requireAdmin() — role === "ADMIN" のみ (グローバルリソース管理用: category / offer-tag 等)requireSeller() — role === "SELLER" のみ (店舗 URL を介さない場合: 例 deleteProduct は productId 起点で product.store.userId !== user.id を別途インライン検証)requireStoreOwner(storeUrl) — role === "SELLER" + where: { url, userId } 複合検索で IDOR 防御を集約。返り値 { user, store } を再利用して後段の findUnique 重複呼び出しを避けるcurrentUser() + if (!user) ... / if (role !== "...") ... のインライン展開を新規追加すること(.claude/steering/tech.md "認可ガード" 項)。既存のインライン展開を見つけた場合は同セッションで auth-guards に置換することを推奨。throw new Error("...") で表現する(src/queries/* の既存実装は { success, error } ラッパーを使わない throw ベース)。where: { url, userId } 構造検証 / (c) ガード失敗時の副作用なし検証 を必ず揃える(docs/testing/SECURITY_GAP_REPORT.md §5.2)。prisma/schema.prisma を確認し、データ構造とリレーションを把握する。src/queries/ 内のどのドメインファイルに処理を追加・修正するかを決定する。src/lib/schemas.ts の Zodスキーマ利用など)がサーバー側で行われているか確認する。src/queries/XXX.test.ts に追加する。詳細は server-action-scaffold skill のテストテンプレートを参照。Keeps spec documents and coverage reports in sync after test implementation, feature implementation, or phase completion. Updates quantitative metrics (test count, suite count, type error count), regenerates coverage-dashboard.html, and syncs functional specs (04-interfaces.md, 05-workflows.md, 08-open-questions.md) and progress trackers (docs/design/*/PROGRESS.md, docs/PROGRESS.md next-actions) when new server actions, pages, or workflows were implemented. Triggered by: "仕様書更新", "ドキュメント更新", "テスト後の仕様同期", "spec sync after test", "update docs after test", "テスト実装後の更新", "カバレッジダッシュボード更新", "update coverage dashboard", "フェーズ完了", "機能実装後の仕様同期", "phase complete", "feature sync".
Runs unit tests (Jest), optional E2E tests (Playwright), TypeScript type check, and ESLint, then reports results with pass/fail details, coverage, and a clear commit-readiness judgment. Recommended before every commit. Triggered by: "テスト実行", "テスト確認", "カバレッジ確認", "品質チェック", "テストチェック", "コミット前確認", "test run", "run tests", "check coverage", "quality check", "pre-commit check".
Regenerates the data-model ER diagram from prisma/schema.prisma and visually declutters edge routing (lines must not overlap entity boxes) without ever hand-editing the generated .drawio. Manual layout intent is captured in the layout-overrides side-car so it survives regeneration. Triggered by: "ERD調整", "ER図調整", "データモデル図", "data-model.drawio", "drawio調整", "図の線が重なる", "線がボックスを突き抜ける", "erd:generate後の調整", "ERD再生成", "モデル追加後の図更新", "adjust ERD diagram", "fix ER diagram routing", "regenerate data model diagram", "erd layout".
Diagnoses CI-only test flakes — tests that pass locally but fail intermittently on GitHub Actions. Triaged via gh CLI log inspection and event-pair comparison (push vs pull_request on the same SHA). Recommends minimal diagnostic instrumentation (Jest --verbose --ci) before any code change. Triggered by: "CI が落ちる", "CI でだけ失敗", "テストがフレーキー", "ローカルでは通る", "間欠的に失敗", "CI flake", "intermittent failure", "flaky test", "passes locally fails in CI".
Generates consistent server action templates in src/queries/ by learning existing patterns. Produces implementation file, Zod schema addition, and unit tests (AAA pattern) in a single scaffold. Only triggered when a new server action is explicitly requested. Triggered by: "新しいサーバーアクション", "サーバーアクション追加", "server action作成", "新しいserver actionを追加", "add server action (query)", "new server action", "add server action", "scaffold action", "create query".
Detects and reports divergences across four layers: (1) specs ↔ implementation, (2) steering rules ↔ rules/skills/agent docs, (3) top-level docs (CLAUDE.md / README.md / GEMINI.md / .agent/) ↔ steering, and (4) SSOT duplication. Never auto-fixes — always reports to the human for judgment. Follows SDD (Spec-Driven Development) principles where specs are the single source of truth, while extending coverage to the operational layer that teaches the rules. Triggered by: "仕様確認", "仕様同期", "spec確認", "仕様書チェック", "仕様と実装の整合性", "仕様乖離", "ルール確認", "規約整合性チェック", "規約浸透チェック", "ドリフト確認", "skill 整合", "rule 整合", "spec check", "sync check", "check spec", "verify spec alignment", "rule sync", "skill sync", "drift check", "仕様乖離をチェック".