Install
openclaw skills install @sdk-team/alibabacloud-db-cost-diagnosisRead-only cost diagnostics and audits for Alibaba Cloud database products (RDS, Redis, MongoDB, PolarDB, DTS, DBS, CDT): explain a high or spiking DB bill with billing-item breakdowns and month-over-month anomaly attribution, and run proactive audits of renewal/expiry risk, idle instances, and optional paid features — never modifying any resource. Triggers: "why is my database bill so high", "DB cost spike", "database cost anomaly", "database bill surged", "unexpected database charges", "unexplained database charge", "don't know what feature is charging me", "RDS bill breakdown", "billing item breakdown", "charged after instance deleted", "released instance still billed", "monthly DB cost trend", "cost increase root cause", "CDT bill", "cost audit", "database cost audit", "idle database instance", "idle instance still charging", "renewal lock", "about to expire", "unexpected auto-renewal charge", "DMS charges", "DAS billing".
openclaw skills install @sdk-team/alibabacloud-db-cost-diagnosisDiagnose Alibaba Cloud database costs: "why is my database bill so high", "which billing item dominates this RDS instance's charge", "my DB cost jumped this month — what caused it", "I deleted the instance, why am I still being billed", "which instances are about to expire", "am I paying for idle databases", "what paid feature is charging me".
Core approach: confirm identity and billing scope, then either (1) drill into a single instance's bill detail with billing-item split to locate the dominant cost driver, (2) aggregate the account-level DB cost trend over recent months, detect anomalies, and attribute them to specific products and instances, or (3) run a proactive read-only audit — renewal/expiry risk and order anomalies, idle/low-load detection, or paid-feature attribution for unexplained charges. Conclude with evidence-based findings only; this skill never changes anything.
Modify*, Delete*, Create*, Restart*, Release*, Upgrade*, Downgrade*, or any configuration/spec change on database resources. This includes commands "for the user to run manually". If the user asks to downgrade, release, or resize an instance to cut cost, only output the manual guidance and declare this skill is read-only.DescribeInstanceBill, DescribeSplitItemBill, QueryOrders, and QueryAvailableInstances (bssopenapi, endpoint business.aliyuncs.com, API version 2017-12-14), the read-only CloudMonitor query DescribeMetricList (cms), plus sts:GetCallerIdentity for identity traceability. Any other action is forbidden.[WARN] <Code>: <Message> to stderr and continue with the remaining queries — never silently skip or abort the whole diagnosis. The final report is still produced with the data at hand.All diagnostics MUST be performed by running the scripts under scripts/. The Agent is forbidden from assembling its own aliyun CLI commands or bypassing the scripts to call billing APIs directly — the scripts embed pagination, retry, error degradation, and observability guarantees that ad-hoc commands lack. Read the script output, interpret it, and compose the report; do not re-implement the queries.
All OpenAPI calls (invoked through the aliyun CLI by the scripts) include:
AlibabaCloud-Agent-Skills/{skill-name}/{session-id}, where {skill-name} is alibabacloud-db-cost-diagnosisuuid.uuid4().hex) generated once per script run and attached to every CLI command of that run, so all calls of one diagnosis can be correlated.The shared CLI layer implements this automatically: the session-id is generated lazily on the first call of each run, cached for the rest of the run, and concatenated into the --user-agent argument of every aliyun invocation.
aliyun CLI (built-in API metadata mode for bssopenapi; the identity check uses plugin mode for sts get-caller-identity and, when the STS plugin is not installed in the environment, automatically falls back to the built-in API metadata mode for the same identity action). No direct HTTP signing, no external Python SDK.~/.aliyun/config.json). Do not read, print, or pass AK/SK/STS tokens explicitly.Credentials are resolved automatically by the aliyun CLI default credential chain (environment or ~/.aliyun/config.json). Do not read, print, or pass AK/SK/STS tokens explicitly.
cd $SKILL_DIR
# Verify caller identity (informational only; credentials always come from the CLI default chain)
python3 scripts/sts_token.py
Identity Verification Failure: If sts get-caller-identity fails, the default credential chain is not configured. Guide the user to run aliyun configure — never ask for AK/SK.
--billing-cycle YYYY-MM): the month to analyze. Default: current month. Auto-fill the current month when omitted and declare it.--instance-id): required for single-instance diagnosis; optional for account-level trend analysis, where instances are auto-discovered from the bill itself.--product): optional; one of rds|dds|kvstore|polardb|dts|cbs|cdt. When an instance ID is given, the DB product is auto-inferred from its prefix (rm- RDS, r- Redis, dds- MongoDB, pc- PolarDB, etc.), so no extra question is needed; CDT is an account-level transfer product, so pass --product cdt explicitly when its charges are in question.aliyun sts get-caller-identity and used only as a traceability label. Auto-fill first, ask second: never ask the user for UID when it can be derived.Auto-fill declaration requirement: Whenever any parameter is auto-filled (billing cycle, product, or UID), the Agent MUST explicitly declare this in the response or report metadata, e.g. "Billing cycle auto-defaulted to the current month (2026-08)" or "Product auto-inferred from instance prefix: ApsaraDB RDS".
Reference modules, strictly 1:1 with the references/ directory:
| Module | File | Responsibility |
|---|---|---|
| M1: Cost query orchestration | references/module1_cost_query.md | How to compose bill/trend queries: granularity choice, pagination, split-item semantics, anomaly drill-down sequencing |
| M2: DB cost FAQ | references/module2_cost_faq.md | High-frequency database billing questions: billing items, charging modes, deleted-instance charges, common cost drivers |
| M3: Cost-audit orchestration | references/module3_cost_audit.md | Renewal/order audit, idle detection and paid-feature audit: when to use which script, parameter and output interpretation, verdict/threshold semantics, EOS table |
| M4: RAM policies | references/ram-policies.md | Minimal read-only RAM policy required by this skill |
EXECUTION RULE (MANDATORY FIRST STEP): You MUST run python3 scripts/sts_token.py before any billing query, on every diagnosis, even when the user already supplied a UID in the request. A UID given by the user is only a label to cross-check against; the identity pre-check is what proves which account the returned bills belong to, so skipping it invalidates the whole diagnosis. Never treat a user-provided UID as a substitute for this call, and never drop this step to save queries — it does not count against any query budget.
Then determine which capability the user needs: A single-instance bill detail, B account-level trend & anomaly attribution, C renewal & order audit, D idle/low-load instance detection, or E paid-feature & unexplained-charge audit (see references/module3_cost_audit.md for the audit selection guide). If genuinely ambiguous, ask one brief clarifying question.
cd $SKILL_DIR && python3 scripts/query_instance_bill.py \
--instance-id <ID> --billing-cycle <YYYY-MM> [--split-item] \
[--granularity MONTHLY|DAILY] [--billing-date <YYYY-MM-DD>] [--json]
The script calls the bssopenapi DescribeInstanceBill action (or DescribeSplitItemBill with --split-item) through the aliyun CLI built-in API metadata mode, with full NextToken pagination, then aggregates by billing item:
--split-item when the user needs per-split-item (e.g. per-shard / per-storage-segment) granularity.--granularity DAILY MUST be paired with --billing-date YYYY-MM-DD (BSS mandates BillingDate for daily bills, and it must fall inside the billing cycle); the script exits with code 2 when it is missing.backup_storage), then cite the matching FAQ entry in references/module2_cost_faq.md — state which items carry the residual charge, using the actual returned data only.Dual-audience output: every script ends its human-readable report with a plain-language Summary section (what was queried / key findings in plain words / suggested next steps) aimed at non-technical users; with --json the same conclusion is exposed as machine-consumable summary / key_findings / suggestions fields alongside the detail fields, for the next diagnosis stage. Empty or failed queries still populate these fields (with reasons and actionable next steps), so downstream consumers can rely on them unconditionally.
Internally: endpoint business.aliyuncs.com, API version 2017-12-14.
cd $SKILL_DIR && python3 scripts/query_cost_trend.py [--months 6] [--product rds|dds|kvstore|polardb|dts|cbs|cdt] [--granularity MONTHLY|DAILY] [--billing-date <YYYY-MM-DD>] [--json]
The script aggregates DescribeInstanceBill per ProductCode over the last N billing cycles (default 6) and computes:
--granularity DAILY --billing-date <YYYY-MM-DD> to drill into a single day of that month — DAILY is a one-day drill-down (single query loop) and always requires --billing-date; it never iterates day by day.The same dual-audience contract as Step 2 applies: the readable report ends with a plain-language Summary section, and --json carries summary / key_findings / suggestions (populated even for empty or failed queries) for downstream stages.
cd $SKILL_DIR && python3 scripts/audit_renewal_orders.py [--months <N>] [--json]
MANDATORY single-command entry for any renewal/expiry/order/EOS question. The script queries QueryAvailableInstances (the server-side ProductCode filter is unreliable, so RDS rows are re-filtered client-side) and grades each instance's EndTime into the 90/30/7-day expiry windows with a high/medium/low risk label derived from RenewStatus; it then pulls the order history via QueryOrders with a MANDATORY explicit time window (default 6 months; without an explicit window the API silently narrows to ~1 hour) to detect auto-renewal charge sequences, adjacent renewal price jumps (> 3x), and refund/cancelled anomalies; finally it matches best-effort engine versions against the embedded EOS table. When no engine version can be extracted, report the EOS table and ask the user to confirm the versions in the console — never fabricate a version. Same dual-audience output contract as Step 2.
cd $SKILL_DIR && python3 scripts/audit_idle_instances.py [--billing-cycle <YYYY-MM>] [--json]
MANDATORY single-command entry for idle / "paying for a database nobody uses" questions. The script first discovers billed RDS instances from DescribeInstanceBill (an empty result is a valid "no billed RDS instance" outcome, exit 0), then samples CloudMonitor DescribeMetricList (namespace acs_rds_dashboard: CpuUsage / ConnectionUsage / IOPSUsage / DiskUsage; 7-day window, 3600 s period, at most 50 instances per batch) and renders an idle / low_load / active verdict per instance. Instances without complete metric data (no datapoints at all, or only one of the CPU/connection dimensions sampled) stay inconclusive and are NEVER judged idle; a total CloudMonitor failure degrades to the billing-side listing without aborting. Same dual-audience output contract as Step 2.
cd $SKILL_DIR && python3 scripts/audit_paid_features.py [--billing-cycle <YYYY-MM>] [--product rds|dds|kvstore|polardb|dts|cbs|cdt] [--json]
MANDATORY single-command entry for "what am I paying for" / unexplained-charge questions. The script queries DescribeInstanceBill(ProductCode) for the cycle, drills DescribeSplitItemBill into the top 10 costliest instances (guardrail; the rest stay at instance level), and attributes every billing item via the paid-feature map (SQL Audit / Performance Insight / cross-region backup / proxy / read-only / auto scaling / DAS Pro). Items matching neither a paid feature nor a known base charge are listed as unidentified charge candidates. Same dual-audience output contract as Step 2.
Summarize: which billing item / instance / month explains the cost, or which audit verdicts / expiry risks / paid features were found, with the actual numbers from the script outputs. Base the conclusion on the script's own Summary section (readable mode) or summary / key_findings / suggestions JSON fields rather than re-deriving it.
Final Answer Contract: every number, verdict, and date in the final answer MUST be quoted verbatim from the script's Summary section or its JSON output (summary / key_findings / suggestions) — never recompute, round differently, or estimate. Suggestions must be evidence-based and stated as manual guidance only (this skill never applies any change).
Fallback: when the billing APIs cannot answer the question (no data, permission gap, or a pricing-policy question), search the official Alibaba Cloud help documentation for the relevant billing rules; if the question still cannot be resolved, suggest the user submit a support ticket with the diagnosis details attached.
DAILY granularity is heavier and is reserved for drilling down into a month that the MONTHLY trend already flagged as anomalous. Default to MONTHLY. --granularity DAILY MUST be paired with --billing-date YYYY-MM-DD (BSS mandates BillingDate for daily bills); the trend script treats DAILY as a single-day drill-down, never a per-day loop.CreateTimeStart/CreateTimeEnd window — without one, QueryOrders silently narrows to roughly 1 hour and returns nothing (known pitfall).inconclusive, never "idle"; a total CMS failure degrades to the billing-side listing and does not abort the audit.sts:GetCallerIdentity; never modifies, releases, renews, or resizes anything.Example 1 — single-instance bill breakdown
User: "Why did my RDS instance rm-bp1xxxx cost 800 CNY last month?"
python3 scripts/query_instance_bill.py --instance-id rm-bp1xxxx --billing-cycle 2026-07 --split-item
Report the per-billing-item table (e.g. instance spec vs. storage vs. backup), the cost-share ranking, and the script's closing Summary section (plain-language findings + next steps), and declare: "Billing cycle auto-filled to 2026-07 based on 'last month'." When the report feeds a follow-up stage instead of a human, use --json and consume its summary / key_findings / suggestions fields.
Example 2 — account-level trend & anomaly attribution
User: "My database bill suddenly jumped, help me find the cause."
python3 scripts/query_cost_trend.py --months 6
Report the 6-month trend table, list flagged month-over-month jumps (with the > 20% / > 100 CNY rule), cite the top instances driving each jump, and relay the script's closing Summary section. If a month needs finer detail, drill down with --granularity DAILY --billing-date <YYYY-MM-DD> for one specific day of that month.
Example 3 — released instance still billed
User: "I deleted instance r-bp1yyyy weeks ago, why am I still paying for it?"
python3 scripts/query_instance_bill.py --instance-id r-bp1yyyy --billing-cycle 2026-08 --split-item
Query the deletion month and the current month; identify which billing items still carry charges (e.g. usage accrued before release, or components not released with the instance), and explain strictly from the returned items — noting the ~48h split-item delay if the window is recent.
| Script | Purpose |
|---|---|
scripts/sts_token.py | Verify caller identity via aliyun sts get-caller-identity; derive the UID traceability label (--json optional) |
scripts/query_instance_bill.py | Single-instance bill detail: billing-item aggregation, cost-share ranking, split-item drill-down |
scripts/query_cost_trend.py | Account-level DB cost trend per product over N months, anomaly detection, top-instance attribution |
scripts/audit_renewal_orders.py | Renewal & order audit: expiry windows (90/30/7d), renewal price spikes, refund anomalies, EOS check |
scripts/audit_idle_instances.py | Idle & low-load audit: billed RDS instances cross-checked against 7-day CloudMonitor load |
scripts/audit_paid_features.py | Paid-feature audit: attributes split-item charges to optional add-ons; lists unidentified charges |
CLI options for query_instance_bill.py: --instance-id <ID> (required), --billing-cycle <YYYY-MM> (required), --split-item (DescribeSplitItemBill), --granularity MONTHLY|DAILY (default MONTHLY), --billing-date <YYYY-MM-DD> (required when --granularity DAILY, must fall inside the billing cycle), --json, --profile.
CLI options for query_cost_trend.py: --months <N> (default 6, minimum 2), --product <rds|dds|kvstore|polardb|dts|cbs|cdt> (optional filter), --granularity MONTHLY|DAILY (default MONTHLY; DAILY is a single-day drill-down), --billing-date <YYYY-MM-DD> (required when --granularity DAILY), --json, --profile.
CLI options for audit_renewal_orders.py: --months <N> (default 6, range 1-24), --json, --profile.
CLI options for audit_idle_instances.py: --billing-cycle <YYYY-MM> (default: current month), --json, --profile.
CLI options for audit_paid_features.py: --billing-cycle <YYYY-MM> (default: current month), --product <rds|dds|kvstore|polardb|dts|cbs|cdt> (default rds), --json, --profile.
| Error | Cause | Resolution |
|---|---|---|
| No credentials found | Default credential chain not configured | Run aliyun configure; never ask the user for AK/SK |
NoPermission / AccessDenied | RAM policy missing a BSS read permission | Record the missing action, continue with remaining queries, point to references/ram-policies.md |
InvalidParameter / invalid billing cycle | Wrong cycle format or out-of-range month | Log [WARN], verify YYYY-MM format, continue |
Throttling.User | Request rate limited | Retried automatically with backoff (up to 3 attempts); then log [WARN] and continue |
InternalError / ServiceUnavailable | Transient service-side failure | Retried automatically; log [WARN] and continue; do not conclude "no cost" from a single failed call |
| Empty bill data | No charge in the cycle, wrong instance ID, or 48h split-item delay | Report "no data" honestly; verify instance ID and cycle, mention the data latency when the window is recent |
All errors follow the Code: Message format raised as CliError inside the shared CLI layer; transient errors are retried, persistent ones are degraded with [WARN] on stderr, and the report is always emitted with whatever data succeeded.