Composite CI gate — runs cost-budget-check + cost-burn + cost-anomaly + cost-projection in parallel and surfaces a single combined health status with max exit c
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-cost-health-679a29f4a95e ,按照其中的说明把「cost-health」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
The four CI-gate skills (budget / burn / anomaly / projection) each answer
a different question. This skill composes them — runs all four IN PARALLEL,
returns max(exit_codes), prints a one-line summary per check.
| Subcheck | Question | Default threshold |
|---|---|---|
budget | "Have we crossed the configured budget?" | HARD_STOP at 100% |
burn | "Is daily burn accelerating?" | +100% vs prior-week mean |
anomaly | "Is any specific session a >3.5σ outlier?" | ≥1 outlier |
projection | "When will we hit 100% of budget?" | <14 days |
Implementation: scripts/health.mjs.
Promise.all over child_process.spawn).--format json; parse and capture exit code.daysUntilReached[100%] < --alert-days-to-exhaust.max(subcheck exits). Any single failure fails the gate.- name: Cost health gate
run: cost health --alert-acceleration 100 --alert-outliers 1
A single step covers four alert ladders. Before this skill you'd wire four separate gates that each duplicated the npx + memory-list overhead; now it's one shell-out (and the four subcheck npx calls run in parallel internally).
# Quarterly review — stricter thresholds
cost health --alert-acceleration 50 --alert-outliers 1 --alert-days-to-exhaust 30
# Production drift gate — only fire on egregious changes
cost health --alert-acceleration 200 --alert-outliers 3 --alert-days-to-exhaust 7
# Skip the slow burn check during a smoke run
cost health --skip burn
# Healthy
Overall: ✓ HEALTHY (max exit code 0)
| Check | Status | Detail |
| budget | ✓ | unknown — no budget configured |
| burn | ✓ | delta within ±100% |
| anomaly | ✓ | 0 outliers — under threshold ≥1 |
| projection | ✓ | no budget configured — skipping |
# After adding $5 outlier (vs $0.10 baseline)
Overall: ⚠ UNHEALTHY (max exit code 1)
| burn | ⚠ | ALERT 5163.2% acceleration: latest bucket $5.00 is 5163.2% above prior mean $0.095 |
| anomaly | ⚠ | ALERT 1 outlier (|z|>3.5) |
cost health --skip burn,projection # only budget + anomaly
Useful when:
| Exit | Meaning |
|---|---|
| 0 | All subchecks OK |
| 1 | At least one subcheck fired an alert (budget HARD_STOP, burn drift, anomaly outlier, projection imminent-exhaust) |
| 2 | A subcheck had a config/usage error (e.g. invalid CLI args propagated to a subscript) |
| 127 | A subcheck failed to launch (script missing, etc.) |
max() means the worst signal wins — exit 2 (config error) always dominates
exit 1 (alert), so you spot misconfigured pipelines before they masquerade
as healthy.