Community生產力與協作github.com

silasroliver-hue/replica-skill-cursor

構建應用程式克隆的後端:身份驗證、資料庫遷移與存取規則、Stripe 付款、電子郵件、背景任務以及僅透過官方 API 的第三方整合,並附帶安全檢查清單。

replica-skill-cursor 是什麼?

此技能「replica-backend」專為 Cursor 等 AI 代理工具設計,用於自動化建構應用程式克隆的後端基礎設施。它的核心目標是根據 `replica/architecture.md` 文件,生成所有必要的伺服器端程式碼與設定,並持續更新 `replica/backend.md` 檢查清單。此技能嚴格遵循「僅使用官方公開 API」與「使用者自行管理金鑰」的規則,確保安全與合規。支援的平台包括但不限於透過 Supabase 進行資料庫管理與資料列層級安全、Stripe 進行付款處理、Resend 或 Postmark 發送交易郵件,以及 Google Calendar 等第三方服務的 OAuth 整合。透過詳細的檢查清單,它涵蓋了從身份驗證(電子郵件、OAuth、角色/團隊)、資料庫遷移、測試模式付款、背景任務到安全最佳實踐的所有環節,最終產出一個可直接運作、經過測試的後端環境,並包含 `.env.example` 與更新的功能矩陣。

相容平台~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/silasroliver-hue/replica-skill-cursor/tree/HEAD/.cursor/skills/replica-backend

Installed? Explore more 生產力與協作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

replica-backend

讀取 replica/architecture.md。撰寫遷移腳本與伺服器程式碼,並保持 replica/backend.md(見下方檢查清單)為最新狀態。

規則

  • 僅限官方公開 API,且使用使用者自己的金鑰。 絕不呼叫原始應用程式的私有端點,絕不重複使用其 OAuth 用戶端,絕不透過它進行代理。
  • 使用者建立帳戶和金鑰。 AI 代理絕不註冊服務、絕不輸入密碼、信用卡或金鑰。使用者在 Stripe、Supabase、Resend 或 Google Cloud 專案中建立帳戶,並將金鑰放入 .env.local。AI 代理撰寫 .env.example,列出所有變數名稱,但不包含任何值。
  • 先使用測試模式。 在 replica-deploy 之前,使用 Stripe 測試金鑰與測試信用卡。

身份驗證 (Auth)

  • 支援電子郵件註冊與驗證、密碼重設,如果原始應用程式有,也支援魔術連結。OAuth(Google、Apple)使用使用者自己的開發者應用程式。
  • 工作階段:使用 http-only 安全 Cookie。可從所有裝置登出。
  • 如果重構地圖中有角色和團隊,則加以實作:擁有者、管理員、成員,並提供一個函數來回答「該使用者是否可對這筆記錄執行此操作」。
  • 帳戶刪除功能會實際刪除資料。Apple 要求只要有註冊功能的應用程式都必須提供此功能。

資料庫 (Database)

  • 從 architecture.md 產生遷移腳本,納入版本控制,並可透過腳本執行。
  • 為每個資料表設定存取規則:在 Supabase 上實作資料列層級安全策略,或在每個查詢中呼叫授權函數。進行測試:第二個使用者必須無法取得任何資料。
  • 種子腳本包含逼真的假資料(無真實人物)。
  • 備份(取決於主機的每日備份次數,請檢查是否已啟用)。

付款 (Payments)

  • 使用 Stripe Checkout 讓使用者註冊方案,使用客戶入口網站進行變更和取消。不要自行建立信用卡表單。
  • Webhook:驗證簽名、儲存事件 ID、確保每個處理器具有冪等性(Stripe 會重試)。處理 checkout.session.completed、customer.subscription.updated、customer.subscription.deleted、invoice.payment_failed 等事件。
  • 訂閱狀態儲存在你的資料庫中,由 webhook 更新,並由你的應用程式讀取。絕不信任客戶端。
  • 取消只需一鍵點擊。難以取消的付費機制是大多數應用程式的主要抱怨,且在多數地區屬於違法。

電子郵件與任務 (Email and jobs)

  • 透過你自己網域的 Resend 或 Postmark 發送交易郵件。範本需重新撰寫。
  • 為所有基於時間的任務(提醒、摘要、同步、清理)建立背景任務,支援重試與死信日誌。時間使用 UTC,在使用者的時區顯示。

整合 (Integrations)

針對功能矩陣中的每項整合:使用官方 API、所需最少的 OAuth 範圍、供應商的審核流程、速率限制。Google 日曆等範圍需要 Google 的 OAuth 驗證才能在公開上線前使用,這需要數週時間。請儘早開始,並在 backend.md 中記錄此事。

安全檢查清單 (Security checklist)

  • 機密資訊僅存在環境變數中,.env* 已加入 .gitignore,且不包含在客戶端套件中
  • 在所有路由的伺服器端驗證輸入(使用 zod 或類似工具)
  • 每次讀取和寫入都檢查授權,並以第二個使用者進行測試
  • 對身份驗證、註冊,以及任何發送電子郵件或簡訊的功能設定速率限制
  • Webhook 驗證簽名
  • 上傳檔案:限制大小與類型,並從獨立的網域或儲存空間提供服務
  • 使用者資料不出現在 URL 或日誌中
  • 檢查相依套件的安全性(npm audit)
  • 隱私權政策列出所有資料處理者(Stripe、Resend、主機、分析工具)

輸出 (Output)

運作中的身份驗證、資料庫、測試模式付款、電子郵件與整合功能、.env.example、已勾選檢查清單的 replica/backend.md、已更新的功能矩陣列。下一步:/replica-test。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

silasroliver-hue/replica-skill-cursor

>- Plans the stack, database schema and API for an app clone, from the recon map replica-recon wrote. Picks boring, managed tech, turns the inferred data model into real SQL with indexes and access rules, lists every route by flow, and orders the build as a thin vertical slice first. Use when the user says "plan the clone", "what stack should I use", "design the database", "write the schema", "plan the API", "architecture for my version of X", or after /replica-recon finishes.

silasroliver-hue/replica-skill-cursor

>- Names and rebrands an app clone so it is the user's own: name candidates with the trademark, domain, store and handle checks to run, a new palette checked for contrast, a logo brief, a voice guide, and a sweep tool that finds anything of the original left in the codebase. Use when the user says "name my app", "rebrand the clone", "make it mine", "pick a name and colours", "logo brief", "brand voice", "check for leftovers", or after /replica-entrepreneur. Always runs before /replica-launch.

silasroliver-hue/replica-skill-cursor

>- Rebuilds an app screen by screen from the recon map: app shell first, then the core flow as a vertical slice, then every screen with all its states, ticking off the feature matrix as it goes. Writes every line fresh, never the original's code, assets or copy. Use when the user says "build the clone", "build screen S07", "start building", "rebuild this screen", "implement the booking page", or after /replica-design.

silasroliver-hue/replica-skill-cursor

>- Ships an app clone live on the user's own domain: a preflight gate (tests green, parity must-haves done, rebrand sweep clean, listing linted, legal pages up), production database and env vars, the host, DNS records for the domain and for email, Stripe live mode, OAuth redirects, monitoring, and mobile builds to TestFlight and Play. Use when the user says "deploy it", "ship it", "put it live", "connect my domain", "go to production", "publish the app", or after /replica-launch.

相關技能