API写作
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- 工程开发
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 较高消耗
- 接入复杂程度
- 需手动接入
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 兼容的系统
- macOS · Linux · Windows
- 底层运行要求
- Node.js · Python
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: bunny-graphql
description: Direct GraphQL API integration with Bunny — the subscription billing and management platform. Co…
category: 工程开发
runtime: Node.js / Python
---
# bunny-graphql 输出预览
## PART A: 任务判断
- 适用问题:代码实现、重构、调试或代码审查。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Credential safety / Endpoint / Authentication”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于代码实现、重构、调试或代码审查,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Credential safety / Endpoint / Authentication”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、读取环境变量、会按任务需要访问外部网络、需要准备 Vendor-specific API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、读取环境变量。
先用一个小任务确认它会围绕“Credential safety / Endpoint / Authentication”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: bunny-graphql
description: Direct GraphQL API integration with Bunny — the subscription billing and management platform. Co…
category: 工程开发
source: tomevault-io/skills-registry
---
# bunny-graphql
## 什么时候使用
- 把工程方向的常用动作沉淀成 Agent 可调用的技能 适合处理工程开发场景下的代码实现、调试、重构、测试或代码审查,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代…
- 面向代码实现、重构、调试或代码审查,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Credential safety / Endpoint / Authentication」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "bunny-graphql" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Credential safety / Endpoint / Authentication
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Node.js / Python | 读取文件、写入/修改文件、读取环境变量 | 会按任务需要访问外部网络
安全层 -> 需要准备 Vendor-specific API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Bunny GraphQL
Bunny exposes its full API as a single GraphQL endpoint per tenant. This skill covers calling it directly over HTTPS — auth, pagination, errors, and the operations integrators reach for most.
For official docs, see docs.bunny.com/developer/using-the-graphql-api.
Credential safety
Access tokens grant write access to live billing data. Treat them like database passwords:
- Read tokens from environment variables only (
process.env.BUNNY_ACCESS_TOKEN,ENV['BUNNY_ACCESS_TOKEN'],os.getenv("BUNNY_ACCESS_TOKEN")). Never inline. - Never log request bodies or auth headers — token values will leak into log aggregators otherwise.
- Never ship tokens to client-side JavaScript bundles — they belong on your server.
- Don't commit
.envfiles. Use your platform's secret manager in production (Doppler, Vault, AWS Secrets Manager, Rails credentials, etc.). - Rotate tokens regularly and scope each token to the minimum set of permissions it needs.
Endpoint
https://<subdomain>.bunny.com/graphql
Replace <subdomain> with your Bunny tenant's subdomain (the part before
.bunny.com in your admin URL).
All requests:
- Use
POST - Set
Content-Type: application/json - Set
Authorization: Bearer <ACCESS_TOKEN>
Authentication
Bunny supports two auth modes. Pick based on how long your process runs.
Access token (simplest)
Generate a long-lived access token in the admin portal: Settings → API Clients → Default API client → Generate Access Token.
Use it directly in the Authorization header. No token exchange needed.
curl -sS "https://example.bunny.com/graphql" \
-H "Authorization: Bearer $BUNNY_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query":"{ currentUser { scopes user { id name email } } }"}'
Downside: if the token expires or is rotated, your requests fail until you update the env var.
OAuth2 client credentials (recommended for long-running services)
Create an API Client in the admin portal and get a client_id, client_secret,
and scope. Exchange them for a short-lived access token; refresh
automatically when it expires.
const {
BUNNY_BASE_URL, // e.g. https://example.bunny.com
BUNNY_CLIENT_ID,
BUNNY_CLIENT_SECRET,
BUNNY_SCOPE = "standard:read standard:write",
} = process.env;
let cached: { token: string; expiresAt: number } | null = null;
async function accessToken(): Promise<string> {
if (cached && Date.now() < cached.expiresAt - 60_000) return cached.token;
const res = await fetch(`${BUNNY_BASE_URL}/oauth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: BUNNY_CLIENT_ID!,
client_secret: BUNNY_CLIENT_SECRET!,
scope: BUNNY_SCOPE,
}),
});
if (!res.ok) throw new Error(`Token exchange failed: ${res.status}`);
const body = await res.json();
cached = {
token: body.access_token,
expiresAt: Date.now() + body.expires_in * 1000,
};
return cached.token;
}
export async function graphql<T>(query: string, variables?: object): Promise<T> {
const res = await fetch(`${BUNNY_BASE_URL}/graphql`, {
method: "POST",
headers: {
Authorization: `Bearer ${await accessToken()}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ query, variables: variables ?? {} }),
});
return res.json();
}
Note on units: body.expires_in is seconds (the TypeScript sample
multiplies by 1000 to reach JS epoch milliseconds). Language implementations
that already work in seconds (Python time.time(), Go time.Duration) skip
the multiplication.
If the token endpoint returns {"error":"unauthorized_client","error_description":"The client is not authorized to perform this request using this method."} with otherwise valid credentials, the issue is server-side: the API client's grant_flows array doesn't include client_credentials. Enable it under Settings → API Clients → <your client> in the Bunny admin. The error name is misleading — it sounds like wrong credentials, but it's a client-config mismatch.
The official Node (@bunnyapp/api-client) and Ruby (bunny_app) SDKs handle
this refresh loop for you — prefer them when available. See also
bunny-node-sdk and bunny-ruby-sdk.
Pagination
List queries return Relay-style connections with edges { node } and
pageInfo { endCursor hasNextPage }. Paginate forward by passing after.
query ListAccounts($cursor: String) {
accounts(first: 50, after: $cursor) {
edges {
node { id name state createdAt }
}
pageInfo { endCursor hasNextPage }
}
}
Loop until pageInfo.hasNextPage is false, passing the previous
endCursor as the next cursor. Keep page sizes ≤ 100 to stay well under
request timeouts.
Finding the right operation
Bunny's schema has hundreds of operations and the names don't always match
what you'd guess — e.g. quotes are applied via quoteApplyChanges, not
quoteApply; subscription renewals are driven through a renewal quote
(quoteSubscriptionRenew) rather than a direct mutation. Do not guess
operation names from the user's prompt.
To find the correct operation:
- Use the Bunny dev MCP —
search_docs("<intent>")surfaces the right operation with a link to its docs page;validate_graphql("<document>")confirms the shape before you ship it. - Reach for the sibling skill for the domain area —
bunny-subscriptionsfor lifecycle operations,bunny-quotingfor quote flows,bunny-billingfor invoices / payments / credit notes,bunny-catalogfor products and pricing,bunny-analyticsfor reporting reads. - Introspect the schema directly if you need the exact shape and no doc search is available.
Minimal end-to-end: create an account
Bunny's argument and payload shapes are not the generic input: XxxCreateInput! you may expect from other GraphQL APIs. Validate your
mutation against the live schema before shipping — either via the
Bunny dev MCP (validate_graphql("<document>")) or a one-off
introspection query. The example below is correct as of the Last verified footer; if it rejects with Field doesn't accept argument 'attributes' or similar, the schema has moved.
const QUERY = /* GraphQL */ `
mutation CreateAccount($attributes: AccountAttributes!) {
accountCreate(attributes: $attributes) {
account { id name }
errors
}
}
`;
const res = await fetch(`${process.env.BUNNY_BASE_URL}/graphql`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BUNNY_ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: QUERY,
variables: {
attributes: {
name: "Acme Corp",
billingContact: { email: "ap@acme.example" },
},
},
}),
});
const body = await res.json();
if (res.status >= 400) throw new Error(`HTTP ${res.status}: ${JSON.stringify(body)}`);
if (body.errors?.length) throw new Error(body.errors[0].message); // schema OR validation
const payload = body.data.accountCreate;
if (payload?.errors?.length) throw new Error(payload.errors.join("; ")); // auth
const account = payload.account;
Note the three-way error check — see "Error response shape" below for
why validation errors come through top-level errors, not the nested
payload.errors array.
Error response shape
Bunny responses mix five observable failure modes. Inspect them in this order:
HTTP status — transport / uncaught exception. 4xx (commonly 401 on a stale token, 403 on OAuth
unauthorized_client) or 5xx (network, auth service, or an uncaught Rails exception). A 500 body from the Rails backend is still JSON and includes anexceptiontrace — it can look deceptively like a successful GraphQL response until you check the status. Retry 5xx with backoff; fix 4xx.Top-level
errors[]— schema-level. Unknown field, missing required argument, wrong type. Array of GraphQL error objects withmessageandpath. Bug in your query; do not retry.Top-level
errors[]withpath = ["<mutationName>"]anddata.<op>: null— model validation. The most common mutation failure mode: blank required string, invalid email format, illegal state transition. Surface to the caller; do not retry.{ "errors": [ { "message": "Name can't be blank", "path": ["accountCreate"] } ], "data": { "accountCreate": null } }data.<op>.errors: [String!]withdata.<op>.<resource>: null— authorization. Populated only for scope / permission failures, e.g."Missing required permission: write, can't access mutation PortalSessionCreate". The message drops the domain prefix (sayswrite, notportal:write), so it can read as ambiguous. IntrospectcurrentUser { scopes }to confirm what your token actually carries.{ "data": { "portalSessionCreate": { "token": null, "errors": ["Missing required permission: write, can't access mutation PortalSessionCreate"] } } }data.<op>.errorsalongside a populateddata.<op>.<resource>— partial / warnings. Rare. Some mutations return soft-error arrays on otherwise-successful responses. Handle defensively.
Canonical check order in a consumer:
if resp.status_code >= 400: # 1: transport / exception
raise TransportError(resp)
if body.get("errors"): # 2 or 3: schema or validation
# path == [<mutationName>] + data.<op> is None => model validation
raise ApiError(body["errors"])
payload = body["data"]["<op>"]
if payload and payload.get("errors"): # 4 (or 5 if resource is also set)
raise AuthError(payload["errors"])
Do not parse message strings for control flow — they are human-readable
and may change between releases.
Scopes
Access tokens are scoped. Common scopes:
standard:read,standard:write— most day-to-day operationsadmin:read,admin:write— tenant administrationbilling:read,billing:write— invoices, payments, credit notesproduct:read,product:write— catalog managementsecurity:read,security:write— API clients, tokens, auditlegendary:read,legendary:write— advanced / internal operations
Request the narrowest set you need. Full scope list in the admin portal.
Confirming a token's scopes at runtime
Query currentUser { scopes } to see what scopes the current token
actually carries. Useful when a mutation rejects with a scope error and
the message is ambiguous about which scope is missing (see error tier 4
above — the message strips the domain prefix, saying "Missing required
permission: write" rather than "**portal:**write").
Comparing currentUser.scopes against the mutation's
REQUIRED_SCOPES (visible in the schema's SDL comments) is usually the
fastest path from error to fix.
References
- docs.bunny.com/developer/using-the-graphql-api — official docs
- bunnyapp/bunny-node — Node SDK (handles auth + refresh for you)
- bunnyapp/bunny-ruby — Ruby gem (handles auth + refresh for you)
Last verified against bunnyapp/api release 2026-04-21-1
Source: bunnyapp/skills — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核