$npx -y skills add BlueprintOS/analysis-to-delivery --skill design-an-interface设计接口契约 — 来自 superpowers 体系。本 skill 是桥接层,完整纪律见 <SUPERPOWERS_SKILL_ROOT>/design-an-interface/。
| 1 | # Design-an-Interface(桥接到 superpowers) |
| 2 | |
| 3 | ## Contract |
| 4 | |
| 5 | - Inputs: design spec, domain constraints, integration points |
| 6 | - Outputs: interface contract document |
| 7 | - Gates: interface is testable and accepted by caller/implementer |
| 8 | - Required disciplines: `stage-gate` |
| 9 | - Next: `/domain-modeling` or `/writing-plans` |
| 10 | |
| 11 | > **本仓库不维护此 skill 的内容**。完整纪律请读: |
| 12 | > `<SUPERPOWERS_SKILL_ROOT>/design-an-interface/SKILL.md` |
| 13 | |
| 14 | ## 何时调 |
| 15 | |
| 16 | - brainstorming 之后,writing-plans 之前 |
| 17 | - 需要把功能拆成可测试的接口 |
| 18 | |
| 19 | ## 衔接点 |
| 20 | |
| 21 | - **产出**:接口契约文档 |
| 22 | - **下一步**:`/domain-modeling` 或 `/writing-plans` |
| 23 | - **门控**:`disciplines/stage-gate` 第 2 层 |
| 24 | |
| 25 | ## 降级方案(superpowers 未装时) |
| 26 | |
| 27 | 如果 `<SUPERPOWERS_SKILL_ROOT>/design-an-interface/` 不存在,按以下 4 步产出接口契约: |
| 28 | |
| 29 | ### 1. 列举调用方与实现方 |
| 30 | |
| 31 | - **调用方**是谁?(controller / 巴枪 / 第三方系统) |
| 32 | - **实现方**是谁?(哪个 service / 模块) |
| 33 | - **触发场景**有哪些?(主动调用 / 事件回调 / 定时) |
| 34 | |
| 35 | ### 2. 写接口契约表 |
| 36 | |
| 37 | 每个接口必须含 5 列: |
| 38 | |
| 39 | | 列 | 含义 | 例子 | |
| 40 | |---|---|---| |
| 41 | | Name | 方法/路径名 | `POST /api/v1/asn/receive` | |
| 42 | | Input | 入参 schema | `{tcAsnId, lpnList[]}` | |
| 43 | | Output | 出参 schema | `{receivedQty, exceptionList[]}` | |
| 44 | | Errors | 错误码字典 | `E_ASN_NOT_FOUND(40401)` | |
| 45 | | Pre/Post | 前置/后置条件 | 前置:ASN 状态=10;后置:状态=30 | |
| 46 | |
| 47 | ### 3. 验收契约 |
| 48 | |
| 49 | - **可测试性**:每个契约都对应 1 个测试用例(契约层用) |
| 50 | - **错误码对齐**:与全局 `09-QA审计报告` 的错误码字典一致 |
| 51 | - **联调**:与调用方对齐字段名 / 类型,**字段名严禁猜测**(走 `disciplines/no-field-guessing`) |
| 52 | |
| 53 | ### 4. 输出 + 签字 |
| 54 | |
| 55 | 写到 `docs/superpowers/specs/<topic>-interface.md`,末尾 `## Sign-off` 等用户白名单签字(4 句之一)。 |
| 56 | |
| 57 | ### 最小纪律摘要 |
| 58 | |
| 59 | - **契约是合同**:写下来就不准改,改了要重新签字 |
| 60 | - **错误码全局唯一**:不复用业务字段名当错误码 |
| 61 | - **Pre/Post 必须**:只写 Input/Output = 验收没边界 |
| 62 | - **联调不靠人脑**:调用方拿到契约文档就能写 Mock |
| 63 | |
| 64 | ### 安装提示 |
| 65 | |
| 66 | ```bash |
| 67 | npx skills@latest add obra/superpowers-design-an-interface |
| 68 | ``` |