/testkit:api-test-automationfrom testkit
Generates and executes API automation tests from Swagger/OpenAPI, YApi, Postman Collection, and existing pytest assets. Supports Arazzo workflows, Schemathesis fuzzing, data-driven tests, and end-to-end import-to-reporting.
Ships in testkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
铁律:不得以“契约已导入”代替自动化执行,也不得为追求覆盖率而绕过目标环境、写操作或 secret 安全门禁。
把一次用户请求视为一个完整任务。按需完成接口发现、定义导入、测试选择、自动化执行和结果总结,不向用户暴露内部模块交接。契约驱动是实现手段,不是公开能力边界;自动化能力不得只停留在 schema 检查。
不得静默丢弃来源语义。OpenAPI/Swagger 必须保留全部字段和原版本;YApi/Postman 只要有损,就必须先写入 source-manifest.json,再生成或执行测试。
默认执行采用双轨:
已有 Python 测试资产或 Arazzo 无法安全表达的专用验证,才使用受控 pytest 兼容入口。pytest collection 和 execution 都会加载用户 Python 代码,必须显式限定项目目录和 selector;不得把它描述成静态扫描,也不得用 pytest 取代默认双轨。
不要把登录或 cleanup 藏在任意 Python/JavaScript 中。需要理解选型依据时读取 community-practices.md。
--force 不覆盖。不得强迫所有请求经过固定阶段:
所有路径都必须先识别来源,再写入文件;执行前复核 warning 和 unsupported feature;secret 只放环境变量;配置错误与测试发现必须分开。只有用户要求纯分析时才停在检查阶段。
识别或转换来源时读取 source-formats.md。
写项目文件前先检查:
python <skill-dir>/scripts/import_api.py inspect <file-or-url>
导入文件、原始 spec URL 或 Swagger UI URL:
python <skill-dir>/scripts/import_api.py import <file-or-url> \
--output-dir <project>/api-tests
通过 YApi Open API 导入项目:
YAPI_TOKEN=<secret> python <skill-dir>/scripts/import_api.py import \
--yapi-base-url https://yapi.example.invalid \
--yapi-project-id 123 \
--output-dir <project>/api-tests
只有用户明确要求扫描代码时才扫描本地后端:
python <skill-dir>/scripts/import_api.py inspect --code-root <backend-dir>
python <skill-dir>/scripts/import_api.py import --code-root <backend-dir> \
--output-dir <project>/api-tests
需要限制路径时使用 --code-prefix /api。不得推断 code root、默认扫描当前仓库、导入应用模块或执行应用代码。普通目录作为位置参数时,不得视为源码扫描请求。
YApi token 必须通过环境变量传入,不得出现在命令、产物、日志或回复中;不得抓取 YApi HTML。
除 import_api.py、run_api.py、run_workflows.py、run_automation.py、pytest_compat.py、migrate_legacy_cases.py 外,其余 scripts/*.py 都是这些入口复用的内部模块,不直接作为公共命令调用。
导入产物:
openapi.yaml:原样语义保留的 OpenAPI/Swagger、从 YApi/Postman 规范化的 OpenAPI 3.1,或明确源码扫描产生的待复核 OpenAPI 3.1 路由骨架。source-manifest.json:来源 hash、格式/版本、保真度、警告、不支持能力和 operation 数量。YApi/Postman 转换不得标为无损。源码扫描必须标为 skeleton,保留 operation 级来源信息,不得发明请求/响应 schema、状态码或认证规则。不支持的脚本只记录警告,不得执行。
执行测试或处理认证前读取 execution.md。
只做契约广覆盖时使用 Schemathesis:
python <skill-dir>/scripts/run_api.py <project>/api-tests/openapi.yaml \
--url <base-url> \
--mode smoke \
--output <project>/api-tests/reports/run-result.json
模式:
smoke:examples + coverage;未确认写入权限时只选择 GET/HEAD/OPTIONS/TRACE。full:examples + coverage + fuzzing + stateful;仅用于隔离测试环境。stateful:只跑 operation chain;可能创建、修改或删除共享数据时必须明确确认。使用 --header-env HEADER=ENV_VAR 注入 secret;缺少环境变量时必须在联网前失败。只有用户需要 Allure 时才使用 --allure-results <dir>。
生产环境不得运行生成式负向、fuzzing 或 stateful 测试。环境身份不明时,只做安全检查和导入,然后请求确认目标。
确定性业务旅程使用 Arazzo sidecar:
python <skill-dir>/scripts/run_workflows.py <project>/api-tests/workflow.yaml \
--schema <project>/api-tests/openapi.yaml \
--url <base-url> \
--workflow authenticatedUser \
--input username=demo \
--input-env password=API_PASSWORD \
--output <project>/api-tests/reports/workflow-result.json
用 --data cases.csv 或 --data cases.json 批量覆盖 workflow inputs;用 --tag 或 --workflow 选择场景。setup、主步骤和 cleanup 中任何 POST/PUT/PATCH/DELETE 都必须在确认目标后加 --allow-mutating-target,workflow 自身不得绕过该门禁。需要 CI 报告时可加 --junit 或 --allure-results。
登录结果需要继续给 Schemathesis 使用时,执行一体化双轨命令:
python <skill-dir>/scripts/run_automation.py <project>/api-tests/workflow.yaml \
--schema <project>/api-tests/openapi.yaml \
--url <base-url> \
--preflight-workflow loginAndVerify \
--input-env username=API_USERNAME \
--input-env password=API_PASSWORD \
--schema-header-from-output Authorization=token \
--header-template 'Authorization=Bearer {value}' \
--allow-preflight-mutating-target
workflow 必须显式声明供 schema 阶段使用的 output。Runner 只通过临时环境变量传递 secret,结束后立即恢复环境;不得把 output 值写进报告。只有确认生成式测试也可写入目标时,才加 --allow-schema-mutating-target。
运行已有 pytest 资产时读取 pytest-compatibility.md。先 collection 并生成绑定源码指纹的 manifest,再选择 manifest 中的完整 nodeid 执行:
python <skill-dir>/scripts/pytest_compat.py collect <pytest-project> \
--selector tests/api \
--output <project>/api-tests/pytest-source-manifest.json
python <skill-dir>/scripts/pytest_compat.py run <pytest-project> \
--manifest <project>/api-tests/pytest-source-manifest.json \
--nodeid 'tests/api/test_users.py::test_get_user[active]' \
--junit <project>/api-tests/reports/pytest-junit.xml \
--output <project>/api-tests/reports/pytest-run-result.json
默认设置 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1;只有项目明确声明所需插件时,collection 才可重复使用 --plugin。source manifest 过期、未知 nodeid、零选择、collection error、JUnit 损坏或 pytest 版本变化都必须作为配置错误失败关闭。pytest exit code 是结果权威来源,JUnit 只提供结构化 testcase 证据。
迁移旧版 project.yaml + flows/ + cases/:
python <skill-dir>/scripts/migrate_legacy_cases.py \
--project <legacy>/project.yaml \
--schema <project>/api-tests/openapi.yaml \
--output <project>/api-tests/workflow.yaml \
--manifest <project>/api-tests/legacy-migration.json
迁移支持 YAML、JSON、CSV、XLSX,保留 flow、setup/steps/teardown、标签、环境/项目变量、默认 header、提取和 eq/ne/数值/contains/exists 断言。遇到无法无损表达的旧语义必须以 conversion 错误停止,不得写部分 workflow。
面向用户的 CLI 只有 import_api.py、run_api.py、run_workflows.py、run_automation.py、pytest_compat.py 和 migrate_legacy_cases.py;其余 scripts/ 文件是内部模块。agents/、evals/ 和 tests/ 只供维护、评测与回归验证,不作为用户工作流入口。
写项目文件、解释保真度或消费 run-result.json 时读取 contracts.md。
operationId 引用 operation,负责确定性业务旅程。推荐修改前先分类:
source:输入不可读、格式/版本不支持或文档损坏。conversion:来源能力无法安全映射到 OpenAPI。configuration:缺少 base URL、工具、secret 或参数非法。collection:pytest collection 加载失败、零用例或 selector 不合法。transport:DNS、TLS、连接或超时。contract:状态码、content type、header 或 response schema 不匹配。behavior:业务断言或状态迁移失败。cleanup:测试状态创建后无法清理。不得为了让实现通过而改写源契约。展示证据,并说明更可能过期的是契约还是实现。
--force、写方法、fuzzing 或 stateful 扩大影响面。lossless、high、high-with-losses 还是源码 skeleton。agents/openai.yaml (opens in a new tab)evals/evals.json (opens in a new tab)evals/live-evals.json (opens in a new tab)evals/run_live_eval.py (opens in a new tab)references/community-practices.md (opens in a new tab)references/contracts.md (opens in a new tab)references/execution.md (opens in a new tab)references/pytest-compatibility.md (opens in a new tab)references/source-formats.md (opens in a new tab)scripts/code_source_adapter.py (opens in a new tab)scripts/execution_provenance.py (opens in a new tab)scripts/import_api.py (opens in a new tab)scripts/legacy_case_adapter.py (opens in a new tab)scripts/migrate_legacy_cases.py (opens in a new tab)scripts/pytest_compat.py (opens in a new tab)scripts/pytest_manifest_plugin.py (opens in a new tab)scripts/run_api.py (opens in a new tab)scripts/run_automation.py (opens in a new tab)scripts/run_workflows.py (opens in a new tab)scripts/source_adapters.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
api-testing, openapi, swagger, yapi, postman, schemathesis, arazzo, pytest
26 skills in this plugin
/android-static-app-reverseAndroid 应用纯静态逆向分析工作流,支持从 ADB 导出 APK、处理 split APK、使用 JADX/apktool/Vineflower 反编译、盘点静态产物、检测加固、提取 API endpoint 并生成带证据和置信度的报告。当用户要求「用 JADX 逆向」「从手机导出安装包」「查包名并反编译」「提取接口」「检测加固」「分析 APK/JADX 输出」「检查 Retrofit/OkHttp/Volley」「查找静态泄漏」「追踪 Android 调用链」时使用。/app-test执行 Android、iOS 与 Web 的真实运行测试,验证页面交互、系统行为和跨端业务旅程,记录实际断言与证据。用户要按已确认用例测试网站、操作手机应用、跑端到端用例或验证 WebView 时使用;没有代码仓库、需要逆向网站并为 TestSpec 建立实现证据时走 web-app-reverse,录屏转缺陷报告走 video-to-issue。/defect-verification组织缺陷重现、修复版本定向复测与关联回归,建立 RED、GREEN、REGRESSION 证据并关联来源失败和再验收。用户要复现 Bug、验证修复、复测旧 APK 与新 APK 或判断缺陷是否关闭时使用;实际操作委托当前可用的 app-test/API 能力,不默认修改业务代码。npx claudepluginhub winhok/testkit --plugin testkitOther plugins' skills for the same job