{"skill":{"slug":"cost-guardian","displayName":"Cost Guardian","summary":"Track, analyze, and optimize AI and infrastructure costs with budgeting, spend forecasts, token usage scans, and optimization suggestions.","description":"# cost-guardian — AI & Infrastructure Cost Tracker\n\nTrack, analyze, and optimize the total cost of running your AI agent and infrastructure. Budget alerts, spend forecasts, and concrete optimization recommendations.\n\n## Commands\n\n### Initialize\n```bash\npython scripts/cost-guardian.py init\n```\nCreates config and database in `~/.openclaw/workspace/costs/`.\n\n### Track a Cost Entry\n```bash\n# Track API spend\npython scripts/cost-guardian.py track --provider openai --amount 12.50 --currency USD --period monthly --category api\n\n# Track infrastructure cost\npython scripts/cost-guardian.py track --provider hetzner --amount 5.00 --currency EUR --period monthly --category hosting\n\n# Track one-time cost\npython scripts/cost-guardian.py track --provider cloudflare --amount 10.00 --currency USD --period once --category domain\n\n# Track electricity\npython scripts/cost-guardian.py track --provider electricity --amount 15.00 --currency EUR --period monthly --category power\n```\n\n### Scan Token Usage from Gateway Logs\n```bash\n# Scan recent gateway logs for token consumption per model\npython scripts/cost-guardian.py scan-tokens\n\n# Scan specific days\npython scripts/cost-guardian.py scan-tokens --days 7\n```\n\n### Set Budget\n```bash\n# Monthly budget\npython scripts/cost-guardian.py budget --monthly 50.00 --currency EUR\n\n# Budget with alert threshold (alert at 80%)\npython scripts/cost-guardian.py budget --monthly 50.00 --alert-pct 80\n```\n\n### Cost Report\n```bash\n# Current month report\npython scripts/cost-guardian.py report\n\n# Weekly report\npython scripts/cost-guardian.py report --period week\n\n# JSON output\npython scripts/cost-guardian.py report --json\n\n# Specific month\npython scripts/cost-guardian.py report --month 2026-02\n```\n\n### Optimization Recommendations\n```bash\n# Get optimization suggestions\npython scripts/cost-guardian.py optimize\n\n# JSON output\npython scripts/cost-guardian.py optimize --json\n```\n\n### Forecast Spend\n```bash\n# Forecast next 3 months\npython scripts/cost-guardian.py forecast\n\n# Forecast next N months\npython scripts/cost-guardian.py forecast --months 6\n\n# JSON output\npython scripts/cost-guardian.py forecast --json\n```\n\n### Manage Subscriptions\n```bash\n# Add a subscription\npython scripts/cost-guardian.py sub add --name \"OpenRouter\" --amount 20.00 --currency USD --cycle monthly --renews 2026-03-15 --category api\n\n# List subscriptions\npython scripts/cost-guardian.py sub list\n\n# Remove a subscription\npython scripts/cost-guardian.py sub remove --name \"OpenRouter\"\n\n# Check upcoming renewals\npython scripts/cost-guardian.py sub upcoming --days 14\n```\n\n### Status Dashboard\n```bash\n# Quick status overview\npython scripts/cost-guardian.py status\n\n# JSON output  \npython scripts/cost-guardian.py status --json\n```\n\n## Categories\n\n- `api` — AI model API costs (OpenAI, Anthropic, OpenRouter, etc.)\n- `hosting` — VPS, cloud, domain, DNS\n- `power` — Electricity for homelab\n- `subscription` — SaaS subscriptions\n- `hardware` — One-time hardware purchases\n- `other` — Everything else\n\n## Output Modes\n\nAll commands support:\n- **Human-readable** (default) — colored terminal output\n- **JSON** (`--json`) — structured data for programmatic use\n\n## Cron Integration\n\nAdd to OpenClaw cron for automated cost tracking:\n- Daily: `scan-tokens` to track API usage\n- Weekly: `report --period week` for digest\n- Monthly: `report` + `forecast` for full analysis\n- On-demand: `optimize` when looking to cut costs\n\n## Data Storage\n\nAll data stored in `~/.openclaw/workspace/costs/`:\n- `config.json` — budget settings, preferences\n- `costs.db` — SQLite database (entries, subscriptions, token scans)\n\n## Zero Dependencies\n\nPure Python 3 stdlib — no pip install needed. Uses sqlite3, json, datetime, pathlib.\n","tags":{"budget":"1.0.0","cost":"1.0.0","latest":"1.0.0","monitoring":"1.0.0","optimization":"1.0.0"},"stats":{"comments":0,"downloads":781,"installsAllTime":29,"installsCurrent":2,"stars":0,"versions":1},"createdAt":1771954295987,"updatedAt":1778491628548},"latestVersion":{"version":"1.0.0","createdAt":1771954295987,"changelog":"Initial release: AI & infrastructure cost tracking with budget alerts, token scanning, subscriptions, forecasting, and optimization recommendations. 9 commands, JSON output, zero dependencies.","license":null},"metadata":null,"owner":{"handle":"mariusfit","userId":"s17en27tt4m76ranka73sgtdfd884sb7","displayName":"mariusfit","image":"https://avatars.githubusercontent.com/u/53900085?v=4"},"moderation":null}