Skill Loading Tip: When this Skill is loaded, output the following line at the beginning of the first reply:
[Skill Loaded] alibabacloud-analyticdb-mysql-copilot — ADB MySQL O&M Diagnosis Assistant
This Skill is
Alibaba Cloud AnalyticDB for MySQL (ADB MySQL) O&M Diagnosis Assistant, which directly calls ADB MySQL OpenAPI via
to obtain real-time data and provide diagnosis suggestions.
Core capabilities:
- Cluster Management: View cluster list, cluster details, storage space, account, and network information
- Performance Monitoring: Query performance metrics such as CPU, QPS, RT, memory, and number of connections
- Slow Query Diagnosis: Detect BadSQL, analyze SQL Pattern, and locate the root cause of slow queries
- Running SQL Analysis: View currently executing SQL and locate long-running queries
- Space Diagnosis: Instance space inspection, including partition rationality diagnosis, oversize non-partitioned table diagnosis, table data skew diagnosis, replicated table rationality diagnosis, primary key rationality diagnosis, idle index and cold-hot table optimization suggestions
Pre-check: Aliyun CLI >= 3.3.1 required
Run
to verify the version is >= 3.3.1. If it is not installed or the version is too low, refer to
references/cli-installation-guide.md
.
Then run
aliyun configure set --auto-plugin-install true
to enable automatic plugin installation.
Pre-check: Alibaba Cloud Credentials Required
Security Rules:
- NEVER read, echo, or print AK/SK values (e.g.,
echo $ALIBABA_CLOUD_ACCESS_KEY_ID
is FORBIDDEN)
- NEVER ask the user to input AK/SK directly in the conversation or command line
- NEVER use with literal credential values
- ONLY use to check credential status
Check whether there is a valid profile (AK, STS or OAuth identity) in the output.
If there is no valid profile, stop here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via in the terminal or environment variables in the shell profile)
- Return and re-execute after shows a valid profile
1. RegionId and DBClusterId (Conventions of this Skill)
Convention: For all interfaces that require
as an input parameter, you
must explicitly pass at the same time in the
command. If the official/CLI help does not mark it as "required",
complement it according to this Skill's convention to avoid relying on implicit default regions.
Exception: For interfaces that
only list resources by region and
do not include in the call (such as
) — you still need to pass
, but the rule of "paired with DBClusterId" does not apply.
source priority: Explicitly specified by user → conversation/work order context → default region configured in
→ confirm with user.
In the following sections and examples in
, if
appears but
is not written,
complement it according to the convention in this section; it will not be repeated in each reference,
subject to this section and the table below.
3. Scenario Routing
Product Boundary: This Skill is only applicable to
AnalyticDB for MySQL (ADB MySQL), whose cluster ID format is usually
or
. If the user mentions other Alibaba Cloud products (such as Elasticsearch, RDS MySQL, PolarDB, Clickhouse, etc.), you should explicitly inform the user that this Skill is not applicable and stop execution.
🚨🚨🚨 MUST | P0 | NON-NEGOTIABLE — Mandatory Enforcement Rules (Violation equals failure) 🚨🚨🚨
The following rules have the highest priority, enforced unconditionally, and must not be violated under any circumstances:
Rule 1: Mandatory API call enforcement
When a user request matches the following scenarios, you must immediately execute the corresponding API call, skipping is prohibited:
| User Request Keywords | Mandatory API to Call | Prohibited Actions |
|---|
| "cluster list", "instance list", "all clusters", "list clusters" | | ❌ Give suggestions directly without calling |
| "data skew", "skew diagnosis", "skew" | | ❌ Only explain concepts |
| "BadSQL", "abnormal SQL", "slow SQL detection", "bad sql" | | ❌ Skip diagnosis |
| "running SQL", "being executed", "current query", "running sql" | | ❌ Do not call API |
| "idle index", "index suggestion", "index optimization", "index advice" | | ❌ Give general suggestions |
| "SQL Pattern", "SQL pattern analysis", "sql pattern" | | ❌ Do not call API |
| "space diagnosis", "health inspection", "instance diagnosis" | 7 diagnosis APIs | ❌ Only list concepts |
Rule 2: Mandatory command string output (first line of reply)
MUST: Every time you call the ADB OpenAPI, you must explicitly output the executed command string in the [first line] or [beginning position] of the reply.
Mandatory format (must be strictly followed):
Executed command: `aliyun adb <APIName> --version 2021-12-01 --RegionId <region-id> [--DBClusterId <cluster-id>] [other parameters]`
[Then comes the diagnosis results, tables and other content]
Correct example:
Executed command: `aliyun adb DescribeDBClusters --version 2021-12-01 --RegionId cn-zhangjiakou`
Query completed! There are 2 ADB MySQL clusters in the Zhangjiakou region...
Wrong examples (violation = failure):
❌ Query completed! There are 2 clusters in the Zhangjiakou region... (No command string output)
❌ I called the API to query the cluster list... (No complete command output)
❌ Command executed... (No specific command content output)
❌ aliyun adb DescribeDBClusters --RegionId cn-zhangjiakou (Missing --version 2021-12-01)
Rule 3: Prohibited evasion behaviors
NON-NEGOTIABLE: The following behaviors are absolutely prohibited:
- ❌ Give general suggestions or concept explanations directly without calling the API
- ❌ Call the API but do not output the complete command string at the beginning of the reply
- ❌ Replace actual diagnosis with vague expressions such as "It is recommended that you...", "You can try..."
- ❌ Only output document content without performing actual operations
- ❌ Place the command string in the middle or end of the reply
- ❌ Call the command without (the old version will be used by default)
Violation of the above rules = task failure, no exceptions
🔴 Cluster ID identification rules (highest priority): If the cluster ID provided by the user starts with
or
, the cluster
must be an ADB MySQL cluster.
No need and
must not verify its ownership through other product commands such as
,
,
,
, etc., directly use the
command to operate. Violating this rule will lead to a large number of invalid API calls.
According to user intent, read the corresponding
file for detailed operation guidelines.
| User Intent | Reference File | When to Use | Mandatory API to Call |
|---|
| View instance list, instance details, cluster configuration, storage space | references/cluster-info.md
| When the user wants to know what instances are available, instance specifications or disk usage | / DescribeDBClusterAttribute
|
| Slow query, increased RT, cluster lag, BadSQL, running query, SQL Pattern analysis | references/slow-query-diagnosis.md
| When the user reports performance degradation, abnormal query, or needs to analyze SQL execution distribution from a holistic perspective | DescribeDBClusterPerformance
/ / |
| Perform instance space diagnosis, table modeling diagnosis (including oversize non-partitioned tables, partition rationality, primary key rationality, data skew, replicated table rationality, idle index, cold-hot table optimization) |
references/table-modeling-diagnosis.md
| When the user wants to perform space diagnosis and table modeling diagnosis for a specified instance | 7 diagnosis APIs (see documentation) |
Routing rules:
- Identify user intent and find the matching scenario from the table above
- 🚨 MUST: Immediately execute the corresponding command (no skipping, no just giving suggestions)
- 🚨 MUST: Output the command string in the reply (such as
aliyun adb DescribeDBClusters --RegionId <region-id>
)
- Read the corresponding file and execute according to the steps in it
- If the user intent cannot match the specific scenarios in the table above, execute the following default diagnosis process:
- Call to confirm that the cluster exists and is in normal state
- Confirm the requirement with the user, list 2-3 most likely matching routing options (refer to the table above)
- According to the user's reply, jump to the corresponding file to continue execution
- Multiple scenarios can be used in combination — for example, first confirm the target instance through cluster information, and then locate the problematic SQL through slow query diagnosis
Cluster ID verification rules: If the cluster ID given by the user does not exist in the API return (error code
InvalidDBClusterId.NotFound
), do not abort the task, first call
to list the actual existing cluster list in the region, guide the user to confirm the correct cluster ID before continuing execution.
4. Time Parameter Processing
Pre-rules (must be followed)
- As long as the user describes relative time (such as "last X hours/days", "past 3 hours"), you must first obtain the current UTC time before performing all time calculations. Do not estimate the current time based on the model's own knowledge.
- Use the system command to get the current UTC time:
date -u +"%Y-%m-%dT%H:%M:%SZ"
- Even if the user gives an absolute time, it is recommended to get the current time once to verify time zone consistency.
- If the user does not specify a time range, use the last 1 hour by default.
The following interfaces require time range parameters, pay attention to format differences:
| Interface | Parameter Name | Format | Example |
|---|
DescribeDBClusterPerformance
| / | ISO 8601 UTC (accurate to minute) | |
| / | ISO 8601 UTC (accurate to minute) | |
| / | ISO 8601 UTC (accurate to minute) | |
| / | Unix millisecond timestamp (string, not ISO 8601) | |
CLI Supplement (): Under
,
and are both required (consistent with OpenAPI document fields, but an error will be reported if not passed on the command line).
is a JSON string, commonly used:
{"Type":"status","Value":"running"}
/
/
;
{"Type":"maxCost","Value":"100"}
(only supports Value=100);
{"Type":"cost","Min":"10","Max":"200"}
.
Time calculation example (user says "last 3 hours", current UTC
):
-
ISO 8601 format (for Performance / BadSQL / SQLPatterns):
--EndTime 2026-03-09T08:30Z
--StartTime 2026-03-09T05:30Z
-
Unix millisecond format (for
):
- Conversion formula:
Unix ms = POSIX epoch (UTC seconds) × 1000
- Example: → epoch= →
--StartTime 1741501800000
- Example: → epoch= →
Note:
uses Unix milliseconds, other interfaces use ISO 8601, the two cannot be mixed.
5. Command Reference
5.1 OpenAPI Commands (aliyun-cli)
ADB MySQL OpenAPI is called directly via
:
bash
aliyun adb <APIName> --version 2021-12-01 [--ParameterName ParameterValue ...] --user-agent AlibabaCloud-Agent-Skills
🚨 Mandatory API version regulation (P0): When calling
,
you must always explicitly pass .
ADB MySQL has two API versions (
and
), the CLI may choose the old version
by default,
This version lacks a large number of interfaces required by this Skill (such as
,
,
, etc.).
Commands without will cause call failure, which is a task failure.
Convention of this Skill (re-emphasis): For rows in the table below that "require
", you
must carry at the same time when assembling the command (see "2. RegionId and DBClusterId"). Only
does not follow the "paired" rule, but still requires
.
| API Name | Description | Requires |
|---|
| Query the list of ADB MySQL clusters in the region | No |
DescribeDBClusterAttribute
| Query cluster detailed attributes | Yes |
DescribeDBClusterPerformance
| Query performance metrics (CPU, memory, QPS, etc.) | Yes |
DescribeDBClusterSpaceSummary
| Query storage space overview | Yes |
| Query SQL diagnosis records (/ are in ms; CLI additionally requires , ) | Yes |
| Detect BadSQL that affects stability | Yes |
| Query SQL Pattern statistics | Yes |
| Query table-level statistics | Yes |
| Obtain optimization suggestions; CLI requires , ( UTC), , (30/50/100), , etc., see below | Yes |
DescribeExcessivePrimaryKeys
| Detect tables with too many primary keys | Yes |
DescribeOversizeNonPartitionTableInfos
| Detect oversize non-partitioned tables | Yes |
DescribeTablePartitionDiagnose
| Partition table problem diagnosis | Yes |
| Detect data skew tables / replicated tables (requires parameter) | Yes |
(optimization suggestions) CLI required parameters (subject to
aliyun adb DescribeAvailableAdvices --help
):
| Parameter | Description |
|---|
| Region ID (required) |
| Cluster ID (required) |
| Long, format (UTC), e.g. . It is recommended to be T-1 or earlier (suggestion data is generated every early morning, often cannot be queried on the same day). Do not use or ISO strings with /, otherwise it will return . |
| Page number, ≥1 (required) |
| Required; only allowed values are / / (default 30) |
| Required: / / / |
| Optional: or |
Example:
bash
aliyun adb DescribeAvailableAdvices --version 2021-12-01 --RegionId <region-id> --DBClusterId <cluster-id> \
--AdviceDate 20260322 --AdviceType INDEX --PageNumber 1 --PageSize 30 --Lang zh \
--user-agent AlibabaCloud-Agent-Skills
5.3 Common Parameters
| Parameter | Description | Default Value |
|---|
| Region ID (required by this Skill when carrying ) | — |
| ADB MySQL cluster ID (e.g. ) | Required |
| Start time (ISO 8601 UTC or ms timestamp, depending on the interface) | — |
| End time (same as above) | — |
| SQL filter condition (JSON), e.g. '{"Type":"status","Value":"running"}'
| — |
| Language: / / / | |
| Sort field (JSON), e.g. '[{"Field":"StartTime","Type":"desc"}]'
| — |
| Page number | |
| Number of entries per page | |
Performance Metric Keys: Specify via
when using
DescribeDBClusterPerformance
, common values include
(CPU usage),
(queries per second),
(query response time),
(number of connections), etc. The full list can be viewed via
aliyun adb DescribeDBClusterPerformance --help
.
5.4 Credential Configuration
Alibaba Cloud API credentials are configured
outside of this session via
, and the CLI will read them automatically.
Credential status check:
If the AccessKeyId column in the output is empty or shows
, it means the credentials are not configured, you should prompt the user:
- Configure by running in the terminal outside of this session
- Or configure environment variables in the shell profile
- Return to continue execution after configuration is completed
🔴 Important Rules:
- Strictly prohibited to guide users to enter AK/SK credentials in the session
- Strictly prohibited to use explicit credential parameters such as
aliyun configure set --access-key-id
- Credential check must be the first step of the task, report directly and terminate if the check fails
Multiple credential types are supported: AK, StsToken, RamRoleArn, EcsRamRole, etc. See
Credential Configuration Document for details.
6. RAM Policy
The list of RAM permissions involved in this Skill is detailed in
references/ram-policies.md
.
[MUST] Permission Failure Handling: When any command or API call fails due to a permission error during execution, follow this process:
- Read
references/ram-policies.md
to obtain the full list of permissions required for this SKILL
- Use the skill to guide the user to apply for the necessary permissions
- Pause and wait for the user to confirm that the required permissions have been granted
7. Parameter Confirmation
IMPORTANT: Parameter Confirmation — Before executing any command or API call, all user-customizable parameters (such as RegionId, instance name, CIDR block, password, domain name, resource specification, etc.) must be confirmed with the user. Do not assume or use default values without explicit user approval.
| Parameter Name | Required/Optional | Description | Default Value |
|---|
| Required | Alibaba Cloud region ID | None (requires user confirmation) |
| Required | ADB MySQL cluster ID ( or ) | None (requires user confirmation) |
| / | Optional | Time range parameters | Last 1 hour |
8. Best Practices
- CLI-First: Prioritize using CLI commands for diagnosis
- Time Verification: When involving time range queries, you must first obtain the current UTC time before calculation
- Command Output: Each API call must output the complete command string at the beginning of the reply
- Error Handling: When the cluster ID does not exist, guide the user to select the correct cluster instead of failing directly
- Product Boundary: Only process ADB MySQL clusters (ID prefix or ), do not mix with other product APIs
9. Reference Links
| Reference File | Content |
|---|
references/ram-policies.md
| RAM permission list |
references/verification-method.md
| Verification method |
references/cli-installation-guide.md
| Aliyun CLI installation guide |
references/cluster-info.md
| Detailed steps for cluster information query |
references/slow-query-diagnosis.md
| Detailed steps for slow query diagnosis |
references/table-modeling-diagnosis.md
| Instance space diagnosis process |