MiniProgram Command-line Interface
MiniProgram Command-line Interface (MiniProgram CLI) offers mini-program developers a text-based tool for managing mini programs on Mini Program Platform. This tool is available across Windows, macOS, and Linux systems. It enables you to automate development processes and integrate your workflow into a continuous integration and delivery (CI/CD) pipeline.
This topic provides a comprehensive reference of available commands of MiniProgram CLI and instructions on how to use the CLI.
Command reference
The following table lists all available commands of MiniProgram CLI and the corresponding command descriptions:
Command name | Description |
| Check the installed CLI's version information. |
| Get a full list of commands and their usage, or help of a specific command. |
| Initialize the CLI with your access token. For more information, refer to Initialize MiniProgram CLI. |
| Retrieve the current CLI initialization settings. For more information, refer to Check initialization settings. |
| Generate a QR code for previewing your mini program. For more information, refer to Preview mini programs. |
| Upload a mini-program package to Mini Program Platform. For more information, refer to Upload mini programs. |
Prerequisites
Before using the CLI commands, ensure that you meet the following prerequisites:
- Have a basic knowledge of running command lines in Windows, macOS, or Linux systems.
- Install Node.js 16 on your operating system.
- Learn the permissions of your user role on Mini Program Platform to prevent any unauthorized operation errors. For more information, refer to Member roles.
- Ensure that the mini program that you intend to operate via MiniProgram CLI is already created within your workspace. For guidance on creating a mini program, refer to Create mini programs.
Install or upgrade MiniProgram CLI
You can install or upgrade the latest MiniProgram CLI version by running the following command in your preferred terminal:
npm install -g @antglobal/miniprogram-cliIf you require a specific CLI version, include the version number by adding @<version> after the package name. The installation process only takes a few seconds. To confirm the installation or check the installed version, run the following command:
miniprogram-cli -v
> 1.0.0Initialize MiniProgram CLI
After installing MiniProgram CLI for the first time, you must initialize it with your access token. This step links the CLI to your Mini Program Platform account, which verifies your identity and access permissions. To complete the initialization, take the following two steps:
Step 1: Obtain access keys
The access token consists of the following two parts:
- Access Key ID: The unique identifier of the user.
- Secret Access Key: The confidential key used to authenticate and verify the user's identity.
To obtain this information, follow these steps:
- Log in to Mini Program Platform and navigate to the workspace containing the target mini program.
- Click the profile icon in the top-right corner, then click My Profile.
- In the Access Keys section, click Generate Keys.
- In the confirmation dialog, follow the on-screen instructions to set a password to encrypt the file that contains the keys.
- Click Generate Keys.
- Check your email inbox for an email titled Your MiniProgram CLI Access Keys Are Ready, then follow the instructions in the email to obtain the keys from the attached ZIP file.
Note: For security reasons, the secret key is always masked on the platform. If you generated keys before September 22, 2026, you will not have received an email containing your keys. If you need the keys, for example, to set up the CLI on a new machine for the first time, you can obtain valid keys in the following ways:
- If you have already used the keys to initialize the CLI on another machine, retrieve the existing keys from the CLI configuration file. For details, see Check initialization settings.
- If you do not have the keys stored anywhere, click Regenerate Keys to create new ones.
Step 2: Run the initialization command
To initialize the CLI, run the following command:
# miniprogram-cli init [options]
# Options:
# -i,--access-key-id
# -s,--secret-access-key
miniprogram-cli init --access-key-id <accessKeyId> --secret-access-key <secretAccessKey>You can also use this command to update your credentials later. Refer to the following table for details about the command options:
Option | Required | Description |
| No | Specify this option with the access key ID you obtained in Step 1. Otherwise, you will be prompted to enter the value in the terminal. |
| No | Specify this option with the secret access key you obtained in Step 1. Otherwise, you will be prompted to enter the value in the terminal. |
Use the CLI commands
Mini-program developers can use the MiniProgram CLI commands for various scenarios. The commands offer multiple options and parameters, allowing for customization of their behavior. The following sections provide detailed descriptions and sample codes for using the CLI commands.
Check initialization settings
If you encounter a permission error, you might need to review your current initialization settings. You can run the following command to obtain the location of your configuration file and the current settings:
miniprogram-cli info
> configuration file: /User/yourname/.miniprogram-cli/settings.json
> { "accessKeyId": "-", "secretAccessKey": "-" }Preview mini programs
After you complete the development process, you can preview your mini program from an end user's perspective within the target super app.
To initiate the preview, run the miniprogram-cli preview [options] command to generate a QR code, and then use the super app to scan the code to open your mini program.
# miniprogram-cli preview [options]
# Options:
# -m,--mini-program-id
# -w,--workspace-id
# -sa,--super-app-id
# -p,--project-path
miniprogram-cli preview -w <workspaceId> -sa <superAppId> -m <miniProgramId>Note:
After confirming that the directory of your mini program project exists (specified by the -p option), it reads the file size (source package) under the directory. The maximum size for uploads from the CLI is 100 MB. For more information, see:
- FAQ: What's the maximum size of a mini program when uploading by CLI to Mini Program Platform?
- FAQ: What should I do if the package size (main package or subpackage) is too large?
Command syntax
When using this command, you can specify the following options:
Option | Required | Description |
| No | The unique ID that is assigned by Mini Program Platform to identify the workspace where your mini program is created. Note:
|
| No | The unique ID that is assigned by Mini Program Platform to identify the super app that is used to scan the generated QR code for previewing your mini program. Note:
|
| No | The unique ID that is assigned by Mini Program Platform to identify a mini program that you need to preview. This mini program must be accessible by your role in the specified workspace. Note:
|
| No | The directory of your mini-program project. If not specified, the value is the current working directory by default. |
Upload mini programs
After you finish developing and debugging your mini program, you can upload its project to Mini Program Platform. This prepares you to release the mini program to a super app.
Run the miniprogram-cli upload [options] command to upload your mini-program project:
# miniprogram-cli upload [options]
# Options:
# -m,--mini-program-id
# -w,--workspace-id
# -sa,--super-app-id
# -p,--project-path
# -mv,--mini-program-version
miniprogram-cli upload -w <workspaceId> -sa <superAppId> -m <miniProgramId> -mv <miniProgramVersion>Note:
After confirming that the directory of your mini program project exists (specified by the -p option), it reads the file size (source package) under the directory. The maximum size for uploads from the CLI is 100 MB. For more information, see:
- FAQ: What's the maximum size of a mini program when uploading by CLI to Mini Program Platform?
- FAQ: What should I do if the package size (main package or subpackage) is too large?
Command syntax
When using this command, you can specify the following options:
Option | Required | Description |
| No | The unique ID that is assigned by Mini Program Platform to identify the workspace where your mini program is uploaded. Note:
|
| No | The unique ID that is assigned by Mini Program Platform to identify the super app where your mini program is to be released. This ID must belong to the default super app determined by the platform. Note:
|
| No | The unique ID that is assigned by Mini Program Platform to identify the mini program for upload. This mini program must be accessible by your role in the specified workspace. Note:
|
| No | The directory of your mini-program project. If not specified, the value is the current working directory by default. |
| No | The version number of the uploaded mini program. The value follows the Note:
|