MaxCompute CLI (maxc) is a command-line tool invoked through the Alibaba Cloud CLI as aliyun maxc. All commands produce structured JSON output for script automation and AI Agent integration.
Installation and verification
maxc is distributed through the Alibaba Cloud CLI. To use maxc, you must install or update the Alibaba Cloud CLI.
-
Supported operating systems
Operating system
Supported versions
Supported architectures
Linux
CentOS 8+, RHEL 8+, Ubuntu 16.04+, Debian 9+, and other major distributions. CentOS 7 has reached EOL and is not recommended.
x86_64 (64-bit), ARM64
macOS
macOS 11 (Big Sur) or later
Intel and Apple silicon (Universal binary)
Windows
Windows 10 and later (64-bit)
x86_64 only. 32-bit and ARM64 are not supported.
-
Select the tab for your operating system and follow the installation steps. Multiple methods are available — choose one.
Linux
Install using a Bash script (Recommended)
The following options are supported:
-
Install the latest version
If you do not specify a version, the script automatically installs the latest version.
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)" -
Install a previous version
Use the
-Voption to specify the version to install. To view available previous versions, go to the GitHub Releases page./bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)" -- -V 3.3.18
Install from a TGZ package (.tar.gz)
-
Download the installation package.
-
Download the latest version:
NoteRun
uname -mto check your Linux system architecture. If the terminal output isarm64oraarch64, your system has an ARM64 architecture. Other outputs indicate an AMD64 architecture.-
For AMD64 systems:
curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli-linux-latest.tgz -
For ARM64 systems:
curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-arm64.tgz -o aliyun-cli-linux-latest.tgz
-
-
Download a previous version: Go to the GitHub Releases page to download installation packages for previous versions.
The file name format for Linux installation packages is
aliyun-cli-linux-<version>-<architecture>.tgz. Replace<version>with the target version number, such as 3.3.18, and<architecture>with `amd64` or `arm64`.
-
-
Decompress the installation package to obtain the
aliyunexecutable file.tar xzvf aliyun-cli-linux-latest.tgz -
Move the executable file to the
/usr/local/bindirectory. This lets you run thealiyuncommand from any path.sudo mv ./aliyun /usr/local/bin/
macOS
Install using Homebrew (Recommended)
NoteBefore you continue, make sure that you have installed and configured Homebrew.
Install the latest version of the Alibaba Cloud CLI:
brew install aliyun-cliInstall using the graphical interface (PKG)
Double-click the package to install — no command-line tool required.
-
Download the installation package.
-
Download the latest version: Open the download link https://aliyuncli.alicdn.com/aliyun-cli-latest.pkg in your browser to download the latest installation package.
-
Download a previous version: Go to the GitHub Releases page to view and download installation packages for previous versions.
The file name format for macOS PKG (macOS Installer Package, .pkg) installation packages is
aliyun-cli-<version>.pkg.
-
-
Double-click the downloaded installation package and follow the instructions to complete the installation.
Install using a Bash script
The installation commands are the same as those for Linux. For more information about parameter descriptions, see the "Install using a Bash script" section for Linux.
-
Install the latest version
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)" -
Installing previous versions
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)" -- -V 3.3.5
Install from a TGZ package (.tar.gz)
-
Download the installation package.
-
Download the latest version:
curl https://aliyuncli.alicdn.com/aliyun-cli-macosx-latest-universal.tgz -o aliyun-cli-macosx-latest-universal.tgz -
Download a previous version: Go to the GitHub Releases page to download installation packages for previous versions.
The file name format for macOS installation packages is
aliyun-cli-macosx-<version>-universal.tgz.
-
-
Decompress the installation package to obtain the
aliyunexecutable file.tar xzvf aliyun-cli-macosx-latest-universal.tgz -
Move the executable file to the
/usr/local/bindirectory. This lets you run thealiyuncommand from any path.sudo mv ./aliyun /usr/local/bin/
Windows
ImportantThe Alibaba Cloud CLI is available only for Windows AMD64 systems. It does not support 32-bit or ARM64 architectures.
Install using the graphical user interface (GUI)
Download and decompress the installation package
-
Download the installation package.
-
Download the latest version: Open the download link https://aliyuncli.alicdn.com/aliyun-cli-windows-latest-amd64.zip in your browser to download the latest installation package.
-
Download a previous version: Go to the GitHub Releases page to download installation packages for previous versions.
The file name format for Windows installation packages is
aliyun-cli-windows-<version>-amd64.zip.
-
-
Extract
aliyun.exefrom the installation package to a directory such asC:\AliyunCLI.Note-
This file must be run from a command-line terminal. Double-clicking the file does not work.
-
Remember this installation path. You will need it when you configure the PATH environment variable.
-
Configure the PATH environment variable
-
Press the
Windows+Skeys to open the search interface, and then enter the keyword "environment variables". -
In the search results, click Edit the environment variables for your account to open the Environment Variables settings.
-
In the User variables section, select the environment variable with the key
Pathand click Edit.
-
In the edit window, click New and enter the installation directory path for the Alibaba Cloud CLI. For example,
C:\ExampleDir. Replace this with your actual installation directory path.
-
Click OK in all open dialog boxes to save the changes.
-
Restart your terminal session for the changes to take effect.
Install using a PowerShell script
-
Create a new script file named
Install-CLI-Windows.ps1. You can runNew-Item Install-CLI-Windows.ps1in PowerShell to create the file, or create a new text document in File Explorer and rename it. -
Copy the following code and save it to the script file.
-
Run the script file to install the Alibaba Cloud CLI as shown in the following examples.
NoteThe example script path is
C:\Example\Install-CLI-Windows.ps1. Before you run the command, replace the script path with the actual location.-
If you do not specify a version, the script automatically installs the latest version. The default installation path is
C:\Users\<USERNAME>\AppData\Local\AliyunCLI.powershell.exe -ExecutionPolicy Bypass -File C:\Example\Install-CLI-Windows.ps1 -
Use the
-Versionand-InstallDiroptions to specify the installation version and directory. To view available previous versions, go to the GitHub Releases page.powershell.exe -ExecutionPolicy Bypass -File C:\Example\Install-CLI-Windows.ps1 -Version 3.3.15 -InstallDir "C:\ExampleDir\AliyunCLI"
-
-
-
Verify the installation
Run the following command to verify the installation.
aliyun maxc --versionIf the version number appears, the installation succeeded. If an error occurs, check the CLI version. For more information, see Install or update the Alibaba Cloud CLI.
Authentication
aliyun maxc reuses the Alibaba Cloud CLI credential system. All authentication methods configured with aliyun configure (except OAuth) work directly — maxc inherits the current profile's credentials.
# Configure authentication using the Alibaba Cloud CLI (if you have not already done so)
aliyun configure --mode AK
# Verify that maxc can access MaxCompute
aliyun maxc auth whoami --json
For more information about authentication methods, see Configure and manage identity credentials.
Configure a MaxCompute project
When you use maxc for the first time, you must specify the MaxCompute project and endpoint:
aliyun maxc auth login \
--endpoint http://service.cn-hangzhou.maxcompute.aliyun.com/api
If you omit --project, an interactive project selector appears. For continuous integration (CI) scenarios, you must explicitly specify the project:
aliyun maxc auth login \
--project my_project_dev \
--endpoint http://service.cn-hangzhou.maxcompute.aliyun.com/api \
--no-picker
The MaxCompute project configuration is saved in ~/.maxc/config.yaml.
View and verify
# View the current identity and project
aliyun maxc auth whoami --json
# Check permissions for a specific table
aliyun maxc auth can-i --table my_table --operation SELECT --json
Quick Start
# 1. Configure the project (authentication is already completed with aliyun configure)
aliyun maxc auth login \
--endpoint http://service.cn-hangzhou.maxcompute.aliyun.com/api
# 2. Browse tables
aliyun maxc meta list-tables --json
aliyun maxc meta describe my_table --json
# 3. Run a query
aliyun maxc query "SELECT * FROM my_table LIMIT 10" --json
# 4. Estimate the cost
aliyun maxc query cost "SELECT * FROM my_table" --json
# 5. Sample data
aliyun maxc data sample my_table --rows 5 --json
Global options
The following options can be placed anywhere in the command line and apply to all commands:
|
Option |
Description |
|
|
Outputs in JSON Envelope format (equivalent to |
|
|
Output format: json, table, csv, ndjson, markdown, or brief |
|
|
Specifies the configuration file path |
|
|
The target MaxCompute project (temporarily overwrites session settings) |
|
|
The target schema (temporarily overwrites session settings) |
Use --project and --schema to temporarily access other projects or schemas without changing the session configuration. Table names also support the schema.table format.
Command reference
SQL query (Query)
-
query modes
Three modes are available, selected by the first keyword:
aliyun maxc query <sql> # Run a query (default) aliyun maxc query cost <sql> # Estimate the cost aliyun maxc query explain <sql> # View the execution planThe default mode is read-only — DDL and DML statements are blocked on the client side. Use
--forceto bypass this restriction.aliyun maxc query "SELECT * FROM my_table LIMIT 10" --json -
Parameter description
Parameter
Description
Default value
<sql>SQL text
—
--fileReads the SQL from a file
—
--stdinReads the SQL from standard input
—
--max-rowsThe maximum number of rows to return
100
--page-sizeThe page size
—
--cursorThe pagination cursor (the return value from the last call)
—
--waitThe number of seconds to wait for synchronization. If a timeout occurs, the job_id is returned.
10
--dry-runDisplays only the query plan without running it
—
--cost-checkAborts the query if the estimated cost exceeds the threshold (in CUs)
—
--outputWrites the result to a file
—
--output-formatThe output file format: table, json, csv, or ndjson
—
--idempotency-keyThe deduplication key, used for idempotent retries
—
--retry-onA comma-separated list of retryable error codes
—
--max-retriesThe maximum number of retries
0
--retry-backoffThe backoff policy: fixed or exponential
fixed
--forceBypasses the read-only mode and allows DDL/DML statements
—
-
--waitbehavior-
--wait 10(Default): Polls synchronously for 10 seconds. If the job is complete, the result is returned. If a timeout occurs, the job_id is returned. -
--wait 0: Submits the job and immediately returns the job_id. -
--wait 300: Waits for a maximum of 5 minutes.
After a timeout, you can use
job wait <job_id>to continue waiting. -
-
Examples
# Run from a file aliyun maxc query --file my_query.sql --json # Cost protection: Automatically aborts if the estimated cost exceeds 100 CUs aliyun maxc query "SELECT * FROM orders" --cost-check 100 --json # Paging aliyun maxc query "SELECT * FROM orders" --page-size 50 --json aliyun maxc query "SELECT * FROM orders" --page-size 50 --cursor <next_cursor> --json # Write the result to a CSV file aliyun maxc query "SELECT * FROM orders LIMIT 1000" --output result.csv --output-format csv --json # Idempotent retry aliyun maxc query "INSERT INTO target SELECT * FROM source WHERE ds='20260601'" \ --force --idempotency-key "daily-etl-20260601" \ --retry-on "QUOTA_EXCEEDED" --max-retries 3 --retry-backoff exponential --json
Job management (Job)
Manages the lifecycle of asynchronous SQL jobs.
job submit
Submits an SQL job and immediately returns the job_id.
aliyun maxc job submit "SELECT * FROM large_table" --json
|
Parameter |
Description |
Default value |
|
|
SQL text |
— |
|
|
Reads the SQL from a file |
— |
|
|
Reads the SQL from standard input |
— |
|
|
The maximum number of rows to return |
100 |
|
|
The cost threshold (in CUs) |
— |
|
|
The deduplication key |
— |
|
|
Allows DDL/DML statements |
— |
job status / wait / result / cancel / diagnose
aliyun maxc job status <job_id> --json # Query the status
aliyun maxc job wait <job_id> --json # Wait for completion and return the result
aliyun maxc job result <job_id> --json # Get the result of a completed job
aliyun maxc job cancel <job_id> --json # Cancel a running job
aliyun maxc job diagnose <job_id> --json # Diagnose the cause of a failure
-
Additional parameters for job wait
Parameter
Description
Default value
--timeoutTimeout in seconds
300
--streamStreams progress output in NDJSON format
—
-
Additional parameters for job result
Parameter
Description
Default value
--max-rowsThe maximum number of rows to return
100
--cursorThe pagination cursor
—
job list
aliyun maxc job list --json # Lists recent jobs (20 by default)
aliyun maxc job list --limit 50 --json # Specify the number of jobs
Complete flow for an asynchronous query
# 1. Submit
JOB_ID=$(aliyun maxc query "SELECT * FROM large_table" --wait 0 --json \
| jq -r '.metadata.job_id')
# 2. Wait
aliyun maxc job wait "$JOB_ID" --timeout 600 --json
# 3. Get the result (supports paging)
aliyun maxc job result "$JOB_ID" --max-rows 1000 --json
Metadata browsing (Meta)
Table operations
# List tables
aliyun maxc meta list-tables --json
# View the table schema (--full displays the complete column list; summary mode is the default)
aliyun maxc meta describe my_table --json
aliyun maxc meta describe my_table --full --json
# Search for tables
aliyun maxc meta search "order" --json
# Search for columns
aliyun maxc meta search-columns "user_id" --json
list-tables and search support paging with --limit and --cursor. By default, search returns 20 items.
Partition operations
# List partitions (up to 100 by default)
aliyun maxc meta partitions my_table --json
aliyun maxc meta partitions my_table --limit 500 --json
# View the latest partition
aliyun maxc meta latest-partition my_table --json
# View data freshness
aliyun maxc meta freshness my_table --json
Projects and schemas
# List accessible projects
aliyun maxc meta list-projects --json
# List schemas in a project
aliyun maxc meta list-schemas --json
Semantic metadata
Provides business semantic information about tables for AI Agents. For more information, see AI Agent integration.
# Set semantic information
aliyun maxc meta semantic set my_table \
--desc "Order details table" \
--use-cases "Analyze daily order volume" "Calculate user repurchase rate" \
--json
# Get semantic information
aliyun maxc meta semantic get my_table --json
# List tables that are missing semantic information
aliyun maxc meta semantic list-missing --json
semantic set also supports --sample-questions, --column-semantics (JSON), --relations (JSON), and --stats (JSON).
Data operations (Data)
Data sample
Samples data from a table. For partitioned tables, the latest partition is selected by default. Views are not supported.
aliyun maxc data sample my_table --json
aliyun maxc data sample my_table --rows 20 --partition "ds=20260601" --columns "user_id,amount" --json
|
Parameter |
Description |
Default value |
|
|
The table name |
— |
|
|
The number of rows to sample |
5 |
|
|
The partition specification |
Latest is auto-selected |
|
|
The columns to include (comma-separated) |
All |
Data profile
Analyzes column statistics such as null percentages, unique value counts, and min/max values. Results are heuristic, based on a 20-row sample.
aliyun maxc data profile my_table --json
aliyun maxc data profile my_table --partition "ds=20260601" --jsonaliyun maxc data profile <table_name> --json
Data upload
Uploads a local CSV or TSV file to a table. For partitioned tables, --partition is required. Views and complex types (array, map, struct) are not supported.
aliyun maxc data upload my_table --file data.csv --json
aliyun maxc data upload my_table --file data.csv --partition "ds=20260601" --overwrite --json
|
Parameter |
Description |
Default value |
|
|
The destination table name |
— |
|
|
The local file path (required) |
— |
|
|
The partition specification (required for partitioned tables) |
— |
|
|
Uses INSERT OVERWRITE semantics |
— |
|
|
The field separator |
|
|
|
Indicates that the first row is data, not a header |
— |
|
|
The NULL marker |
|
|
|
The number of rows to upload per batch |
10000 |
Data download
Downloads table data to a local CSV or TSV file. For partitioned tables, --partition is required. Views are not supported.
aliyun maxc data download my_table --output data.csv --json
aliyun maxc data download my_table --output data.csv --partition "ds=20260601" --limit 100000 --json
|
Parameter |
Description |
Default value |
|
|
The source table name |
— |
|
|
The output file path (required) |
— |
|
|
The partition specification (required for partitioned tables) |
— |
|
|
The columns to include (comma-separated) |
All |
|
|
The maximum number of rows to download |
Unlimited |
|
|
The field separator |
|
|
|
Does not write a header row |
— |
|
|
The NULL output marker |
Empty string |
Session management (Session)
Manages the default project and schema for the current session. These are local operations that do not require a backend connection.
# Set the default project (specify at least --project or --schema)
aliyun maxc session set --project my_project_dev --json
# Set the default schema
aliyun maxc session set --schema my_schema --json
# View the current session
aliyun maxc session show --json
# Clear session settings
aliyun maxc session unset --json
To temporarily switch projects without modifying the session configuration, use the global --project parameter:
aliyun maxc meta list-tables --project other_project --json
aliyun maxc query "SELECT * FROM t LIMIT 5" --project other_project --json
Output format
JSON Envelope
Adding --json to any command produces a unified JSON Envelope (v2.0):
{
"version": "2.0",
"command": "query",
"status": "success",
"data": { ... },
"metadata": { ... },
"error": null,
"agent_hints": null
}
|
Field |
Type |
Description |
|
|
string |
Fixed at |
|
|
string |
The command that was run, such as |
|
|
string |
|
|
|
object |
The business data returned by the command |
|
|
object |
Execution metadata (such as project name, time consumed, and job_id) |
|
|
object/null |
Details of the error if the command failed |
|
|
object/null |
Recommended next actions for the AI Agent |
Data field
The structure of the data field varies based on the command:
|
Command |
Top-level keys in data |
|
query / job wait / job result |
|
|
query cost / query explain |
|
|
meta list-tables |
|
|
meta describe |
|
|
meta search / meta search-columns |
|
|
meta partitions |
|
|
meta latest-partition |
|
|
meta freshness |
|
|
data sample |
|
|
data profile |
|
|
job list |
|
|
job status / job cancel |
|
|
job diagnose |
|
|
auth whoami |
|
|
auth login |
|
|
auth can-i |
|
error field
If a command fails, the error field contains the following fields:
{
"code": "TABLE_NOT_FOUND",
"message": "Table 'orders' does not exist in project 'my_project'",
"suggestion": "Use 'aliyun maxc meta search orders --json' to find similar tables",
"recoverable": false
}
|
Field |
Description |
|
|
Error code (see the table below) |
|
|
Error description |
|
|
Recommended fix (optional) |
|
|
Indicates whether the operation can be retried |
|
|
The ODPS instance ID (only for query errors, optional) |
|
|
The LogView link (only for query errors, optional) |
|
|
Structured context (optional) |
Error codes
|
Error code |
Description |
Retryable |
|
|
Execution failed |
Yes |
|
|
Permission denied |
No |
|
|
Quota exceeded |
Yes |
|
|
SQL syntax or execution error |
No |
|
|
Cost limit exceeded |
No |
|
|
Resource not found |
No |
|
|
Table not found |
No |
|
|
Schema not found |
No |
|
|
Column not found |
No |
|
|
Input validation failed |
No |
|
|
Cannot connect to the backend |
Yes |
|
|
Job polling timed out |
Yes |
|
|
Write operation blocked by read-only mode |
No |
|
|
Write operation requires |
Yes |
|
|
CSV parsing failed |
No |
|
|
Internal error |
No |
Other formats
|
Format |
Description |
|
|
Readable table (default) |
|
|
Markdown format |
|
|
Single-line summary |
|
|
CSV (data rows only) |
|
|
Newline-delimited JSON, with one record per line |
AI Agent integration
maxc is purpose-built for AI Agent integration. The following sections cover its core design and usage patterns.
Unified JSON protocol
Every command's --json output follows a fixed Envelope protocol. Agents parse structured fields for reliable, predictable feedback.
-
status: Indicates success or failure. -
data: The business data. The structure is fixed based on the command type. -
error.code+error.suggestion: The error code and an executable suggestion for a fix. -
agent_hints.next_actions: The next command that is recommended by the CLI. This is a complete and executable command line. -
agent_hints.warnings: Risks to note, such as high costs or automatic partition selection.
Error self-healing
Each error response includes a suggestion field and agent_hints.next_actions that tell the Agent which command to run next:
|
Error scenario |
Guidance received by the Agent |
|
Table not found |
Suggests running |
|
Column not found |
Suggests running |
|
Insufficient permissions |
Suggests switching to the |
|
SQL syntax error |
Suggests running |
|
Quota exceeded |
Suggests running |
|
Job timeout |
Suggests running |
The Agent reads error.suggestion and reruns the suggested command to recover automatically — no hard-coded error handling required.
Read-only safety
maxc blocks all DDL and DML statements (CREATE, DROP, INSERT, UPDATE, DELETE) on the client side, preventing accidental data modifications. This local check runs before SQL is submitted to the server, with zero latency and no cost.
Write operations require the user to explicitly pass --force — the Agent should never add this on its own. Data uploads via data upload use a separate Tunnel API channel and are not subject to this restriction.
Cost awareness
Before the Agent runs a query, it can estimate the cost using query cost or set a cost limit using --cost-check:
# Estimate the cost
aliyun maxc query cost "SELECT * FROM large_table" --json
# Set a cost threshold
aliyun maxc query "SELECT * FROM large_table" --cost-check 100 --json
Querying a partitioned table without a partition filter can trigger a full table scan with high costs. The Agent should determine the partition range with meta partitions or meta latest-partition before running the query.
SKILL layered knowledge architecture
SKILL is a set of structured guidance documents installed on the Agent platform that teach the Agent how to use maxc for MaxCompute data tasks.
# One-click installation to Claude Code
aliyun maxc agent skill install --json
# Install on other platforms
aliyun maxc agent skill install cursor --json
aliyun maxc agent skill install windsurf --json
SKILL uses layered loading to optimize LLM context window efficiency:
|
Layer |
Content |
Loading time |
|
Main file SKILL.md |
Intent-to-command mapping table, core principles, workflows, decision tables |
Loaded automatically when a task is triggered |
|
Reference documents |
SQL dialect guide, query templates, partition strategies, error recovery manual, etc. |
Loaded on demand (only when the Agent needs it) |
Simple metadata queries require only the 270-line main file. Complex SQL generation or error recovery triggers on-demand loading of reference documents.
Supported Agent platforms:
|
Platform |
Installation path |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Other Agents |
Specify --dir to install to any directory |
SKILL management
# View the installation status on all platforms
aliyun maxc agent skill list --json
# Update installed SKILLs (after a new version is released)
aliyun maxc agent skill update --all --json
# View the differences between the installed version and the latest version
aliyun maxc agent skill diff claude-code --json
# Uninstall
aliyun maxc agent skill uninstall cursor --json
NL2SQL workflow
SKILL guides the Agent to convert natural language questions into SQL queries using the following flow:
User question
↓
1. meta search / meta list-tables → Find relevant tables
↓
2. meta describe → Understand table schema and column meanings
↓
3. data sample → View actual data to confirm column value formats
↓
4. meta partitions / latest-partition → Determine the partition range
↓
5. query cost → Estimate the cost
↓
6. query → Run the query and return the result
SKILL reference documents include a 700+ line MaxCompute SQL dialect guide covering function differences, type traps, query templates, and common error fixes.
Semantic metadata
The meta semantic command attaches business semantics to a table — descriptions, use cases, sample questions, and column semantics. When meta describe reveals missing semantics, the Agent can generate and save them:
aliyun maxc meta semantic set my_table \
--description "User behavior log table, recording click and view events within the app" \
--usage-scenario "User behavior analysis, funnel conversion statistics" \
--sample-questions '["What was the DAU for the last 7 days?", "What is the registration conversion rate trend?"]' \
--json
Subsequent Agent sessions read this information, creating a cycle of use, accumulation, and reuse.
Agent context
The Agent can retrieve the complete current context at once using agent context:
aliyun maxc agent context --json
This command returns the current authentication status, project, schema, and configuration path, helping the Agent decide whether to guide the user through authentication or project switching.