API Interface Design
Developmentapi-interface-designAPI Interface Design is an Agent Skill for development published in the TencentBlueKing/bk-ci repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
设计 BK-CI API 契约时使用,例如 Resource 路径设计、HTTP 方法选择、请求响应对象、错误码和版本策略。当用户要定义接口而不是实现业务逻辑时优先使用。
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/TencentBlueKing/bk-ci/blob/HEAD/ai/skills/api-interface-design/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/api-interface-design, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
API 接口设计
适用场景
- 设计新的 RESTful API
- 定义 Resource 接口、请求体和响应体
- 设计错误码、分页格式和版本策略
- 评审接口命名和路径结构
不适用场景
- 实现业务逻辑或服务分层
- 处理参数校验落地细节
- 只改前端页面展示
快速指导
- 这个 skill 关注的是“接口契约怎么设计”,不是“接口代码怎么实现”。
- 设计前先判断调用方是谁,再决定
/user/、/service/、/build/、/open/等路径前缀。 - 路径、方法、返回结构、错误码和版本策略要作为一套契约一起设计。
- 能用资源语义表达的,就不要退化成动作式杂糅接口。
- 如果问题已经进入服务分层或实现细节,切到
backend-microservice-development。
高信号规则
- 接口设计的核心是稳定契约,而不是先把功能堆出来
- 错误码、分页和返回包装会直接影响前后端协作成本
- 调用方不同,接口前缀和暴露方式也应不同
关键陷阱
- 路径命名反映不出资源语义
- HTTP 方法和真实操作语义不一致
- 只设计成功响应,不设计错误返回和版本演进
延伸阅读
- 如果你在实现后端服务:再看
backend-microservice-development - 如果你在做参数校验:再看
common-technical-practices