apifox-cli
通过 Apifox CLI 管理 Apifox 项目资源。触发场景:运行接口自动化测试/测试套件,查询/创建/更新/删除接口、环境、Schema、Mock、分支等项目资源,导入导出 API 文档,查看测试报告,管理 Runner、定时任务、通知等 CI/CD 配置。CLI 输出为结构化 JSON,常含 agentHints.nextSteps;所有命令支持 --help。
- Installs
- 8.1K
- Last 24h
- +64
- Trending rank
- #2821
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://apifox.com --skill apifox-cli- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads apifox-cli automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Apifox CLI
用 Apifox CLI 完成用户请求;不要凭记忆拼 payload,优先让 CLI 的 --help、cli-schema、cli-schema validate、agentHints.nextSteps 驱动下一步。
新会话检查
- 首次处理 Apifox CLI 任务时,先轻量确认 CLI 可用:
apifox --version、apifox --help。 - 如果
apifox不存在或无法输出版本,先安装 CLI:npm i -g apifox-cli@latest --registry=https://registry.npmmirror.com/。 - 安装后执行
apifox login --with-token <TOKEN>登录。API 访问令牌可在 Apifox 客户端或网页端「用户头像 → 账号设置 → API 访问令牌」创建。 - 不要每次默认升级;只有命令返回版本过低/unknown command/参数缺失疑似旧版导致,或用户任务依赖新能力时,才建议升级。
基础用法
apifox --help
apifox <command> --help
apifox <command> <subcommand> --help
常用全局参数:
--project <projectId> 项目 ID
--branch <branchName> 分支名;纯数字值兼容旧 branchId
--access-token <token> 覆盖当前登录 token
--api-base-url <url> 私有部署地址
登录与项目
- 未登录时让用户提供 API 访问令牌,执行:
apifox login --with-token <TOKEN>。 - Apifox CLI 的鉴权凭证存在
~/.apifox/config.toml;不要把 token 打印到日志、提交到仓库或写进普通聊天摘要。 - 如果用户未指定项目,先查看当前工作区是否存在
.apifox/settings.json;如其中有常用默认projectId,优先使用该项目。 - 项目 ID 可推荐用户从「项目设置 - 基本设置 - 项目 ID」获取;或先执行
apifox project list,给用户确认需执行命令的目标项目。 - 写入任何本地配置文件前先询问用户。
写入标准流程
强制:执行 create 或 update 命令前必须先获取完整的资源定义和数据格式,并在正式执行前通过 cli-schema validate 校验写入准确,具体流程:
- 查对应资源执行命令的 JSON schema:
apifox cli-schema get <schemaKey> - 生成资源的 JSON 数据文件。
- 校验:
apifox cli-schema validate <schemaKey> --file <path> - 只有
validate无误后,才执行真实create或update命令。
命令输出结果后,优先读取 JSON 输出里的 agentHints.nextSteps 继续执行或恢复。
CLI 事实优先
- 具体命令、参数、schema key 以当前 CLI 输出为准:
apifox <command> --help、apifox cli-schema list、agentHints.nextSteps。 - 如本 skill 与当前 CLI 输出不一致,以当前 CLI 输出执行,并同步修正本 skill 的事实性描述。
CLI 写入权限声明
- 执行写入被 AI(CLI 来源)权限限制时,若用户未声明,不要替用户选择,优先询问写入方式:开启目标分支的直接编辑权限,或在 AI 分支上编辑目标分支数据。
- 如用户需直接编辑主分支、迭代分支或通用分支数据,请用户在 Apifox 客户端 2.8.32+ 版本在「项目设置 - 功能设置 - AI 功能设置 - 外部 AI 编辑权限」开启直接编辑权限的开关。
- 如用户选择 AI 分支,流程是: step1:创建 AI 分支并指定来源分支; step2:按实际需要导入(pick-to)来源分支资源; step3:按用户需求编辑 AI 分支; step4:完成后,提醒用户确认是否发起合并请求或合并。
- 从 CLI 直接执行合并/合并请求时,要求来源分支和目标分支的直接编辑权限开关均已开启;否则请提醒用户先打开对应分支类型的权限开关,或直接在客户端手动触发合并。
AI 分支说明
- AI 分支是给 AI/自动化修改项目资源的隔离分支,避免直接污染源分支。
- AI 分支若在 24 小时内与来源分支无差异,将自动归档。
- AI 分支初始为空,不会自动 clone 源分支资源;编辑/删除来源分支已有资源前,先导入到 AI 分支。
- AI 分支中新建资源无需先导入。
- AI 分支修改不会自动写回源分支;完成后必须让用户确认是否立刻合并或发起合并请求。
- 目标主分支受保护时(isProtected),优先走
merge-request,不要直接merge。
必须询问用户
- 登录 token、本地配置写入、私有部署地址。
- 创建/切换 AI 分支、导入源分支资源到 AI 分支。
- 删除、归档、覆盖导入、批量更新等破坏性操作。
- 将 AI 分支改动 merge / merge-request 回源分支。
- 是否升级 CLI。
故障恢复
| 现象 | 处理 |
|---|---|
| 未登录 | apifox login --with-token <TOKEN> |
| 不知道项目 | apifox project list |
| 不知道命令参数 | apifox <command> --help |
| 参数或 schema 错误 | 先跑 cli-schema get / cli-schema validate |
| AI 写入受限 | 解释 AI 分支/权限开关,让用户选择 |
| 私有部署 | 加 --api-base-url https://your-server |
FAQ
What does the apifox-cli skill do?
通过 Apifox CLI 管理 Apifox 项目资源。触发场景:运行接口自动化测试/测试套件,查询/创建/更新/删除接口、环境、Schema、Mock、分支等项目资源,导入导出 API 文档,查看测试报告,管理 Runner、定时任务、通知等 CI/CD 配置。CLI 输出为结构化 JSON,常含 agentHints.nextSteps;所有命令支持 --help。
How do I install apifox-cli?
Run npx skills add https://apifox.com --skill apifox-cli in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/apifox-cli/ (personal) or .claude/skills/apifox-cli/ (project).
Which AI agents can use apifox-cli?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is apifox-cli safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains apifox-cli?
It is published by apifox.com in apifox.com. It has 8,146 recorded installs.
More from apifox.com
apifox-import-export
apifox.com
Apifox 导入导出与质量门禁:导入 OpenAPI/Postman/Apifox 原生格式,导出 OpenAPI/HTML/Markdown/Postman/Apifox 原生格式;导入前校验 spec 完整性、tags 分组、schema/body 覆盖率,导入后验证计数、模块和资源可见性。
apifox-test-case
apifox.com
Apifox 接口测试用例:test-case 与 test-data 的查询、创建、更新、删除、分类和运行;处理测试步骤、断言、提取变量、前后置处理器、数据集,以及“CLI 创建后前端测试步骤无法展示”等问题。
apifox-cli-checkup
apifox.com
Apifox CLI 使用检查与版本确认:命令成功但页面没看到、创建后 list/get 找不到、测试运行失败、报告缺失、agentHints/help/实际行为不一致,或怀疑本机 CLI 版本不是最新时使用。
apifox-test-automation
apifox.com
Apifox 自动化测试执行、套件与 CI:test-suite、scheduled-task、runner、apifox run、执行参数、迭代数据、报告上传和 CI 回归。复杂 test-scenario 步骤建模请使用 apifox-test-scenario。
apifox-workflow-api-lifecycle
apifox.com
Apifox API 生命周期工作流:从需求到接口设计、Schema、环境、Mock、测试用例、文档导出/发布和分支合并。用户要“创建一组 API 并补齐测试/Mock/文档”时使用。
apifox-test-scenario
apifox.com
Apifox 测试场景建模:test-scenario 的查询、创建、更新、删除和运行;导入接口、单接口用例或其它场景步骤;添加场景引用步骤;复杂步骤编排、接口步骤/条件/循环/等待/脚本/数据库等步骤衔接、前后置操作、变量引用、断言、提取器和场景调试最佳实践。用户要创建或维护复杂自动化测试流程时使用。
Popular devops & cloud skills
microsoft-foundry
microsoft/azure-skills
Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent create, managed harness agent create, GitHub Copilot harness agent, create agent, update agent, add tool to agent, invoke agent, agent insights, evaluate agent, batch eval, continuous eval, continuous monitoring, agent CI/CD, optimize prompt, improve prompt, optimize agent instructions, Agent Optimizer scaffold, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure
azure-diagnostics
microsoft/azure-skills
Debug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe triage. WHEN: debug production issues, troubleshoot app service, app service high CPU, app service deployment failure, troubleshoot container apps, container app 503 or target port mismatch, troubleshoot functions, function telemetry missing or stopped after a config/connection-string change, troubleshoot AKS, VM RDP, Linux SSH, VM black screen, can't connect to VM, reset VM password, NSG or firewall blocking, kubectl cannot connect, kube-system/CoreDNS failures, pod pending, crashloop, node not ready, upgrade failures, analyze logs, KQL, insights, image pull failures, cold start issues, health probe failures, resource health, root cause of errors, troubleshoot event hubs, troubleshoot service bus, messaging SDK error, AMQP connection failure, message lock lost, lock renewal during long-running processing, service bus dead letter.
azure-prepare
microsoft/azure-skills
Prepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Terraform), and Dockerfiles for the Azure Developer CLI (azd) workflow. USE ONLY when the user explicitly wants to use azd as the deployment tool, or the project already has an azure.yaml file. DO NOT USE FOR: non-azd deployments, Python App Service code-only deploys (use python-appservice-deploy), or cross-cloud migration (use azure-cloud-migrate). WHEN: prepare app for azd, create azure.yaml, set up azd infrastructure, modernize app for Azure with azd, deploy with azd, function app, timer trigger, service bus trigger, event-driven function, managed identity, generate Bicep, generate Terraform, create and deploy to Azure.
azure-ai
microsoft/azure-skills
Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.
azure-deploy
microsoft/azure-skills
Execute Azure deployments for ALREADY-PREPARED applications that have existing .azure/deployment-plan.md and infrastructure files. DO NOT use this skill when the user asks to CREATE a new application — use azure-prepare instead. This skill runs azd up, azd deploy, terraform apply, and az deployment commands with built-in error recovery. Requires .azure/deployment-plan.md from azure-prepare and validated status from azure-validate. WHEN: "run azd up", "run azd deploy", "execute deployment", "push to production", "push to cloud", "go live", "ship it", "bicep deploy", "terraform apply", "publish to Azure", "launch on Azure". DO NOT USE WHEN: "create and deploy", "build and deploy", "create a new app", "set up infrastructure", "create and deploy to Azure using Terraform" — use azure-prepare for these.
azure-validate
microsoft/azure-skills
Pre-deployment validation for Azure readiness. Run deep checks on configuration, infrastructure (Bicep or Terraform), RBAC role assignments, managed identity permissions, and prerequisites before deploying. WHEN: validate my app, check deployment readiness, run preflight checks, verify configuration, check if ready to deploy, validate azure.yaml, validate Bicep, test before deploying, troubleshoot deployment errors, validate Azure Functions, validate function app, validate serverless deployment, verify RBAC roles, check role assignments, review managed identity permissions, what-if analysis, validate Container Apps deployment.