apifox-cli-checkup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCLI 使用检查与版本确认
CLI Usage Check and Version Verification
前置条件:先阅读。若旧总入口与本 skill 的规则冲突,以当前../apifox-cli/SKILL.md和本 skill 为准。根据资源类型再读取对应业务 skill。apifox <command> --help
本 skill 用于公开 CLI 使用排查,不依赖内部接口或内部代码。目标是确认命令、项目、分支、环境、资源 ID、报告位置和 CLI 版本是否一致,再回到具体业务 skill 修正资源结构。Agent 排查时优先以当前 help、schema validate、get 回读和 agentHints 组成闭环,不要只看 summary 文案。
Prerequisite: Readfirst. If there is a conflict between the old main entry and the rules of this skill, follow the current../apifox-cli/SKILL.mdand this skill. Read the corresponding business skill according to the resource type.apifox <command> --help
This skill is used for public CLI troubleshooting and does not rely on internal interfaces or code. The goal is to verify consistency of commands, projects, branches, environments, resource IDs, report locations, and CLI versions, then return to the specific business skill to correct the resource structure. When troubleshooting with Agent, prioritize forming a closed loop with current help, schema validate, get readback, and agentHints instead of relying solely on summary copy.
何时使用
When to Use
- CLI 返回成功,但 Apifox 页面没看到资源或展示不完整。
- 创建后 找不到资源。
list/get - 测试用例、测试场景或测试套件运行失败。
- 本地报告或云端报告找不到、没有步骤详情。
- 、help、示例或实际命令行为互相矛盾。
agentHints - 用户或测试同学反馈“我这边没有这个参数”“命令不认识”,需要确认 CLI 版本。
- CLI returns success, but the resource is not visible or displayed incompletely on the Apifox page.
- The resource cannot be found via after creation.
list/get - Test cases, test scenarios, or test suites fail to run.
- Local or cloud reports are missing or lack step details.
- , help, examples, or actual command behavior contradict each other.
agentHints - Users or testers report "I don't have this parameter" or "The command is unrecognized", and you need to verify the CLI version.
先做 5 件事
First 5 Actions
- 记录原始命令、projectId、branch、resourceId、environmentId、文件路径和是否带 。
--api-base-url - 执行 ,确认本机 CLI 版本;参数不存在时先看是否需要更新。
apifox --version - 执行对应 ,以当前公开 help 为准,不凭旧文档或记忆使用参数。
apifox <command> --help - 用对应 回读资源,确认是否写入了预期项目、分支、模块、目录或分类。
list/get - 如果是运行或报告问题,先区分本地报告和云端报告:未带 时,不要去云端报告列表找本次结果。
--upload-report
- Record the original command, projectId, branch, resourceId, environmentId, file path, and whether is included.
--api-base-url - Execute to confirm the local CLI version; if parameters are missing, first check if an update is needed.
apifox --version - Execute the corresponding , follow the current public help instead of using parameters based on old documents or memory.
apifox <command> --help - Use the corresponding to read back the resource and confirm if it has been written to the expected project, branch, module, directory, or category.
list/get - For run or report issues, first distinguish between local and cloud reports: if is not included, do not look for the result in the cloud report list.
--upload-report
版本检查
Version Check
先看版本和命令 help:
bash
apifox --version
apifox import --help
apifox test-case category --help如果测试说明里要求的新参数没有出现在 help 中,优先更新 CLI:
bash
apifox update非交互环境或确认直接更新时:
bash
apifox update --yes如果自动更新提示影响排查,可以让用户在 shell 配置里设置禁用每日检查,但这不会影响手动 :
apifox updatebash
export APIFOX_CLI_DISABLE_UPDATE_CHECK=1版本排查结论必须写清:当前 、命令路径(如 )、缺失的参数名、建议更新方式。
apifox --versionwhich apifoxFirst check the version and command help:
bash
apifox --version
apifox import --help
apifox test-case category --helpIf the new parameters required in the test instructions do not appear in the help, prioritize updating the CLI:
bash
apifox updateFor non-interactive environments or when confirming direct updates:
bash
apifox update --yesIf automatic update prompts interfere with troubleshooting, users can disable daily checks in shell configuration, which does not affect manual :
apifox updatebash
export APIFOX_CLI_DISABLE_UPDATE_CHECK=1The version troubleshooting conclusion must clearly state: current , command path (e.g., ), missing parameter name, and recommended update method.
apifox --versionwhich apifoxhelp 与提示冲突
Conflict Between Help and Hints
- 公开文档、agentHints、历史示例和实际行为不一致时,优先以当前 和实测为准。
apifox <command> --help - 不主动推荐 help 未公开的隐藏别名。
- 时以真实
success=false字段和退出码为准,不要相信 summary 里的成功语义。success - 如果命令提示下一步但实际参数不存在,记录为 CLI 提示问题,并使用 help 中公开的替代命令。
- When public documents, agentHints, historical examples, and actual behavior are inconsistent, prioritize the current and actual tests.
apifox <command> --help - Do not actively recommend hidden aliases not disclosed in help.
- When , rely on the real
success=falsefield and exit code instead of the success semantics in the summary.success - If the command prompts the next step but the actual parameter does not exist, record it as a CLI prompt issue and use the alternative command disclosed in help.
页面看不到资源
Resource Not Visible on Page
优先检查:
- 是否写入了正确 project。
- 是否带了正确 。
--branch - 是否资源在 AI 分支中,且页面当前查看的是同一分支。
- 是否写入到了预期模块或目录。
- 测试用例是否使用了有效 。
categoryId - Apifox 原生格式二次导入时,是否因为模块策略导致资源进入了新模块。
常用回读命令:
bash
apifox endpoint list --project <projectId> --branch <branchName>
apifox test-case list --project <projectId> --endpoint <endpointId> --branch <branchName>
apifox test-scenario get <scenarioId> --project <projectId> --branch <branchName> --with-case-detail如果 能看到,但页面看不到,先确认页面筛选条件、分支、模块、目录、分类是否一致;不要直接重建资源。
get/listPrioritize checking:
- Whether it is written to the correct project.
- Whether the correct is included.
--branch - Whether the resource is in an AI branch and the page is viewing the same branch.
- Whether it is written to the expected module or directory.
- Whether the test case uses a valid .
categoryId - When re-importing Apifox native format, whether the resource enters a new module due to module policies.
Common readback commands:
bash
apifox endpoint list --project <projectId> --branch <branchName>
apifox test-case list --project <projectId> --endpoint <endpointId> --branch <branchName>
apifox test-scenario get <scenarioId> --project <projectId> --branch <branchName> --with-case-detailIf the resource is visible via but not on the page, first confirm that the page filter conditions, branch, module, directory, and category are consistent; do not directly rebuild the resource.
get/list测试用例排查
Test Case Troubleshooting
- 创建前必须用 获取有效
apifox test-case category --project <projectId>。categoryId - 当前 不支持
test-case category;按接口查看用例用--endpoint。test-case list --endpoint <endpointId> - 能看到结构,只说明资源已保存,不代表 requestBody、断言、提取变量和脚本一定能运行。
test-case get - 运行失败时检查 environment、变量、请求体、前后置脚本、断言和报告详情。
- Must obtain a valid using
categoryIdbefore creation.apifox test-case category --project <projectId> - The current does not support
test-case category; use--endpointto view cases by endpoint.test-case list --endpoint <endpointId> - The fact that shows the structure only indicates the resource has been saved, not that the requestBody, assertions, extracted variables, and scripts can run correctly.
test-case get - When execution fails, check the environment, variables, request body, pre/post scripts, assertions, and report details.
测试场景排查
Test Scenario Troubleshooting
- 只创建场景元数据;复杂步骤需要后续
test-scenario create、import-steps或add-ref。update --file - 创建或更新后先 ,确认步骤树和 HTTP 详情展开正常。
test-scenario get --with-case-detail - 步骤间变量为空时,检查是否运行完整场景、步骤编号、响应路径、提取变量和环境选择。
- 不要把 的结构直接写成
test-case步骤。test-scenario
- only creates scenario metadata; complex steps require subsequent
test-scenario create,import-steps, oradd-ref.update --file - After creation or update, first execute to confirm the step tree and HTTP details expand normally.
test-scenario get --with-case-detail - When variables between steps are empty, check if the full scenario is run, step number, response path, extracted variables, and environment selection.
- Do not directly write structure as
test-casesteps.test-scenario
运行与报告排查
Execution and Report Troubleshooting
- 未指定 时,服务端可能使用项目默认环境;为了复现,建议显式指定。
--environment - 本地报告看 和
--out-dir。--out-file - 只有运行时带 ,云端
--upload-report才能看到本次报告。test-report list/get/download - 报告没有步骤详情时,先对比本地 JSON 和云端报告;本地也没有详情时,回查运行对象和资源结构。
- 有副作用的测试不要在生产环境默认执行。
- When is not specified, the server may use the project's default environment; for reproduction, it is recommended to specify it explicitly.
--environment - Check and
--out-dirfor local reports.--out-file - Only when is included during execution can this report be viewed via cloud
--upload-report.test-report list/get/download - When the report lacks step details, first compare the local JSON and cloud report; if the local report also lacks details, review the execution object and resource structure.
- Do not execute tests with side effects in the production environment by default.
常见分流
Common Diversion
| 现象 | 处理 |
|---|---|
| 新参数不识别 | |
| 创建成功但页面没看到 | 检查 project、branch、模块、目录、分类、页面筛选 |
| test-case 页面看不到 | 检查 |
| 场景步骤不展示 | |
| run-config 或运行前失败 | 确认 case/scenario/endpoint/environment/branch 都存在且一致 |
| 云端报告找不到 | 确认运行时是否带 |
| agentHints 和 help 冲突 | 以当前 help 和实测为准,记录提示问题 |
| Phenomenon | Handling |
|---|---|
| New parameter unrecognized | Execute |
| Created successfully but not visible on page | Check project, branch, module, directory, category, and page filters |
| Test case not visible on page | Check |
| Scenario steps not displayed | Execute |
| run-config or pre-run failure | Confirm that case/scenario/endpoint/environment/branch all exist and are consistent |
| Cloud report not found | Confirm if |
| agentHints conflicts with help | Follow current help and actual tests, record the prompt issue |