Community生产力与协作github.com

replica-backend:后端克隆构建工具(适用于 Cursor/Claude)

构建应用克隆的后端:身份认证、数据库迁移与访问规则、Stripe 支付、邮件、后台任务以及通过官方 API 的第三方集成,并提供安全检查清单。

Claude) 是什么?

该技能(名为 replica-backend)专门用于从架构文档(replica/architecture.md)自动生成后端代码,包括数据库迁移、服务器逻辑以及一个持续更新的后端清单(replica/backend.md)。它强调仅使用官方、公开的 API,并要求用户自行创建账户和密钥(如 Stripe、Supabase、Resend 等),绝不允许代理使用原始应用的私有端点、复用其 OAuth 客户端或通过原始应用进行代理。技能覆盖身份认证(邮箱注册/验证、密码重置、OAuth、安全会话、角色/团队权限)、数据库(迁移、行级安全策略、种子数据、备份)、支付(Stripe Checkout 与客户门户、Webhook 幂等处理)、邮件与后台任务(Resend/Postmark、定时任务、重试与死信队列)以及第三方集成(Google Calendar 等,需最少的 OAuth 作用域并提前处理提供商审核流程)。它还提供了一个详细的安全检查清单,确保机密仅存在于环境变量、服务器端输入验证、每次读写操作的权限检查、速率限制、Webhook 签名验证、上传限制、用户数据保护以及依赖审计。该技能适用于 Cursor 和 Claude Code 等平台,当用户提出“添加登录”、“设置认证”、“连接数据库”、“添加支付”、“连接 Stripe”、“添加 Google Calendar”、“发送邮件”、“为我的克隆构建后端”等指令时,或当 /replica-build 在虚假数据上运行时触发。最终产出是可工作的认证、测试模式下的支付、邮件、集成、.env.example 文件和更新后的 backend.md 清单。

兼容平台~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 客户端,绝不要通过它进行代理。
  • 用户创建账户和密钥。 代理绝不注册服务,绝不输入密码、信用卡或真实密钥。用户创建 Stripe、Supabase、Resend 或 Google Cloud 项目,并将密钥放入 .env.local。代理编写 .env.example,包含每个变量名且不包含值。
  • 先使用测试模式。 使用 Stripe 测试密钥和测试卡,直到 replica-deploy。

身份认证

  • 邮箱注册与验证、密码重置、如果原始应用有的话则包括魔法链接。OAuth(Google、Apple)使用用户自己的开发者应用。
  • 会话:http-only 安全 Cookie。所有地方登出。
  • 如果重新映射图中有角色和团队:所有者、管理员、成员,并提供一个函数来回答“此用户能否对此记录执行此操作”。
  • 账户删除必须实际删除。Apple 要求提供注册功能的应用必须这样做。

数据库

  • 从 architecture.md 生成的迁移脚本,已检入,由脚本运行。
  • 每张表的访问规则:Supabase 上的行级安全策略,或在每个查询中调用授权函数。测试:第二个用户必须什么也拿不到。
  • 使用逼真的虚假数据(无真人数据)的种子脚本。
  • 备份(主机的每日备份计数,检查它们是否已启用)。

支付

  • 使用 Stripe Checkout 注册套餐,使用客户门户进行更改和取消。不要构建卡表单。
  • Webhook:验证签名,存储事件 ID,使每个处理程序具有幂等性(Stripe 会重试)。处理 checkout.session.completed、customer.subscription.updated、customer.subscription.deleted、invoice.payment_failed。
  • 订阅状态存在于你的数据库中,由 Webhook 更新,由你的应用读取。永远不要信任客户端。
  • 取消只需点击一次。难以取消的计费是大多数应用最常见的投诉之一,在许多地方也是非法的。

邮件和任务

  • 通过 Resend 或 Postmark 从你自己的域名发送事务性邮件。模板全新编写。
  • 任何基于时间的任务(提醒、摘要、同步、清理)都使用任务处理,支持重试和死信日志。时间使用 UTC,并在用户的时区显示。

集成

对于功能矩阵中的每个集成:官方 API、所需的 OAuth 作用域(尽可能少)、提供商的审核流程、速率限制。像 Calendar 这样的 Google 作用域在公开发布前需要 Google 的 OAuth 验证,这需要数周时间。尽早开始,并在 backend.md 中写明。

安全检查清单

  • 机密仅存在于环境变量中,.env* 在 .gitignore 中,客户端包中不包含任何机密
  • 在每个路由上进行服务器端输入验证(zod 或类似工具)
  • 每次读取和写入都检查授权,并使用第二个用户进行测试
  • 对身份认证、注册以及任何发送邮件或短信的操作进行速率限制
  • Webhook 验证签名
  • 上传:大小和类型限制,从单独的域或存储桶提供
  • URL 或日志中不包含用户数据
  • 依赖项审计(npm audit)
  • 隐私政策列出所有处理方(Stripe、Resend、主机、分析工具)

输出

可工作的身份认证、数据库、测试模式下的支付、邮件和集成,.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.

相关技能