API Lifecycle Workflow
You must read
before starting. If there is a conflict between the old main entry and the domain rules of this workflow, the current CLI help and this workflow shall prevail. Read
,
,
step by step; read
when complex test processes are involved, and read
when execution and CI are involved.
The specific endpoint, schema, environment, test-report commands shall be subject to the current CLI help. This workflow is used for end-to-end delivery from requirements to API assets, testing, reports, and branch merging, focusing on resource order, quality gates, and delivery verification. When the Agent executes, it should prioritize forming a closed-loop of
help/schema -> get -> validate -> write -> run/report
, and should not write based solely on old documents or memory.
Applicable Scenarios
- Create or update a set of interfaces based on requirements.
- Organize interfaces, Schema, directories, and tests after importing OpenAPI/Postman.
- Generate API spec from code repositories, PRDs, requirement documents, test documents, or discussion content and then import it into Apifox.
- Complete Mock, test cases, documents, and publishing settings for interfaces.
- Complete API changes in AI branches and prepare for merging.
Workflow
text
Confirm project/branch
-> If importing from code/documents, first perform spec generation and quality gate checks
-> Design interfaces and Schema
-> Configure environment and variables
-> Configure Mock
-> Create interface test cases
-> Run tests and view reports
-> Export/publish documents
-> Merge or create MR
Step 1: Confirm Context
Confirm identity, project, target branch, and whether an AI branch is required according to the current CLI help.
- When the user wants to directly modify the main branch/iteration branch, confirm the AI write permission or use an AI branch.
- If modifying existing resources through an AI branch, first import the source resources using .
Step 2: Design API Resources
Use API design resource commands such as endpoint, schema, response-component, security-scheme, folder according to the current CLI help.
Minimum boundaries: endpoint is the interface definition, test-case is the test case under the interface, do not mix them; reusable resources such as schema, response-component, security-scheme should be created first, then referenced by the endpoint; environment variables should not be written into common-parameter.
If the task is to generate and import API spec from code repositories, PRDs, or documents, first read
../apifox-import-export/SKILL.md
, complete generator search, OpenAPI indicator verification, tags grouping, and temporary project import verification, then proceed to interface design or test supplement.
- Create reusable resources such as , , first, then reference them in the endpoint.
- Must use to verify the actual saved structure after creation.
Step 3: Configure Environment
Use environment and runtime context commands such as environment, variables, database-connection, vault according to the current CLI help.
- Create or update the environment if no suitable environment exists.
- Sensitive variables should not appear in the final response.
- It is recommended to explicitly add when running test and CI delivery commands to avoid irreproducibility caused by changes in the default environment.
Step 4: Complete Test Cases
Read
../apifox-test-case/SKILL.md
.
- Do not create empty test cases.
- Use to verify that steps, assertions, and extractors are saved after creation.
Step 5: Verification and Delivery
- If there is an exception in the test report, first distinguish between local reports, cloud uploads, and download summaries; transfer to if necessary.
- Transfer to if there is an exception in front-end display.
- Transfer to when merging is required.
- If the test run of a newly created API returns 404 or assertion failure, first check whether Mock/environment is configured, and do not directly determine that the endpoint or test-case creation failed. A run failure caused by unconfigured Mock is an execution environment issue, not equivalent to unsaved design assets.
Non-violable Rules
- Do not skip project/branch confirmation.
- Do not directly write to protected main branches.
- Do not create interfaces without verifying the saved structure.
- Do not only create empty test cases.
- Do not treat test failures as interface creation failures; locate API definition, environment, test cases, and execution reports separately.