Token导航 LogoToken导航TokenDH.com
前端设计敏感数据github未标认证来源可访问clear审计异常

api-billing-service-onboardingAPI billing service 入门

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

874

周安装

35

GitHub Stars

3

下载量

283
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:api-billing-service-onboarding(API billing service 入门)
来源仓库:https://github.com/oldwinter/skills
仓库路径:skills/api-billing-service-onboarding
安装命令:
npx skills add https://github.com/oldwinter/skills --skill api-billing-service-onboarding
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/oldwinter/skills --skill api-billing-service-onboarding

简介

用于自动化将第三方 API 服务集成到基于 AWS Lambda 的计费与配额监控系统。

  • 适合在需要添加新 API 服务到现有监控体系时启用,支持指标推送、告警触发和数据可视化。
  • 使用时需提供具体业务语义、鉴权方式和错误处理规则,避免凭空补字段,应基于现有代码或接口样例提取事实。
  • 安装方式:通过 npx skills add 命令从指定 GitHub 仓库添加,需确认宿主环境支持 Codex、Claude 等工具。
  • 注意:涉及敏感信息时应避免硬编码凭证,优先使用环境变量或安全存储机制管理密钥。

SKILL.md

API Billing Service Onboarding

Automates the complete process of adding a new third-party API service to the AWS Lambda-based billing and quota monitoring system.

Purpose

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.

When to Use

Use this skill when the user requests to:

  • Add monitoring for a new API service's balance, quota, or credits
  • Set up alerts for low balance/quota on a third-party service
  • Integrate a new service into the billing dashboard
  • Monitor remaining usage or spending on an external API

Common trigger phrases:

  • "Add [Service] to monitoring"
  • "Monitor [Service] API balance"
  • "Set up quota alerts for [Service]"
  • "Track [Service] credits in dashboard"

Project Context

The monitoring system is located in /path/to/monitoring-system/ and consists of:

  • Runtime: Node.js 18.x (TypeScript)
  • Cloud Platform: AWS Lambda + CloudWatch + Secrets Manager + EventBridge + SNS
  • Commands: Managed via just (see justfile)
  • Architecture: EventBridge (30min) → Lambda → CloudWatch Metrics → Alarms → SNS → Feishu

Key Files:

  • adapters/*.ts - API service adapters
  • adapters/index.ts - Adapter registry
  • src/handler.ts - Lambda entry point
  • src/types.ts - BillingMetric interface
  • src/metrics.ts - CloudWatch metric publishing
  • CLAUDE.md - Project documentation

Workflow

Step 1: Gather Service Information

Before starting implementation, collect the following information from the user:

  1. Service name (e.g., "resend", "sendgrid")
  2. API documentation URL (especially balance/quota endpoints)
  3. API Key/Token (will be stored in Secrets Manager)
  4. Alert threshold (absolute value or percentage)
  5. Service display name (for Dashboard labels)

Questions to ask:

  • "What is the API endpoint for checking balance/quota?"
  • "How does the API authenticate? (Bearer token, API key header, query param?)"
  • "What response format does the API return? (JSON structure)"
  • "What threshold should trigger an alert? (e.g., remaining < 100, or < 5%)"
  • "What unit does the service use? (USD, credits, emails, requests?)"

Step 2: Create API Adapter

Create a new TypeScript adapter file at adapters/<service_name>.ts.

Refer to: references/adapter-templates.md for three common adapter patterns:

  • Standard JSON response with balance fields
  • Response headers containing quota information
  • Prepaid credits with no total amount

The adapter must:

  1. Call the service's API to retrieve balance/quota
  2. Mask the API key (show first 6 and last 6 characters)
  3. Return a BillingMetric object with:

- service: lowercase service identifier - apiKeyMask: masked API key - total: total quota/balance - remaining: remaining quota/balance - remainingRatio: 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 pattern
  • adapters/serper.ts - Prepaid credits pattern
  • adapters/scrapedo.ts - Standard JSON response pattern

Step 3: Register Adapter

Edit adapters/index.ts:

  1. Import the new adapter function
  2. Add entry to the adapters object

Example:

import { fetchServiceName } from "./service_name";

export const adapters = {
  // ... existing adapters
  service_name: fetchServiceName,
};

Step 4: Update Lambda Handler

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 });
  }
}

Step 5: Add API Key to Secrets Manager

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

Step 6: Build and Deploy

# 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>

Step 7: Create CloudWatch Alarm

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>

Step 8: Update CloudWatch Dashboard

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:

  1. Get current dashboard configuration: aws cloudwatch get-dashboard \ --dashboard-name "API-Billing-Monitor" \ --query "DashboardBody" \ --output text > /tmp/dashboard.json
  2. Edit /tmp/dashboard.json to add the service in 4 locations:

- "所有服务剩余比例趋势" metrics array - "当前剩余比例" metrics array - Create a new widget (optional, for detailed service chart) - "当前剩余额度/Credits" metrics array

  1. 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.

Step 9: Update Project Documentation

Edit CLAUDE.md to add the new service to the "已接入服务" table:

| <service_name> | <unit> | <threshold> | <description> |

Step 10: Verification

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:

  • ✅ Lambda logs show successful metric push
  • ✅ CloudWatch metrics exist for the service
  • ✅ Alarm is in OK or ALARM state (not INSUFFICIENT_DATA)
  • ✅ Dashboard displays the service in all charts
  • ✅ Service appears in just status output

Troubleshooting

Lambda execution fails:

  • Check logs: just logs
  • Verify API key in Secrets Manager: just secrets-full
  • Test API endpoint manually with curl/Postman

Metrics not appearing in CloudWatch:

  • Confirm Lambda executed successfully: just invoke
  • Check for errors in adapter code
  • Verify metric push logic in logs

Dashboard shows no data:

  • Wait 30 minutes for first execution cycle
  • Confirm metrics exist: aws cloudwatch list-metrics --namespace ThirdPartyAPIBilling
  • Verify Dashboard JSON syntax

Alarm not triggering:

  • Check alarm configuration: aws cloudwatch describe-alarms --alarm-names "<Service>-Low-Balance"
  • Verify metric data points exist
  • Test alarm: just test-alarm <Service>-Low-Balance

Notes

  • The system runs on a 30-minute schedule via EventBridge
  • All API keys are stored securely in AWS Secrets Manager
  • Alarms notify via SNS to Feishu webhook
  • The CloudWatch namespace is ThirdPartyAPIBilling
  • Common dimension: Service=<service_name>, APIKey=<masked_key>

For detailed examples and edge cases, refer to references/service-integration-examples.md.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.7%
按下载量换算78

windsurf

25.75%
按下载量换算73

Antigravity

18.15%
按下载量换算51

trae

13.02%
按下载量换算37

OpenCode

7.93%
按下载量换算22

Gemini CLI

3.83%
按下载量换算11

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

未通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills