微算力 · API 导航与自营网关
API 接入 EN
未登录登录
💰

跨平台广告预算智能风控

Ad Budget Governor · v1.0.0
入口已确认,内容待校验 文件树里有 SKILL.md,但正文还没采回,frontmatter 未核对。
专业技能 安全 A 级 作者 roberthill0475-lang 公开目录收录
309 下载 0 安装 805 收藏 1 浏览

简介

来自真实 Meta+TikTok 双平台生产环境验证的跨平台广告预算管控技能,通过滚动窗口聚合多平台支出,在数据异常时自动熔断阻断超支风险。

原始描述

Cross-platform rolling ad-spend cap that blocks overspend across multiple ad platforms combined, not just per-platform daily limits. Fails closed on unreadab...

通过你的 Agent 添加

安装目录:ad-budget-governor/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/ad-budget-governor/
Codex CLI~/.codex/skills/ad-budget-governor/
DeepSeek Harness~/.agents/skills/ad-budget-governor/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Ad Budget Governor 是一款面向多平台广告投放场景的预算风控技能,解决传统单平台日限额无法感知跨平台总支出的核心痛点。该技能通过读取各平台的支出流水账本(JSON 格式),在 30 天滚动窗口内聚合计算真实总消耗,并在每次支出操作前执行预检拦截。

开发者需将 ad_budget_governor.py 集成至项目,配置 LEDGER_PATHS 指向各平台支出日志文件,随后在每次调用广告平台 API 前执行 check_rolling_budget(amount_usd) 检查。若检查返回 ok=False,则必须阻断当前支出操作并将原因反馈给运营人员。预算上限默认设为 $0,强制要求人工配置真实限额后方可放行任何支出。

显著优点

  1. 真跨平台聚合:打破 Meta、TikTok、Google 等平台各自独立的日限额孤岛,从业务视角管控总预算而非单平台限额。
  2. Fail-Closed 安全设计:当任一平台账本损坏、解析失败或格式异常时,技能将该平台支出视为「未知」而非「零」,自动阻断新支出直至修复。这是对抗数据腐败导致隐性超支的关键防线。
  3. 生产级验证:已在真实营销 campaigns 中经 Meta + TikTok 双平台生产环境验证,非实验室原型。
  4. 零侵入架构:通过读取外部 JSON 账本实现解耦,无需改造现有平台 SDK 或代理代码。

潜在缺点与局限性

  1. 账本延迟风险:技能依赖外部账本文件的及时写入,若平台日志延迟或写入失败,预算计算将基于过期数据。
  2. 单机状态局限:当前版本未内置分布式锁或集中式存储,多实例部署时可能出现竞态条件导致限额击穿。
  3. 币种单一:仅支持 USD 计价,多币种场景需开发者自行换算预处理。
  4. 无自动回退机制:账本异常熔断后需人工介入恢复,未提供自动重试或降级策略。

适合的目标群体

  • 日均广告支出 $1,000+ 且跨平台投放的营销团队
  • 使用自主开发 Agent 或内部平台管理多广告账户的技术团队
  • 对预算硬上限有合规要求(如上市公司季度营销封顶)的企业
  • 现有云原生广告工具(如 Smartly.io)无法覆盖的自定义 Agent 场景

常规使用风险

  • Python 运行时依赖:需确保生产环境 Python 3 可用,虚拟环境隔离不当可能引发依赖冲突。
  • 文件 IO 瓶颈:高频支出场景下(每秒百次级),JSON 账本文件的磁盘读写可能成为性能瓶颈。
  • 时钟漂移敏感:滚动窗口计算依赖系统时间,容器化部署时需确保 NTP 同步,避免窗口边界计算偏差。
  • 权限配置风险:账本文件若权限开放不当,可能被恶意篡改导致预算欺诈放行。

技能正文


name: ad-budget-governor description: Cross-platform rolling ad-spend cap that blocks overspend across multiple ad platforms combined, not just per-platform daily limits. Fails closed on unreadable spend data. version: 1.0.0 metadata: openclaw: requires: bins: - python3

Ad Budget Governor

Most per-platform ad tools (Meta, TikTok, Google, etc.) only enforce their own daily spend cap. If your agent runs ad spend across more than one platform, none of them know about each other — total combined spend can exceed what you actually intended even when every individual platform "cap" is technically respected.

This skill adds one rolling-window cap that sums spend across all platforms you configure, and blocks any spend action that would push the combined total over your limit — regardless of which platform is asking.

Why fail-closed matters

If the spend ledger for a platform is corrupted, missing in an unexpected way, or fails to parse, this skill treats that platform's spend as unknown, not zero, and blocks new spend until it's resolved. A governor that silently assumes "unreadable = $0 spent" will let real overspend through at exactly the moment something is already wrong. This is the single most important property of this skill — don't change it.

Setup

  1. Copy ad_budget_governor.py into your project.
  2. Edit LEDGER_PATHS to point at your own platform spend-tracking files. Each ledger is a JSON file containing a list of records shaped like:
    {"timestamp": "2026-06-22T14:00:00Z", "amount_usd": 12.50}
    
    Extra fields are ignored. If your platform wrapper doesn't already log spend in this shape, add that logging before wiring this in.
  3. Call check_rolling_budget(amount_usd) before every spend action, on every platform:
    from ad_budget_governor import check_rolling_budget
    
    ok, reason = check_rolling_budget(amount_usd=25.00)
    if not ok:
        # do not spend — surface `reason` to the operator
        ...
    
  4. Set your cap (defaults to $0 — intentionally, so nothing spends before a real number is chosen):
    from ad_budget_governor import set_cap
    set_cap(300.0, note="initial cap")
    

API

Function Returns
check_rolling_budget(amount_usd) (ok: bool, reason: str | None)
rolling_spend_usd(window_days=30) (total: float, had_read_error: bool)
get_status() dict with cap, spent, remaining, at_cap, ledger_read_error
set_cap(new_cap_usd, note="") updated status dict

Tested against

Built and verified in production governing real Meta + TikTok ad spend for a live marketing campaign before being generalized for publication here.

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

marketingfinance-accountingautomationpaydata-analyticsbackend

同类 Skill