
Api Writer
- 23 installs
- 79 repo stars
- Updated May 6, 2026
- testany-io/testany-agent-skills
Helps with backend & apis tasks.
About
api-writer is a Claude Code skill for backend & apis. It helps solo builders move faster with AI-assisted development.
- api-writer
- Backend & APIs
- AI-coding skill
Api Writer by the numbers
- 23 all-time installs (skills.sh)
- Ranked #3,432 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Jul 27, 2026 (Skillselion catalog sync)
npx skills add https://github.com/testany-io/testany-agent-skills --skill api-writerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 23 |
|---|---|
| repo stars | ★ 79 |
| Last updated | May 6, 2026 |
| Repository | testany-io/testany-agent-skills ↗ |
What it does
Helps with backend & apis tasks.
Files
API Writer
语言规则:默认跟随用户输入语言;用户显式指定时以用户指定为准;不要因为本SKILL.md是中文而强制输出中文;TRACEABILITY-METADATA的字段名、枚举值、ID、comment markers 始终保持英文。若本 skill 使用模板或派发子任务,继续传递同一个output_language。详见../../references/language-policy.md。
你是一个接口契约/协议文档写作助手。基于 PRD 与边界确认,输出可审查的 contract,降低前后端/多团队对接口认知漂移。
核心原则
1. 契约是事实源:HLD/实现必须引用契约版本,禁止在 HLD 中新增接口。 2. 有基线才产出:没有 PRD 基线或边界确认时,必须 AskUserQuestion 并停止产出。 3. 基于证据,不猜测:现有接口/服务/规范必须有文档依据;缺证据就问。 4. 边界先行:先确认服务/模块/数据所有权,再写接口。 5. 复用优先:优先复用已有接口/模块/第三方能力,避免重复造轮子。 6. 兼容性默认保守:默认向后兼容,破坏性变更必须显式标注与迁移计划。 7. 只写接口,不写实现:不写内部架构、数据库、算法和部署细节。 8. 不替代决策者:边界或选型不清时只给选项和影响,不擅自定夺。 9. 先做 Guardrails trigger check:如果本次 contract 会定义项目级默认规则,先判断是否必须更新 Guardrails。
执行进度清单
执行时使用 TodoWrite 工具跟踪以下进度,完成一项后立即标记为 completed:
□ 阶段 0:上下文收集
□ 0.1 使用 Glob 扫描 PRD/需求文档、已有 API 规范、现有服务说明
□ 0.2 AskUserQuestion 确认要读取的文档与最新批准基线
□ 0.3 执行 Guardrails trigger check
□ 阶段 1:边界/所有权确认
□ 1.1 AskUserQuestion 确认服务/模块边界
□ 1.2 确认数据所有权(source of truth)
□ 1.3 确认主要消费者与调用方向
□ 1.4 确认与既有接口/能力的关系
□ 阶段 2:合同类型选择
□ 2.1 AskUserQuestion 确认 contract 类型(HTTP/GraphQL/gRPC/Event/...)
□ 2.2 确认输出格式
□ 阶段 3:契约撰写
□ 3.1 若多协议,先生成 Contract Index
□ 3.2 按选定模板生成各协议契约文档
□ 3.3 生成 PRD → Contract 映射表
□ 3.4 标注兼容性与版本策略、已复用能力、待确认项
□ 阶段 4:一致性自检
□ 4.1 PRD 需求覆盖率检查(100% 被映射)
□ 4.2 与现有契约冲突/重复检查
□ 4.3 兼容性/版本策略是否明确
□ 4.4 错误契约、权限、幂等性是否缺失
□ 4.5 多协议间数据模型与错误码一致性检查契约内容边界(强制遵守)
应该包含
- 契约基本信息:名称、版本、状态、Owner、消费者、PRD 引用
- 范围与边界:覆盖能力、非覆盖项、数据所有权
- 接口清单与定义:路径/事件/函数签名、请求/响应/错误
- 安全与权限:认证/授权/数据级权限
- 兼容性与版本策略:升级、弃用、breaking change 规则
- 关键非功能约束:SLO、幂等性、分页、限流等
- 示例与约束:典型请求/响应/事件样例
不应该包含
- 内部模块设计、部署拓扑、数据库表/字段
- 具体算法、重试参数、缓存 TTL
- UI 交互细节或实现代码
合同类型选择(按需)
选择一种或多种模板撰写(必要时拆分多个 contract):
- HTTP/REST API →
references/http-api-contract.md - GraphQL API →
references/graphql-contract.md - gRPC API →
references/grpc-contract.md - 事件/消息协议 →
references/event-contract.md - WebSocket/SSE 实时协议 →
references/realtime-contract.md - Webhook →
references/webhook-contract.md - SDK/Library 公共接口 →
references/library-contract.md - 文件格式/数据交换格式 →
references/file-format-contract.md - IPC/CLI/插件接口 →
references/ipc-cli-contract.md
多协议混合的契约组织方式(强制)
当一个系统包含多种协议(如 REST + Webhook + WebSocket),必须:
1. 先产出 Contract Index → references/contract-index.md 2. 每种协议单独成文档(不要混写在一个模板里) 3. 在 Index 统一共享规则:认证/授权、错误码体系、版本策略、幂等与重试、限流、可观测性 4. 定义跨协议一致性映射:
- 共享数据模型的 canonical schema
- 同一业务事件在不同协议的 payload 对应关系
- 错误码/状态码的跨协议映射
5. PRD → Contract 映射以 Index 为准,确保全覆盖
工作流程
阶段 0:上下文收集(强制)
1. 使用 Glob 扫描并收集路径(不先读):
- PRD/需求文档、已有 API/规范(OpenAPI/AsyncAPI/Spec)、现有服务/模块说明、相关 ADR、现有 Guardrails
2. AskUserQuestion 让用户确认要读取的文档与“最新批准基线”。 3. 基于 ../../references/guardrails-trigger-check.md 执行一次 Guardrails trigger check:
no_trigger:继续阶段 1suggest_guardrails:记录原因、影响域和推荐动作后继续require_guardrails_before_design:停止当前 contract 写作,明确建议先运行guardrails-writer
阶段 1:边界/所有权确认(强制)
若边界不清晰,必须 AskUserQuestion 确认,未确认不得继续:
- 服务/模块边界
- 数据所有权(source of truth)
- 主要消费者与调用方向
- 与既有接口/能力的关系(复用/扩展/替换)
阶段 2:合同类型选择(强制)
使用 AskUserQuestion 确认 contract 类型与输出格式:
- HTTP / GraphQL / gRPC / Event / WebSocket-SSE / Webhook / SDK / File / IPC-CLI
阶段 3:契约撰写
1. 若为多协议,先生成 Contract Index,再分别生成各协议 contract 2. 生成 PRD → Contract 映射表(需求条目 → 接口/事件/函数) 3. 标注兼容性与版本策略、已复用能力、待确认项
阶段 4:一致性自检(必须)
检查并修正:
- PRD 需求覆盖率(100% 被映射)
- 与现有契约冲突/重复
- 兼容性/版本策略是否明确
- 错误契约、权限、幂等性是否缺失
- 多协议间的数据模型与错误码一致性
AskUserQuestion 模板(必须使用)
1) 边界确认
question: "请确认本契约的边界与所有权:"
header: "Contract 边界确认"
multiSelect: false
options:
- label: "按现有服务/模块边界"
description: "已有明确服务/模块归属"
- label: "按数据所有权边界"
description: "数据归属清晰,围绕数据主权划分"
- label: "按业务域能力边界"
description: "围绕业务能力划分,需补充服务清单"
- label: "不确定,需要你提供边界/服务列表"
description: "缺乏边界信息,无法继续"2) 合同类型选择
question: "请选择要撰写的 contract 类型:"
header: "Contract 类型"
multiSelect: true
options:
- label: "HTTP/REST API"
- label: "GraphQL API"
- label: "gRPC API"
- label: "事件/消息协议"
- label: "WebSocket/SSE 实时协议"
- label: "Webhook"
- label: "SDK/Library 公共接口"
- label: "文件格式/数据交换格式"
- label: "IPC/CLI/插件接口"3) Guardrails Trigger 澄清
question: "这次 Contract 变更是否会改变项目里多个模块都要遵守的默认规则?"
header: "Guardrails Trigger"
multiSelect: false
options:
- label: "是,会改变项目默认规则"
description: "应优先判断是否需要更新 Guardrails"
- label: "否,只影响当前 Contract"
description: "通常无需触发 Guardrails"
- label: "不确定,需要结合现有 Guardrails 一起判断"
description: "先读取现有 Guardrails 与批准基线再决定"输出要求(默认结构)
- 单协议:契约文档(按模板)+ PRD → Contract 映射表 + 待确认问题清单 + 变更/兼容性说明
- 多协议:Contract Index + 各协议契约文档 + PRD → Contract 映射表 + 待确认问题清单 + 变更/兼容性说明
- 若命中
suggest_guardrails:在输出中附一段Guardrails Trigger Check摘要
使用示例
示例 1: “根据 PRD 输出订单服务的 API contract(OpenAPI),并标注幂等与错误码。”
示例 2: “为桌面端插件系统写插件 API contract,包含生命周期与权限模型。”
资源目录(按需加载)
references/contract-index.mdreferences/http-api-contract.mdreferences/graphql-contract.mdreferences/grpc-contract.mdreferences/event-contract.mdreferences/realtime-contract.mdreferences/webhook-contract.mdreferences/library-contract.mdreferences/file-format-contract.mdreferences/ipc-cli-contract.md../../references/guardrails-trigger-check.md
interface:
display_name: "API Writer"
short_description: "Draft API contracts from product requirements"
icon_small: "./assets/testany-logo-small.png"
icon_large: "./assets/testany-logo.svg"
default_prompt: "Use $api-writer to draft an API contract from this PRD."
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="958.3745509306195" height="958.3745509306195" viewBox="0 0 958.3745509306195 958.3745509306195">
<g transform="scale(8.11041548093341) translate(10, 10)">
<defs id="SvgjsDefs1360"></defs>
<g id="SvgjsG1361" featureKey="symbolFeature-0" transform="matrix(0.9816393857057392,0,0,0.9816393857057392,-3.0293391105859975,0.00098156823722121)" fill="#7cbb00">
<rect xmlns="http://www.w3.org/2000/svg" x="42.607" y="47.076" transform="matrix(0.7761 0.6306 -0.6306 0.7761 46.5672 -14.0771)" width="1" height="22.92">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="45.986" y="57.948" transform="matrix(0.6084 0.7937 -0.7937 0.6084 68.7434 -22.4141)" width="22.194" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="61.209" y="34.391" transform="matrix(0.285 0.9585 -0.9585 0.285 88.4619 -26.0748)" width="1" height="23.738">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="38.984" y="37.368" transform="matrix(0.0074 1 -1 0.0074 88.2466 -13.1692)" width="23.546" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="27.744" y="45.76" transform="matrix(0.9562 0.2928 -0.2928 0.9562 15.2685 -9.4777)" width="23.094" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="35.832" y="34.683" transform="matrix(0.9456 0.3253 -0.3253 0.9456 16.6429 -9.3663)" width="1" height="20.809">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="31.072" y="60.446" transform="matrix(0.8221 0.5694 -0.5694 0.8221 42.108 -12.8663)" width="21.141" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="58.047" y="51.212" transform="matrix(0.5722 0.8201 -0.8201 0.5722 75.2668 -21.8197)" width="1" height="20.036">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="53.541" y="45.129" transform="matrix(0.2845 0.9587 -0.9587 0.2845 89.4167 -28.5477)" width="20.584" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="39.708" y="35.004" transform="matrix(0.9997 0.0243 -0.0243 0.9997 0.8776 -1.2119)" width="21.201" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="36.331" y="59.987" transform="matrix(0.5784 0.8158 -0.8158 0.5784 77.9659 2.2244)" width="1" height="33.1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="55.959" y="70.302" transform="matrix(0.3351 0.9422 -0.9422 0.3351 114.7194 -20.9532)" width="32.492" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="76.946" y="19.044" transform="matrix(0.0107 0.9999 -0.9999 0.0107 112.198 -42.2379)" width="1" height="33.083">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="44.371" y="2.123" transform="matrix(0.9527 0.3039 -0.3039 0.9527 7.9224 -12.733)" width="0.999" height="33.928">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="3.101" y="44.487" transform="matrix(0.8004 0.5995 -0.5995 0.8004 30.9 -2.8183)" width="33.161" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="13.446" y="11.595" transform="matrix(0.9605 0.2782 -0.2782 0.9605 11.716 -2.2955)" width="1" height="57.08">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="1.626" y="81.812" transform="matrix(0.8375 0.5464 -0.5464 0.8375 49.6273 -2.2773)" width="54.033" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="71.659" y="52.69" transform="matrix(0.6376 0.7704 -0.7704 0.6376 87.6254 -26.6706)" width="1" height="54.215">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="55.738" y="36.926" transform="matrix(0.377 0.9262 -0.9262 0.377 86.266 -53.4047)" width="54.19" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="46.824" y="-12.954" transform="matrix(0.0146 0.9999 -0.9999 0.0146 58.9718 -35.1579)" width="1" height="50.592">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="6.016" y="66.991" width="29.866" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="9.472" y="27.565" transform="matrix(0.2024 0.9793 -0.9793 0.2024 47.599 -2.3107)" width="31.493" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="61.126" y="6.058" transform="matrix(0.5429 0.8398 -0.8398 0.5429 44.2475 -43)" width="1" height="26.18">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="69.065" y="52.2" transform="matrix(0.7128 0.7014 -0.7014 0.7128 60.8208 -43.1259)" width="28.006" height="1">
</rect>
<rect xmlns="http://www.w3.org/2000/svg" x="57.052" y="65.986" transform="matrix(0.9215 0.3885 -0.3885 0.9215 36.441 -15.9049)" width="1" height="32.356">
</rect>
<circle xmlns="http://www.w3.org/2000/svg" cx="6.41" cy="35.047" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="32.979" cy="55.017" r="4.79">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="93.05" cy="62.521" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="93.987" cy="35.41" r="2.927">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="51.269" cy="97.073" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="6.014" cy="67.55" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="50.332" cy="49.641" r="5.511">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="39.816" cy="35" r="4.789">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="60.904" cy="35.842" r="4.79">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="77.649" cy="86.109" r="2.927">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="50.635" cy="67.21" r="4.79">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="66.735" cy="55.478" r="4.79">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="28.249" cy="42.878" r="2.028">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="50.633" cy="26.257" r="1.929">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="35.881" cy="67.432" r="2.128">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="63.833" cy="67.256" r="2.053">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="50.031" cy="2.927" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="72.616" cy="12.331" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="73.085" cy="42.878" r="2.225">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="23.331" cy="86.109" r="2.928">
</circle>
<circle xmlns="http://www.w3.org/2000/svg" cx="22.03" cy="12.645" r="2.928">
</circle>
</g>
</g>
</svg>Contract Index(多协议场景)
1. 基本信息
- 系统/域:
- 版本:
- 状态:
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 非覆盖项:
- 数据所有权:
3. 共享规则(跨协议统一)
- 认证/授权:
- 错误码体系:
- 版本与兼容策略:
- 幂等与重试:
- 限流与配额:
- 可观测性(trace/log/metrics):
4. Contract 清单
| 协议 | Contract 文档 | 版本 | Owner | Consumers | PRD 条目 |
|---|
5. Canonical 数据模型
| 实体/事件 | Canonical schema | 使用协议 | 映射说明 |
|---|
6. PRD → Contract 映射表
| PRD 条目 | 对应协议/Contract | 接口/事件/函数 |
|---|
7. 待确认问题
- ...
事件/消息契约模板
1. 基本信息
- 契约名称:
- 版本:
- 状态:
- Owner:
- Producer/Consumer:
2. 范围与边界
- 覆盖能力:
- 数据所有权:
3. 事件清单
| 事件名/主题 | Producer | Consumer | Schema 版本 | Key | PRD 条目 |
|---|
4. 事件 Envelope
- 必须字段: event_id, event_type, occurred_at, version, trace_id
- 编码: JSON/Avro/Protobuf
5. 事件定义(逐个)
{事件名}
- 触发条件:
- Payload schema:
- 顺序/幂等:
- 失败处理: 重试/DLQ
- 示例:
6. 兼容性与版本策略
- 向后兼容规则:
- Schema 演进策略:
7. 非功能约束
- 延迟/吞吐:
- 保留期:
8. 待确认问题
- ...
文件格式/数据交换格式契约模板
1. 基本信息
- 格式名称:
- 扩展名/MIME:
- 版本:
- Owner:
- 兼容性目标:
2. 范围与边界
- 覆盖能力:
- 不覆盖事项:
3. 编码与结构
- 编码: UTF-8/二进制
- 总体结构: (header/body/footer)
- Schema/字段说明:
4. 约束与校验
- 必填字段/约束:
- 校验规则:
5. 兼容性与迁移
- 向后兼容规则:
- 迁移策略:
6. 示例
- 样例文件/片段:
7. 待确认问题
- ...
GraphQL Contract 模板
1. 基本信息
- Schema 名称:
- 版本:
- 状态:
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 非覆盖项:
- 数据所有权:
3. Schema 概览
- Query:
- Mutation:
- Subscription:
- 关键类型与关系:
4. 访问控制
- 认证方式:
- 字段级授权/指令:
- 多租户/数据隔离:
5. 规范约束
- 分页策略(cursor/connection):
- 复杂度/深度限制:
- N+1 防护策略:
- 缓存策略:
6. 错误契约
- Error codes / extensions 规范:
- 可重试判定:
7. 兼容性与版本策略
- Deprecated 策略:
- Breaking change 规则:
8. 示例
- Query/Mutation/Subscription 示例:
9. 非功能约束
- SLA/SLO:
- 限流/配额:
10. 待确认问题
- ...
gRPC Contract 模板
1. 基本信息
- Proto package:
- 服务名:
- 版本:
- 状态:
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 非覆盖项:
- 数据所有权:
3. 服务清单
| Service | Method | Type(unary/stream) | Request | Response | PRD 条目 |
|---|
4. 消息与枚举定义
- Request/Response schema:
- 关键字段约束:
5. 错误契约
- gRPC status codes:
- Error details 规范:
- 可重试判定:
6. 传输与调用约束
- Deadline/timeout:
- 重试/退避:
- 负载均衡/压缩:
- 认证/元数据:
7. 兼容性与版本策略
- Protobuf 演进规则:
- Breaking change 规则:
8. 非功能约束
- SLA/SLO:
- 吞吐/延迟目标:
9. 示例
- 方法调用示例:
10. 待确认问题
- ...
HTTP API Contract 模板
适用于 REST/HTTP API。若已有 OpenAPI/Swagger 规范,优先引用并标注链接与版本。
1. 基本信息
- 契约名称:
- 版本:
- 状态: draft/approved
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 非覆盖项:
- 数据所有权:
3. 接口清单
| 操作 | 方法 | 路径 | Owner | Consumers | PRD 条目 |
|---|
4. 通用规范
- Base URL / Versioning:
- 认证/授权:
- 幂等性:
- 分页:
- 限流/配额:
- 重试/超时约束:
- 通用 Header:
5. 数据模型(公共)
| 名称 | 说明 | 备注 |
|---|
6. 接口定义(逐个)
{操作名}
- 说明:
- 请求: (schema/字段/约束)
- 响应: (成功/失败 schema)
- 错误码:
- 示例:
- 兼容性备注:
7. 错误契约
| 错误码 | HTTP | 含义 | 可重试 | PRD 条目 |
|---|
8. 兼容性与版本策略
- Breaking change 规则:
- 弃用/迁移策略:
9. 非功能约束
- SLA/SLO:
- 安全/合规:
10. 待确认问题
- ...
IPC/CLI/插件接口契约模板
1. 基本信息
- 接口类型: IPC / CLI / 插件
- 版本:
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 权限/安全边界:
3. 命令/方法清单
| 命令/方法 | 入参 | 返回 | 错误码 | PRD 条目 |
|---|
4. 协议细节
- 传输/调用方式:
- 超时/重试:
- 权限模型:
5. 兼容性与版本策略
- Breaking change 规则:
- 弃用策略:
6. 示例
- ...
7. 待确认问题
- ...
SDK/Library 公共接口契约模板
1. 基本信息
- 包名/模块:
- 版本:
- 语言/平台:
- Owner:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 不覆盖事项:
- 依赖:
3. 公共 API 列表
| 模块/类 | API/函数签名 | 说明 | PRD 条目 |
|---|
4. 行为契约
- 输入前置条件:
- 输出/副作用:
- 错误模型:
- 线程安全/并发:
- 资源/内存所有权:
5. 兼容性与版本策略
- SemVer 规则:
- 弃用/迁移:
6. 性能/复杂度
- 复杂度上限/性能目标:
7. 示例用法
- ...
8. 待确认问题
- ...
WebSocket/SSE 实时协议契约模板
1. 基本信息
- 协议类型: WebSocket / SSE
- 版本:
- 状态:
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 数据所有权:
3. 连接与认证
- Endpoint/URL:
- 认证方式:
- 子协议/协议版本:
- 连接生命周期:
4. 消息模型
| 事件/消息 | 方向 | Schema | 触发条件 | PRD 条目 |
|---|
5. 传输语义
- 顺序与幂等:
- 断线重连/重放:
- 心跳/保活:
- 背压/流控:
6. 错误与关闭
- 错误码/关闭码:
- 客户端处理建议:
7. 兼容性与版本策略
- Breaking change 规则:
- 迁移策略:
8. 示例
- 连接/消息样例:
9. 非功能约束
- SLA/SLO:
- 吞吐/延迟目标:
10. 待确认问题
- ...
Webhook 契约模板
1. 基本信息
- 版本:
- 状态:
- Owner:
- Consumers:
- PRD 引用:
2. 范围与边界
- 覆盖能力:
- 非覆盖项:
3. 事件清单
| 事件名 | 触发条件 | Payload schema | PRD 条目 |
|---|
4. 投递与确认
- Endpoint 注册方式:
- 认证/签名方式:
- 超时与重试策略:
- 去重与幂等:
- 响应/回执规范:
5. Payload 结构
- Envelope 字段:
- 关键字段约束:
6. 安全与合规
- IP allowlist/签名校验:
- 敏感字段处理:
7. 兼容性与版本策略
- Breaking change 规则:
- 弃用/迁移:
8. 示例
- 事件样例:
9. 待确认问题
- ...