Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/devcodex-labs/devcodex --skill api-verification명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | api-verification |
| description | 接口验证规范 — 双产物(.http + .cjs)生成 + 自动化执行脚本 |
在 dev/fix 工作流涉及接口变更时,生成归档级双产物并执行验证:
.http — 可执行请求示例(VS Code REST Client 格式).cjs — 自动化执行脚本(Node.js)说明:本 Skill 不负责“给前端或调用方看的轻量接口说明”。这类阅读型目标文档由
dev-docs的light-api/frontend-api模式负责。
test-router 负责识别本轮是否存在 API/HTTP 契约变更、归档级接口验证或回归接口探针需求。api-verification,本 Skill 的 .http + .cjs 双产物和自动化执行规则仍然强制适用。| 工作流 | 触发条件 |
|---|---|
| dev | 新增/修改 API 接口 |
| dev-optimization | 优化前(建立基线)和优化后(对比验证) |
| dev-scenario-test | 场景测试基于接口规范 |
| fix | 修复涉及接口行为变更 |
| test-router | TestRoute 判定存在对外 HTTP/API 契约变更、归档级接口验证或接口回归探针 |
.http 文件(可执行请求示例)# <模块名> API 验证请求示例
@baseUrl = http://localhost:3000
@contentType = application/json
@token = replace-with-token-if-required
@language = zh-CN
@userName = test-user
@userEmail = test@example.com
### POST 创建用户
# @description 创建新用户账号
# @expects 201 + 返回体包含 data.id(人工检查提示)
POST {{baseUrl}}/api/users
Content-Type: {{contentType}}
Accept-Language: {{language}}
# 鉴权值默认可按用户要求直写;只有用户 / 项目要求可分享或脱敏时才保留占位变量
Authorization: Bearer {{token}}
{
"name": "{{userName}}",
"email": "{{userEmail}}"
}
###
存放:任务目录根 *-接口验证.http(dev 需求目录或 fix bug 目录,遵循 02-output-paths.instructions.md 产物路径规范)
.cjs 文件(自动化脚本)// *-接口验证.cjs
const http = require('http')
const https = require('https')
const assert = require('assert')
const BASE_URL = process.env.API_BASE_URL
if (!BASE_URL) throw new Error('API_BASE_URL is required; point it at an already running target')
const ENDPOINTS = [
{
name: 'list users',
method: 'GET',
path: '/api/users',
body: null,
expected: { status: 200, jsonPaths: { 'data.items': value => Array.isArray(value) } }
}
]
function getPath(value, dottedPath) {
return dottedPath.split('.').reduce((current, key) => current == null ? undefined : current[key], value)
}
async function () {
( {
url = (path, )
client = url. === ? https : http
payload = body ? .(body) :
options = {
: url.,
: url. || (url. === ? : ),
: ,
method,
: { : , ...headers }
}
(payload) {
options.[] =
options.[] = .(payload)
}
req = client.(options, {
data =
res.(, data += chunk)
res.(, {
assert.(res., expected., )
(expected.) assert.(data.(expected.), )
json = data ? .(data) :
( [jsonPath, predicate] .(expected. || {})) {
assert.(((json, jsonPath)), )
}
({ : res., : data, json })
})
})
req.(, reject)
(payload) req.(payload)
req.()
})
}
() {
(. === ) ()
( endpoint ) {
(endpoint., endpoint., endpoint., endpoint., endpoint.)
}
.()
}
().( {
.(error. || error.)
process. =
})
存放:任务目录根 *-接口验证.cjs(dev 需求目录或 fix bug 目录,遵循 02-output-paths.instructions.md 产物路径规范);归档级脚本只连接外部已运行实例,不在脚本内启动服务。
.http 文件(覆盖所有公开接口).cjs 脚本(endpoint matrix 非空,包含状态码/契约字段断言,响应路径来自已确认 API 契约或 Profile).cjs 脚本,确认全部通过当目标仅为本地调试、联调排查或一次性自用验证,且不会作为需求/bug 的正式归档产物提交时,可使用轻量模式:
.http 或单个 .js / .cjs 脚本,不强制生成双产物config.local.json、env、secretRef 或 secret manager.http 不生成 .cjs(双产物缺一不可)runTests() 必须非零退出OfficialApiEvidenceGate:读取官方 API 文档、公开契约或源码证据;不可用时记录降级证据、兼容风险和采用依据。AsyncDbTruthSourceVerificationGate:区分真实数据源、异步请求、缓存替换、失败回退和刷新边界;不得只凭当前 UI 空白、mock 或同步阻塞路径判断接口可用。FrontendAsyncCacheRenderGate / StaleWhileRevalidateGate:有旧缓存先渲染旧数据并异步刷新替换,不能回退为空白或 loading-only。API_BASE_URL 或同等配置连接用户已启动的目标实例items/id/data.* 等固定响应形状当成所有项目的默认事实.http 必须声明标准变量块:@baseUrl、@contentType,鉴权接口必须声明 @token,有语言/区域差异时必须声明 @languageUserFacingVerificationArtifactLanguageGate:.http 的标题、说明、人工检查提示、接口验证脚本注释和执行说明默认使用用户当前语言;项目要求英文、双语或特定文档语言时按项目要求;HTTP 方法、Header、变量名、JSON 字段和代码标识保持原样。.http 的 Host 建议通过 {{baseUrl}} 便于切换目标;鉴权头默认可直写真实 Token、Cookie、API Key 或项目私有密码,只有用户 / 项目要求可分享或脱敏时才使用 Authorization: Bearer {{token}} 等占位变量ApiDocVerificationSync:检查归档级 .http / .cjs 是否需要同步;若不更新,写 N/A + skipReason.cjs 应按 TestRoute 查询持久化真相源,并在可能时验证最终消费者响应字段.http 默认定位为“请求样本 + 可选轻提示”,不承诺跨宿主统一断言语法;正式归档级验证以 .cjs 为准当接口间有依赖关系(如先登录取 token → 再调用业务接口)时,须使用流程串联模式:
// 串联示例:先获取 token,再使用 token 调用业务接口
async function runFlow() {
const loginRes = await testEndpoint('POST', '/auth/login', { user: 'test', pass: 'test' }, { status: 200 })
const token = JSON.parse(loginRes.body).token
await testEndpoint('GET', '/api/resource', null, { status: 200 }, { Authorization: `Bearer ${token}` })
}
触发条件:接口测试用例中有前序接口产出数据被后序接口消费(如 token/id/session)。