devops-skills/aws-api-billing-service-onboarding/SKILL.md
This skill should be used when the user requests to add a new third-party API service to the AWS billing/quota monitoring system. It handles the complete onboarding process including adapter creation, Lambda deployment, CloudWatch alarms, Dashboard updates, and verification. Triggers on requests mentioning "add service monitoring", "monitor API balance", "setup quota alerts", "add to billing dashboard", or similar service integration requests.
npx skillsauth add oldwinter/skills api-billing-service-onboardingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Automates the complete process of adding a new third-party API service to the AWS Lambda-based billing and quota monitoring system.
This skill provides a step-by-step workflow for integrating new API services into an existing AWS monitoring infrastructure that tracks account balances, quotas, and usage across multiple third-party services. The system monitors services every 30 minutes, pushes metrics to CloudWatch, triggers alerts via SNS to Feishu, and visualizes data on a centralized dashboard.
Use this skill when the user requests to:
Common trigger phrases:
The monitoring system is located in /path/to/monitoring-system/ and consists of:
just (see justfile)Key Files:
adapters/*.ts - API service adaptersadapters/index.ts - Adapter registrysrc/handler.ts - Lambda entry pointsrc/types.ts - BillingMetric interfacesrc/metrics.ts - CloudWatch metric publishingCLAUDE.md - Project documentationBefore starting implementation, collect the following information from the user:
Questions to ask:
Create a new TypeScript adapter file at adapters/<service_name>.ts.
Refer to: references/adapter-templates.md for three common adapter patterns:
The adapter must:
BillingMetric object with:
service: lowercase service identifierapiKeyMask: masked API keytotal: total quota/balanceremaining: remaining quota/balanceremainingRatio: remaining/total (0-1)currency (optional): "USD", "CNY", etc.unit (optional): "credits", "emails", "requests"Use the Read tool to examine existing adapters for reference:
adapters/resend.ts - Response header quota patternadapters/serper.ts - Prepaid credits patternadapters/scrapedo.ts - Standard JSON response patternEdit adapters/index.ts:
adapters objectExample:
import { fetchServiceName } from "./service_name";
export const adapters = {
// ... existing adapters
service_name: fetchServiceName,
};
Edit src/handler.ts to add the service call logic.
Location: Insert before console.log("✅ Billing check completed")
Pattern:
// <Service Display Name>
if (apiKeys.<service_name>) {
try {
console.log("🔍 Fetching <Service> quota...");
const metric = await adapters.<service_name>(apiKeys.<service_name>);
await pushMetrics(metric);
results.push({
service: "<service_name>",
status: "success",
remaining: metric.remaining,
total: metric.total,
ratio: metric.remainingRatio
});
} catch (error: any) {
console.error("❌ <Service> error:", error.message);
results.push({ service: "<service_name>", status: "error", error: error.message });
}
}
Use the helper script to safely add the API key:
scripts/add-secret-key.sh <service_name> <api_key>
Manual alternative:
# Get current secrets
aws secretsmanager get-secret-value \
--secret-id api-billing-monitor/keys \
--query SecretString --output text > /tmp/secrets.json
# Edit /tmp/secrets.json to add: "<service_name>": "<api_key>"
# Update secrets
aws secretsmanager update-secret \
--secret-id api-billing-monitor/keys \
--secret-string file:///tmp/secrets.json
# Quick deployment (recommended)
just deploy-quick
# Or full deployment with verbose output
just deploy
Verify deployment:
# Trigger Lambda manually
just invoke
# Check logs for the new service
just logs | grep <service_name>
Choose the appropriate alarm strategy:
Strategy A: Absolute Value Threshold (for fixed quotas):
aws cloudwatch put-metric-alarm \
--alarm-name "<Service>-Low-Balance" \
--namespace "ThirdPartyAPIBilling" \
--metric-name "Remaining" \
--dimensions Name=Service,Value=<service_name> \
--statistic Average \
--period 1800 \
--evaluation-periods 1 \
--threshold <absolute_value> \
--comparison-operator LessThanThreshold \
--alarm-actions "arn:aws:sns:us-east-1:830101142436:CloudWatchAlarmsToFeishu" \
--alarm-description "<Service> remaining balance below <threshold>"
Strategy B: Percentage Threshold (for variable quotas):
aws cloudwatch put-metric-alarm \
--alarm-name "<Service>-Low-Ratio" \
--namespace "ThirdPartyAPIBilling" \
--metric-name "RemainingRatio" \
--dimensions Name=Service,Value=<service_name> \
--statistic Average \
--period 1800 \
--evaluation-periods 1 \
--threshold 0.05 \
--comparison-operator LessThanThreshold \
--alarm-actions "arn:aws:sns:us-east-1:830101142436:CloudWatchAlarmsToFeishu" \
--alarm-description "<Service> remaining ratio below 5%"
Verify alarm creation:
just alarms | grep <Service>
Use the helper script to automatically add the service to the dashboard:
scripts/add-to-dashboard.sh <service_name> "<Service Display Name>" "<masked_api_key>"
Manual alternative:
Get current dashboard configuration:
aws cloudwatch get-dashboard \
--dashboard-name "API-Billing-Monitor" \
--query "DashboardBody" \
--output text > /tmp/dashboard.json
Edit /tmp/dashboard.json to add the service in 4 locations:
Update dashboard:
aws cloudwatch put-dashboard \
--dashboard-name "API-Billing-Monitor" \
--dashboard-body file:///tmp/dashboard.json
Refer to: references/dashboard-widget-template.json for widget JSON structure examples.
Edit CLAUDE.md to add the new service to the "已接入服务" table:
| <service_name> | <unit> | <threshold> | <description> |
Run the complete verification checklist:
# 1. Trigger monitoring
just invoke
# 2. Check logs for successful execution
just logs | grep "<service_name>"
# Expected: "✅ Metrics pushed for <service_name>"
# 3. Verify metrics in CloudWatch
aws cloudwatch list-metrics \
--namespace ThirdPartyAPIBilling \
--dimensions Name=Service,Value=<service_name>
# 4. Check alarm status
just alarms | grep "<Service>"
# 5. View current status
just status
# 6. Visit dashboard
echo "https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#dashboards/dashboard/API-Billing-Monitor"
Success criteria:
just status outputLambda execution fails:
just logsjust secrets-fullMetrics not appearing in CloudWatch:
just invokeDashboard shows no data:
aws cloudwatch list-metrics --namespace ThirdPartyAPIBillingAlarm not triggering:
aws cloudwatch describe-alarms --alarm-names "<Service>-Low-Balance"just test-alarm <Service>-Low-BalanceThirdPartyAPIBillingService=<service_name>, APIKey=<masked_key>For detailed examples and edge cases, refer to references/service-integration-examples.md.
devops
Deploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.
tools
This skill should be used when users need to manage AWS Support cases via CLI. It handles listing cases (recent 2 weeks, unresolved), viewing case details with bilingual display (English-Chinese line by line), creating new cases with auto-detected service/category, replying to cases, and attachment handling. Triggers on requests mentioning "AWS support", "support case", "工单", "support ticket", or AWS technical support inquiries.
testing
This skill should be used when users need to query AWS cost and usage details for a specific date. It supports querying costs at service level (e.g., EC2, S3, RDS) and drilling down to usage type level (e.g., instance types, storage classes, data transfer). Triggers on requests mentioning AWS costs, billing, spending, cost breakdown, or fee analysis.
tools
This skill should be used when users need to interact with AWS services via CLI. It covers all AWS services including EC2, ECS, EKS, Lambda, S3, RDS, DynamoDB, VPC, Route53, CloudFront, Bedrock, Support, Billing, and more. Supports querying, creating, modifying, deleting resources, monitoring, debugging, and cost analysis. Triggers on requests mentioning AWS, cloud resources, or specific AWS service names.