Dev backend
开发流水线第 3 步:后端先行。按 API 契约实现数据库迁移、服务层、接口层和测试, 每个接口可用 curl 独立验证,让前端拿到可调用的真实 API 后再开工。 触发词:后端先行、实现后端、写后端、开发接口、实现 API。 输入 docs/dev/02-architecture.md 和 03-api-contract.md,产出可运行的后端 + 更新契约状态, 下一步交给 /dev-frontend。From its SKILL.md
npx -y skills add Hedy-Alan/claude-5-step-dev --skill dev-backendAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 24 days oldThe repository was created 24 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.1 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
后端先行
按契约实现后端。核心纪律:契约是合同——实现过程中发现契约不合理,先改 03-api-contract.md 再改代码,绝不让代码悄悄偏离文档。
前置检查
- 读取
docs/dev/02-architecture.md和docs/dev/03-api-contract.md。缺失则建议先跑/dev-architecture;用户坚持直接写时,先花几分钟现场补一份最小契约(全局约定 + 接口清单)再动手。 - 确认本地环境:数据库能连上、依赖能装、端口不冲突。环境起不来就先解决环境,不要盲写代码。
开工前对齐(必须)
前置检查完成后,先向用户列出本次实现计划:要实现的接口清单、实现顺序、涉及的表和文件。用户明确同意后才开始写代码;用户要砍范围或调顺序,先改计划再动手。
商量必须自带默认推荐:计划本身就是你的推荐方案,直接说"建议按此执行,确认即开工";有多个可选路线时标注「推荐」项+一句理由,不许只抛开放式问题。
实现顺序
严格按依赖方向从下往上,每层可验证后再进入下一层:
1. 数据层
- 按架构文档的 ER 图写建表迁移(用项目技术栈自带的 migration 机制;没有就用带序号的 SQL 文件
migrations/001_xxx.sql)。 - 写种子数据脚本:至少 1 个测试账号 + 每张核心表 3-5 条真实形状的数据(不要 "test1/test2" 式敷衍数据,前端要拿它做展示开发)。
- 验证:迁移能在空库上从零执行成功。
2. 服务层(业务逻辑)
- 按模块实现业务逻辑,与 HTTP 层解耦(service 不 import web 框架)。
- 校验规则、权限判断、事务边界都在这一层,不散落在 controller 里。
3. 接口层
- 严格按契约实现:路径、方法、参数名、响应结构、错误码逐项对齐。
- 统一响应包装和全局异常处理先做——保证任何错误都返回契约约定的结构,而不是框架默认的 500 堆栈。
- 认证中间件就位后,逐个接口标注需要/不需要登录。
4. 自测验证
每完成一个接口立即验证,不攒到最后:
- 用 curl(或项目已有的测试框架)跑通:正常路径、参数缺失、参数非法、未登录、无权限。
- 响应 JSON 与契约中的示例逐字段比对——字段名大小写、类型、null 处理都算。
- 关键业务逻辑写单元测试;接口层至少每个端点一条 happy-path 测试。
完成标准(全部满足才算交付)
-
docs/dev/03-api-contract.md中所有 P0 接口状态更新为 ✅ 后端已实现 - 空库 → 迁移 → 种子数据 → 启动服务,一套命令能从零跑起来(把命令写进契约文档"本地启动"一节)
- 每个接口的 curl 验证命令记录在契约文档对应接口下(前端联调直接可用)
- 测试全绿;实现与契约有出入的地方已回写契约并标注变更原因
交接
向用户汇报:实现了哪些接口、启动命令、测试账号密码、遗留问题。
提示:下一步运行 /dev-frontend 开始前端实现。
原则
- 一次只做一个模块,做完自测再做下一个;不要铺开写完所有 controller 再回头调。
- 发现需求或契约有歧义,停下来问用户,不要按自己的猜测实现后让联调买单。
- 日志:每个请求可追踪(方法/路径/耗时/错误),但不打印密码和 token。
- 密钥、数据库密码走 env 文件,提供
.env.example,真实.env进.gitignore。
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.
Gives 0 of the 12 instructions most data backend skills give in ~1.3k tokens
Counted across 229 of the 229 authors here whose files we hold, read 2026-08-07
- Separate business logic into service layersin 22 of 229, across 15 files
- Retry failures with exponential backoffin 21 of 229, across 14 files
- Select only needed database columnsin 20 of 229, across 13 files
- Abstract data access into repository classesin 19 of 229, across 12 files
- Use centralized error handlersin 17 of 229, across 10 files
- Use AsNoTracking for read-only queriesin 16 of 229, across 4 files
- Use async/await for all I/O operationsin 16 of 229, across 5 files
- Implement structured loggingin 15 of 229, across 4 files
- Use dependency injection for all servicesin 14 of 229, across 2 files
- Use resource-based URLs for REST APIsin 13 of 229, across 7 files
- Invalidate cache after data changesin 13 of 229, across 9 files
- Use a dependency injection containerin 12 of 229, across 4 files
Said here and by no other author read
- change contract before changing code
- fix environment before writing code
- propose implementation plan before coding
- start coding only after user approves plan
- implement bottom-up by dependency direction
- verify each layer before next layer
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.