Skip to content
SlashClone

Consumption guardrails

@agentcosts/consumption-guardrails

Set and check consumption guardrails for an AI product: per-customer daily and monthly spend caps, month-end forecasts, spend spike rules, runaway agent runs, and failure rate spikes, plus a runbook for what to do when each alert fires. Runs on usage files; exit code 2 on critical alerts for cron or CI.

SkillDevOpsv1.0.0 (latest)Tested
Activity
New: be the first to try it
  1. 1{
  2. 2 "name": "consumption-guardrails",
  3. 3 "owner": "agentcosts",
  4. 4 "version": "1.0.0",
  5. 5 "type": "skill",
  6. 6 "description": "Set and check consumption guardrails for an AI product: per-customer daily and monthly spend caps, month-end forecasts, spend spike rules, runaway agent runs, and failure rate spikes, plus a runbook for what to do when each alert fires. Runs on usage files; exit code 2 on critical alerts for cron or CI.",
  7. 7 "category": "devops",
  8. 8 "license": "MIT",
  9. 9 "compat": ["claude-code"],
  10. 10 "permissions": {
  11. 11 "shell": ["node scripts/guardrails.mjs"],
  12. 12 "files": { "read": ["./data/**"], "write": ["./data/guardrails.json", "./out/guardrails*"] }
  13. 13 },
  14. 14 "tests": {
  15. 15 "cases": [
  16. 16 {
  17. 17 "name": "catches the example spike, cap breach, and runaway runs",
  18. 18 "inputs": {},
  19. 19 "checks": [
  20. 20 { "type": "command_exits_zero", "command": "node scripts/guardrails.mjs examples/usage.csv --config examples/guardrails.json --prices examples/prices.csv --as-of 2026-10-27 --out out/guardrails" },
  21. 21 { "type": "file_contains", "path": "out/guardrails.md", "text": "| CRITICAL | cobalt-labs | runaway runs |" },
  22. 22 {
  23. 23 "type": "output_matches_schema",
  24. 24 "path": "out/guardrails.json",
  25. 25 "schema": {
  26. 26 "type": "object",
  27. 27 "required": ["as_of", "counts", "alerts", "customers"],
  28. 28 "properties": {
  29. 29 "as_of": { "const": "2026-10-27" },
  30. 30 "counts": { "const": { "critical": 3, "warning": 2, "info": 0 } },
  31. 31 "alerts": {
  32. 32 "type": "array",
  33. 33 "minItems": 5,
  34. 34 "maxItems": 5,
  35. 35 "items": { "type": "object", "properties": { "customer": { "const": "cobalt-labs" } } }
  36. 36 },
  37. 37 "runaway_runs": { "type": "array", "minItems": 6, "maxItems": 6 }
  38. 38 }
  39. 39 }
  40. 40 }
  41. 41 ]
  42. 42 },
  43. 43 {
  44. 44 "name": "forecasts the month and warns before the cap",
  45. 45 "inputs": {
  46. 46 "data/usage.csv": "timestamp,customer,task,model,cost_usd\n2026-11-01T10:00:00Z,a,t,m,10\n2026-11-02T10:00:00Z,a,t,m,10\n2026-11-03T10:00:00Z,a,t,m,10\n",
  47. 47 "data/guardrails.json": "{\"defaults\":{\"monthly_cap_usd\":200,\"daily_cap_usd\":50}}"
  48. 48 },
  49. 49 "checks": [
  50. 50 { "type": "command_exits_zero", "command": "node scripts/guardrails.mjs data/usage.csv --config data/guardrails.json --fail-on-alert --out out/guardrails" },
  51. 51 {
  52. 52 "type": "output_matches_schema",
  53. 53 "path": "out/guardrails.json",
  54. 54 "schema": {
  55. 55 "type": "object",
  56. 56 "properties": {
  57. 57 "counts": { "const": { "critical": 0, "warning": 1, "info": 0 } },
  58. 58 "customers": { "type": "array", "items": { "type": "object", "properties": { "month_to_date": { "const": 30 }, "forecast_month": { "const": 300 } } } }
  59. 59 }
  60. 60 }
  61. 61 }
  62. 62 ]
  63. 63 }
  64. 64 ]
  65. 65 }