Prerequisites: first read
../apifox-cli/SKILL.md. If the old general entry point conflicts with this skill's domain rules, the current CLI help and this skill take precedence.
Specific command parameters are subject to the current CLI help. This skill only supplements the rules most easily misused in branch collaboration: branch context, AI branches, pick-to, write permissions, protected branches, and merge confirmation. After an Agent writes on a branch, it must use the same --branch to read back and verify; do not judge whether a resource exists across branches using the default perspective.
When to Use
- The user specifies
--branchor says to operate on a certain branch. - Create, view, update, archive, or delete branches.
- Create an AI branch and modify source branch resources.
- Pick-to source branch resources to an AI branch.
- Merge branches or create/approve merge requests.
- Encounter AI write permission restrictions.
Command Entry Points
- Branch management:
apifox branch --help - Merge requests:
apifox merge-request --help - Resource commands usually all support
--branch <branchName>. Keep the same branch context when querying, creating, updating, and running tests.
First Determine How to Modify
Before writing to a branch, first ask the user clearly which method they want:
- Directly edit the target branch: suitable when the user explicitly allows direct modification and the target branch has no protection or permission restrictions.
- Edit via an AI branch: suitable for AI making changes on behalf of the user to endpoints, test cases, test scenarios, or configurations; also suitable when the target branch is protected, external AI direct writing is not enabled, or the user wants to isolate and verify first before merging.
Before starting to write, you must confirm:
- Project ID.
- Source branch and target branch.
- The scope of resources to modify.
- Whether subsequent creation of a merge request or direct merge is allowed.
AI Branch Workflow
AI branches are used to isolate AI modifications and avoid directly polluting the source branch.
确认源分支和目标变更
-> 创建 AI 分支
-> pick-to 已有资源
-> 在 AI 分支修改
-> 验证 get/run/report
-> preview merge-request
-> 用户确认后 create merge-request 或 merge
Standard steps:
- Specify the source when creating an AI branch:
--from <sourceBranchName>。 - Use the canonical name:
ai/年月日-from-来源分支名-功能或模块名, for exampleai/20260312-from-main-userRegister。 - Before modifying existing resources on the source branch, first use
branch pick-toto import them into the AI branch; creating new resources does not require pick-to. - When modifying, querying, and verifying on the AI branch, always include
--branch <aiBranchName>。 - Verify results by resource type, for example
get、run, local reports, or cloud report checks. - Before merging, first
merge-request preview, and have the user confirm the scope of impact. - After the user confirms, then
merge-request createorbranch merge; when the target main branch is protected, prefer a merge request.
AI Branch Notes:
- An AI branch is initially empty and will not automatically copy all resources from the source branch.
branch getmay returntype: SPRINTandisAiBranch: true; this does not mean--type sprintshould be used during operations. AI branch-related operations should still use--type ai。
Branch Parameter Rules
- Prefer using the branch name:
--branch <branchName>。 - Pure numeric branchId is compatible, but the branch name is more intuitive and clearer in logs and troubleshooting.
- Within the same task, querying, creating, updating, and running tests must carry the same branch context, to avoid being unable to find resources from the main/default perspective.
pick-to rules
- Must carry
--type ai。 - Only supports importing from the main branch or regular iteration branches into an AI branch.
- Cannot import into the main branch.
- Cannot use an AI branch as the source branch.
- Use
--include-endpoint-casesto also import interface test cases when importing interfaces.
Write permission rules
- The main branch, iteration branches, and common branches may require enabling "External AI edit permission".
- Typical error messages include
Automation caller branch required。 - Creating an AI branch may succeed, but writing content to the AI branch may still fail because "Allow AI to modify AI branch content" is turned off.
- When encountering write restrictions, do not automatically switch strategies; let the user choose to enable direct edit permission, or switch to using an AI branch.
- When the target main branch is protected, prefer
merge-request preview/create, do not directlybranch merge。
Non-violable rules
- Do not create an AI branch without user confirmation.
- Do not modify existing resources of the source branch in an AI branch without pick-to first.
- Do not omit in branch tasks
--branch <branchName>。 - Do not merge, create merge-request, or approve merge request without user confirmation.
- Do not delete or archive branches unless the user explicitly requests it.
- When encountering
Automation caller branch required, you must stop and ask the user to choose a permission strategy; do not automatically create or switch AI branches.
Common recovery
| Symptom | Handling |
|---|---|
| get without branch cannot find resources | Carry --branch <branchName> and retry |
| Cannot find source resources in the AI branch | First branch pick-to import |
projectBranchState has a count but the AI branch page is empty |
Do not mistakenly assume it has been imported; the AI branch still requires pick-to |
| run-config returns 404 under the branch | After confirming case/endpoint/environment/branch all exist, switch to apifox-cli-checkup |
| merge blocked by protected branch | Switch to merge-request |