burnwatch 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +276 -214
  3. package/billing/anthropic.json +49 -0
  4. package/billing/billing.schema.json +213 -0
  5. package/billing/browserbase.json +68 -0
  6. package/billing/google-gemini.json +66 -0
  7. package/billing/inngest.json +45 -0
  8. package/billing/openai.json +70 -0
  9. package/billing/posthog.json +61 -0
  10. package/billing/resend.json +49 -0
  11. package/billing/scrapfly.json +38 -0
  12. package/billing/supabase.json +32 -0
  13. package/billing/upstash.json +65 -0
  14. package/billing/vercel.json +85 -0
  15. package/billing/voyage-ai.json +42 -0
  16. package/dist/cli.js +501 -256
  17. package/dist/cli.js.map +1 -1
  18. package/dist/cost-impact.d.ts +8 -4
  19. package/dist/cost-impact.js +261 -72
  20. package/dist/cost-impact.js.map +1 -1
  21. package/dist/{detector-myYS2eVC.d.ts → detector-DiBj3WjE.d.ts} +1 -1
  22. package/dist/hooks/on-file-change.js +271 -88
  23. package/dist/hooks/on-file-change.js.map +1 -1
  24. package/dist/hooks/on-prompt.js.map +1 -1
  25. package/dist/hooks/on-session-start.js +126 -76
  26. package/dist/hooks/on-session-start.js.map +1 -1
  27. package/dist/hooks/on-stop.js +87 -43
  28. package/dist/hooks/on-stop.js.map +1 -1
  29. package/dist/index.d.ts +6 -4
  30. package/dist/index.js +289 -114
  31. package/dist/index.js.map +1 -1
  32. package/dist/interactive-init.d.ts +2 -2
  33. package/dist/interactive-init.js +21 -19
  34. package/dist/interactive-init.js.map +1 -1
  35. package/dist/mcp-server.js +741 -85
  36. package/dist/mcp-server.js.map +1 -1
  37. package/dist/{types-BwIeWOYc.d.ts → types-CUAiYzmE.d.ts} +2 -0
  38. package/llms.txt +1 -1
  39. package/package.json +2 -1
  40. package/registry.json +12 -68
  41. package/skills/burnwatch-interview/SKILL.md +2 -4
  42. package/skills/setup-burnwatch/SKILL.md +7 -9
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  <p align="center">
2
2
  <h1 align="center">burnwatch</h1>
3
+ <p align="center"><strong>You're coding 10x. You might also be spending 10x.</strong></p>
3
4
  <p align="center">Passive cost memory for AI-assisted development.</p>
4
5
  </p>
5
6
 
@@ -7,44 +8,49 @@
7
8
  <a href="https://www.npmjs.com/package/burnwatch"><img src="https://img.shields.io/npm/v/burnwatch.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
8
9
  <a href="https://www.npmjs.com/package/burnwatch"><img src="https://img.shields.io/npm/dm/burnwatch.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
9
10
  <a href="https://github.com/RaleighSF/burnwatch/blob/main/LICENSE"><img src="https://img.shields.io/github/license/RaleighSF/burnwatch?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
10
- <a href="https://github.com/RaleighSF/burnwatch"><img src="https://img.shields.io/badge/dependencies-0-28CF8D?style=flat&colorA=18181B" alt="Zero Dependencies"></a>
11
+ <a href="https://github.com/RaleighSF/burnwatch"><img src="https://img.shields.io/badge/dependencies-0_runtime-28CF8D?style=flat&colorA=18181B" alt="Zero Runtime Dependencies"></a>
11
12
  </p>
12
13
 
13
14
  <br>
14
15
 
15
- burnwatch detects every paid service in your project, tracks what you're spending, and injects budget context directly into your AI coding sessions - so the agent knows what things cost before it recommends burning more money.
16
-
17
16
  ```
18
17
  ╔══════════════════════════════════════════════════════════════
19
- ║ BURNWATCH - your-app - March 2026
18
+ ║ BURNWATCH your-app March 2026
20
19
  ╠══════════════════════════════════════════════════════════════
21
20
  ║ Service Spend Conf Budget Left
22
21
  ║ ──────────────────────────────────────────────────────────
23
- Anthropic $47.20 ✅ LIVE $100 53%
24
- Vercel $23.00 LIVE $50 54%
25
- Scrapfly $127.00 ✅ LIVE $50 ⚠️ OVR
26
- Browserbase ~$63.00 🟠 EST $75 16%
27
- Supabase $25.00 LIVE $100 75%
28
- PostHog ~$49.00 🟡 CALC $49 0%
22
+ anthropic $47.20 ✅ LIVE $100 53%
23
+ vercel $20.00 🟡 CALC $20 flat — on plan
24
+ scrapfly $127.00 ✅ LIVE $100 ⚠️ OVER
25
+ browserbase ~$12.40 LIVE $99 87%
26
+ supabase $25.00 🟡 CALC $25 flat — on plan
27
+ posthog $0.00 🟡 CALC $0
28
+ ║ ↳ 234K/1M events (23%)
29
29
  ╠══════════════════════════════════════════════════════════════
30
- ║ TOTAL: ~$334.20 Untracked: 0 ✅ Est margin: ±$20
31
- ║ 🚨 SCRAPFLY 254% OVER BUDGET - review before use
30
+ ║ TOTAL: ~$231.60 Untracked: 0 ✅ Est margin: ±$12
31
+ ║ 🚨 scrapfly 127% OVER BUDGET - review before use
32
32
  ╚══════════════════════════════════════════════════════════════
33
33
  ```
34
34
 
35
- This brief appears automatically at the start of every [Claude Code](https://claude.ai/code) session. You don't open a dashboard. You don't remember to check anything. You just see what you're spending.
35
+ This shows up automatically. Every session. No dashboards to check. No tabs to remember. Just quiet awareness right where you're already working.
36
36
 
37
37
  <br>
38
38
 
39
- ## Why
39
+ ## The Problem
40
40
 
41
- Agentic development lets you ship 10x faster. It also lets you burn through $400 in Scrapfly credits, rack up unexpected Browserbase bills, and discover PostHog overages three weeks after the code that caused them was written - by an agent, in a session you barely remember.
41
+ Here's how it usually goes.
42
42
 
43
- **78% of IT leaders experienced unexpected charges** tied to consumption-based or AI pricing in the past 12 months ([Zylo 2026 SaaS Management Index](https://zylo.com/research/saas-management-index/)).
43
+ You're deep in a flow state. Claude is writing features, you're approving them, the codebase is growing, and everything feels amazing. Tuesday you add a Scrapfly key for web scraping. Wednesday you wire up Browserbase for browser automation. By Friday your agent has built a cron job that scrapes 1,000 competitor pages every other day. The code works perfectly.
44
+
45
+ Three weeks later the bill shows up. Turns out "works perfectly" costs $340/month and you signed up for the $99 plan.
44
46
 
45
- Existing tools either cover one service (ccusage tracks Claude tokens), require enterprise pricing (CloudZero, Vantage), or demand you already know what you're spending on. Nobody watches how services enter your stack and tracks them from the moment of introduction.
47
+ This is the new normal with AI-assisted development. The services that charge you are getting wired in by an agent that has zero concept of what they cost. It doesn't know that Scrapfly's anti-bot bypass burns 25x your base credits. It doesn't know that Anthropic Opus costs 15x more per token than Haiku. It doesn't know you're on the free tier with a hard cap at 1,000 API calls.
48
+
49
+ And the sneaky part? Most of these services look cheap when you sign up. $20/month. $99/month. Flat fee, no worries. But then there's the overage rate buried on page three of the pricing docs. You leave the signup page feeling good about $20 and come back to a monthly bill in the hundreds because you blew past the included usage and nobody told you.
50
+
51
+ **78% of IT leaders experienced unexpected charges** tied to consumption-based or AI pricing in the past 12 months ([Zylo 2026 SaaS Management Index](https://zylo.com/research/saas-management-index/)).
46
52
 
47
- burnwatch does.
53
+ burnwatch sits between your agent and your wallet. It watches every file save, knows every billing model, and speaks up before the damage is done.
48
54
 
49
55
  <br>
50
56
 
@@ -54,223 +60,332 @@ burnwatch does.
54
60
  npx burnwatch init
55
61
  ```
56
62
 
57
- That's it. burnwatch scans your project, detects paid services, creates a `.burnwatch/` directory, and registers Claude Code hooks. Next time you start a session, you see your spend.
63
+ That's it. burnwatch scans your project, detects paid services, and registers hooks. Next session, you see your spend.
58
64
 
59
- > **Requirements:** Node.js 18+ · Zero dependencies · Works with or without Claude Code
65
+ > **Requirements:** Node.js 18+ · Works with Claude Code, MCP, or standalone CLI
60
66
 
61
67
  <br>
62
68
 
63
- ## Quick Start
69
+ ## How It Works
64
70
 
65
- ### 1. Initialize
71
+ ### 1. Detection
66
72
 
67
- ```bash
68
- cd your-project
69
- npx burnwatch init
70
- ```
73
+ You run `npx burnwatch init` and burnwatch immediately scans four surfaces:
74
+
75
+ | What it checks | Example | When |
76
+ |----------------|---------|------|
77
+ | **package.json** | `"@anthropic-ai/sdk"` in dependencies | Init, file change |
78
+ | **Environment variables** | `SCRAPFLY_KEY` in `.env` | Every session start |
79
+ | **Import statements** | `import { Resend } from "resend"` | Init, file change |
80
+ | **Prompt mentions** | *"use Browserbase to scrape..."* | Every prompt |
71
81
 
72
82
  ```
73
83
  🔍 Scanning project for paid services...
74
84
 
75
- Found 11 paid services:
85
+ Found 6 paid services:
76
86
 
77
- Anthropic (Claude) (✅ LIVE API available)
87
+ Anthropic (Claude) ✅ LIVE API available
78
88
  Detected via: package.json, env vars, imports
79
- Vercel (✅ LIVE API available)
89
+ Scrapfly ✅ LIVE API available
90
+ Detected via: env vars, imports
91
+ ● Browserbase ✅ LIVE API available
92
+ Detected via: package.json, imports
93
+ ● Supabase ✅ LIVE API available
94
+ Detected via: package.json, env vars
95
+ ● Vercel 🟡 Flat plan
80
96
  Detected via: package.json
81
- Scrapfly (✅ LIVE API available)
82
- Detected via: env vars
83
- • Supabase (✅ LIVE API available)
97
+ PostHog 🟡 Free tier
84
98
  Detected via: package.json, imports
85
- ...
86
99
 
87
- 🔗 Registering Claude Code hooks...
100
+ 🔗 Registering hooks...
88
101
  ✅ burnwatch initialized!
89
102
  ```
90
103
 
91
- ### 2. Configure your services
104
+ ### 2. The Interview
92
105
 
93
- **In Claude Code (recommended):** Just ask the agent:
106
+ No CLI flags. No YAML config files. You just talk to your agent:
94
107
 
95
108
  ```
96
109
  You: "Let's set up burnwatch for this project"
97
110
  ```
98
111
 
99
- The agent runs `/burnwatch-interview` — a conversational flow that walks through each detected service one at a time, confirms plans, sets budgets, and configures API keys. No terminal commands needed.
112
+ Your agent runs a conversational interview, walking through each service by risk category (LLMs first, then usage-based, then flat infrastructure):
100
113
 
101
- **From the terminal:**
102
-
103
- ```bash
104
- burnwatch init # interactive interview in TTY mode
105
114
  ```
115
+ Agent: I found 6 services. Let me walk through each one.
106
116
 
107
- **Manual CLI (if you prefer):**
117
+ Anthropic I probed your API key. You're on API Usage,
118
+ $47.23 spent this billing period. Default budget: $100/mo.
119
+ Does that feel right?
108
120
 
109
- ```bash
110
- burnwatch add anthropic --key $ANTHROPIC_ADMIN_KEY --budget 100
111
- burnwatch add scrapfly --key $SCRAPFLY_KEY --budget 50
112
- burnwatch configure --service posthog --plan "Free" --budget 0
113
- ```
121
+ You: Yeah that's fine.
114
122
 
115
- API keys are stored in `~/.config/burnwatch/` (global, `chmod 600`). They **never** touch your project directory. They never end up in git.
123
+ Agent: Anthropic set to $100/mo budget.
116
124
 
117
- ### 3. Check your spend
125
+ Scrapfly Probe detected Pro plan (1M credits).
126
+ You've used 742K/1M credits. Budget: $100/mo.
118
127
 
119
- ```bash
120
- burnwatch status
121
- ```
128
+ You: Keep it.
122
129
 
123
- ### 4. Start coding
130
+ Agent: Scrapfly set to Pro, $100/mo.
124
131
 
125
- Start a Claude Code session. The spend brief appears automatically. When you mention a tracked service in a prompt, a spend card is injected:
132
+ Vercel You're on Pro ($20/mo flat).
133
+ PostHog — Free tier.
134
+ I'll set these as flat plans with matching budgets.
135
+ Skip?
126
136
 
137
+ You: Yep.
138
+
139
+ Agent: ✅ Vercel $20, PostHog $0 — all set.
127
140
  ```
128
- You: "Use Scrapfly to scrape the competitor pricing pages"
129
141
 
130
- [BURNWATCH] scrapfly - current period
131
- Spend: $127.00 | Budget: $50 | ⚠️ 254% over
132
- Confidence: LIVE
133
- ⚠️ 254% of budget consumed
142
+ Each answer is written back immediately. The whole thing takes about 90 seconds.
143
+
144
+ ### 3. Billing Manifests
145
+
146
+ This is where it gets interesting. Every tracked service has a **billing manifest**, a community-maintained JSON file that encodes the complete pricing model:
147
+
148
+ ```json
149
+ {
150
+ "serviceId": "browserbase",
151
+ "billingDimensions": [
152
+ {
153
+ "id": "browser_hours",
154
+ "name": "Browser hours",
155
+ "unit": "hour",
156
+ "ratePerUnit": 0.10,
157
+ "ratePer": 1,
158
+ "variants": [
159
+ { "id": "standard", "ratePerUnit": 0.10, "codePatterns": ["createSession"] }
160
+ ]
161
+ },
162
+ {
163
+ "id": "proxy_bandwidth",
164
+ "name": "Proxy bandwidth",
165
+ "unit": "GB",
166
+ "ratePerUnit": 10.00,
167
+ "ratePer": 1
168
+ }
169
+ ],
170
+ "plans": [
171
+ { "id": "startup", "monthlyBase": 99, "included": { "browser_hours": 500 } }
172
+ ],
173
+ "costMultipliers": [
174
+ { "id": "long_session", "factor": 10, "codePatterns": ["keepAlive", "waitForTimeout"] }
175
+ ]
176
+ }
134
177
  ```
135
178
 
136
- Claude factors this into its response - it might suggest Cheerio instead, or warn you before proceeding.
179
+ This is not guesswork. burnwatch knows that Browserbase charges per browser-hour (not per session), that the Startup plan includes 500 hours, that overages are $0.10/hr, and that long-running sessions with `keepAlive` can multiply cost by 10x. It knows that Anthropic Opus costs 5x more than Sonnet. It knows that Scrapfly's anti-bot bypass burns 5-25x base credits.
180
+
181
+ 12 services ship with production-verified manifests. Adding a new one is a single JSON file.
137
182
 
138
- When a new paid service enters your project (new dependency, new env var, new import), burnwatch alerts immediately:
183
+ ### 4. Passive Monitoring
184
+
185
+ You code. burnwatch watches. Every time a file is saved, three things happen silently:
186
+
187
+ **Cost impact analysis** scans the changed file for SDK call sites, detects multipliers (loops, `.map()`, `Promise.all`, cron schedules), resolves variable loop bounds, matches model variants in the code, and projects monthly cost:
139
188
 
140
189
  ```
141
- [BURNWATCH] 🆕 New paid service detected: resend
142
- Run 'burnwatch add resend' to configure budget and tracking.
190
+ [BURNWATCH] ⚠️ Cost impact estimate for scraper.ts
191
+ Browserbase: ~15,000 calls/mo $37-$375/mo (Long-running sessions)
192
+ Current: $12/$99 budget (12%)
143
193
  ```
144
194
 
145
- <br>
195
+ **Utilization tracking** updates incrementally, tracking every call site across the project and projecting overage:
146
196
 
147
- ## How It Works
148
-
149
- burnwatch runs as [Claude Code hooks](https://docs.anthropic.com/en/docs/claude-code/hooks) - background scripts that fire on session lifecycle events. It never proxies your traffic. It never intercepts API calls. It watches the exhaust of your sessions silently, completely, and without interrupting the work.
197
+ ```
198
+ [BURNWATCH] ⚠️ Browserbase utilization: ~750 browser-hours/mo
199
+ (plan includes 500) ~$25.00/mo overage
200
+ ```
150
201
 
151
- ### Four Detection Surfaces
202
+ **New service detection** fires if a file change introduces something burnwatch hasn't seen before:
152
203
 
153
- | Surface | What it catches | When |
154
- |---------|----------------|------|
155
- | **Package manifest** | `@anthropic-ai/sdk` in dependencies | `init`, `reconcile`, file change |
156
- | **Environment variables** | `SCRAPFLY_KEY` in process.env | Every session start |
157
- | **Import statements** | `import { Resend } from "resend"` | `init`, file change |
158
- | **Prompt mentions** | "use Browserbase to..." | Every prompt |
204
+ ```
205
+ [BURNWATCH] 🆕 New paid service detected: twilio
206
+ Run 'burnwatch add twilio' to configure budget and tracking.
207
+ ```
159
208
 
160
- ### Confidence Badges
209
+ ### 5. Intervention (The Part That Actually Saves You Money)
161
210
 
162
- Every spend figure carries an honest confidence badge:
211
+ Here's the scenario that matters. You're five sessions and 4,000 lines deep. You tell Claude to build a web scraper:
163
212
 
164
- | Badge | Meaning | Source |
165
- |-------|---------|--------|
166
- | **LIVE** | Real billing API data | Polls service API with your key |
167
- | 🟡 **CALC** | Fixed monthly cost | You enter your plan cost; burnwatch projects daily burn |
168
- | 🟠 **EST** | Instrumented estimate | Usage signals + pricing formula from registry |
169
- | 🔴 **BLIND** | Detected, not tracked | Service is in your project but no key or cost configured |
213
+ ```
214
+ You: "Create a scraper that uses Browserbase to scrape 1000 competitor
215
+ pages every other day on a cron job"
216
+ ```
170
217
 
171
- If burnwatch can't track a service accurately, it says so. The ledger always shows the untracked count. You never get a clean dashboard hiding a surprise bill.
218
+ Claude writes the code. The moment the file is saved, burnwatch fires:
172
219
 
173
- ### Three Outputs
220
+ ```
221
+ [BURNWATCH] ⚠️ Cost impact estimate for scraper.ts
222
+ Browserbase: ~15,000 sessions/mo → $37-$375/mo (Long-running sessions)
223
+ Current: $12/$99 budget (12%)
174
224
 
175
- | Output | Trigger | What it does |
176
- |--------|---------|-------------|
177
- | **Session brief** | Every session start | Full spend table with alerts and untracked count |
178
- | **Spend cards** | Service mentioned in prompt | Current spend, budget status, confidence for that service |
179
- | **New service alerts** | File change introduces a paid service | Flags it immediately, prompts you to configure |
225
+ [BURNWATCH] ⚠️ Browserbase utilization: ~750 browser-hours/mo
226
+ (plan includes 500) → ~$25.00/mo overage
227
+ ```
180
228
 
181
- ### The Ledger
229
+ Claude sees this **in its own context**, injected as a system message. It doesn't wait for you to ask about cost. It responds proactively:
182
230
 
183
- burnwatch writes `.burnwatch/spend-ledger.md` at the end of every session - human-readable, git-committable, designed to be read in 10 seconds:
231
+ ```
232
+ Agent: I built the scraper, but heads up — burnwatch flagged this:
184
233
 
185
- ```markdown
186
- # Burnwatch Ledger - your-app
187
- Last updated: 2026-03-24T14:32:11Z
234
+ At 1,000 pages every other day, you're looking at ~750
235
+ browser-hours/month. Your Startup plan includes 500 hours,
236
+ so you'd hit ~$25/mo in overage on top of the $99 base.
188
237
 
189
- ## This Month (March 2026)
190
- | Service | Spend | Conf | Budget | Status |
191
- |---------|-------|------|--------|--------|
192
- | Anthropic | $47.20 | LIVE | $100 | 53% - healthy |
193
- | Scrapfly | $127.00 | ✅ LIVE | $50 | ⚠️ 254% over |
194
- | Vercel | $23.00 | ✅ LIVE | $50 | 54% - healthy |
238
+ A few options:
239
+ 1. Reduce to 500 pages per run (stays within plan)
240
+ 2. Use Playwright locally for non-JS pages (free)
241
+ 3. Batch into fewer longer sessions to reduce overhead
195
242
 
196
- ## TOTAL: ~$209.70 (±$2 estimated margin)
197
- ## Untracked services: 0
243
+ Want me to adjust?
198
244
  ```
199
245
 
246
+ **That conversation does not happen without burnwatch.** Without it, Claude writes the scraper, you ship it, and you find out about the overage three weeks later when the bill shows up. By then the cron job has been happily running the whole time.
247
+
200
248
  <br>
201
249
 
202
- ## Supported Services
250
+ ## Multiplier Detection
203
251
 
204
- 14 services out of the box. [Add more via PR](#contributing).
205
-
206
- | Service | Tier | Billing Model | Notes |
207
- |---------|------|--------------|-------|
208
- | Anthropic | LIVE | Per-token | Requires admin API key |
209
- | OpenAI | LIVE | Per-token | Requires org API key |
210
- | Vercel | LIVE | Compute + overages | Requires Vercel token |
211
- | Scrapfly | LIVE | Credit pool | Standard API key works |
212
- | Stripe | LIVE | % of transaction | Tracks processing fees |
213
- | Supabase | LIVE | Tiered + overages | Management API |
214
- | Browserbase | 🟠 EST | Per-session | Estimated from usage |
215
- | Upstash | 🟠 EST | Per-command | Estimated from usage |
216
- | Resend | 🟠 EST | Per-email | Estimated from sends |
217
- | Inngest | 🟡 CALC | Tiered | User-entered plan cost |
218
- | PostHog | 🟡 CALC | Tiered | User-entered plan cost |
219
- | Google Gemini | 🟡 CALC | Per-token | User-entered budget |
220
- | Voyage AI | 🟡 CALC | Per-token | User-entered budget |
221
- | AWS | 🔴 BLIND | Varies | Detected, complex billing |
252
+ burnwatch doesn't just count API calls. It reads the code structure around them.
253
+
254
+ | Pattern | Example | Detection |
255
+ |---------|---------|-----------|
256
+ | **Literal loop bounds** | `for (let i = 0; i < 1000; i++)` | Factor: 1000 |
257
+ | **Variable loop bounds** | `const PAGES = 1000; for (i < PAGES)` | Resolves `PAGES` to 1000 |
258
+ | **Array iteration** | `urls.map(async (u) => scrape(u))` where `urls = Array(500)` | Factor: 500 |
259
+ | **for...of** | `for (const page of pages)` where `pages` has known size | Resolved size |
260
+ | **Promise.all** | `Promise.all(urls.map(...))` | No double-count with `.map()` |
261
+ | **Named constants** | `const NUM_REQUESTS = 5000` | Detected as multiplier hint |
262
+ | **Cron: every 5 min** | `// every 5 minutes` or `*/5 * * *` | Factor: 8640/mo |
263
+ | **Cron: every other day** | `// every other day` or `*/2` | Factor: 15/mo |
264
+ | **Cron: weekly** | `// every week` or `0 0 * * 0` | Factor: 4/mo |
265
+ | **Batch size** | `const batch_size = 50` | Factor: 50 |
266
+
267
+ When a billing manifest has **cost multipliers** with code patterns (like Scrapfly's `asp.*true` for anti-bot bypass), those get detected too, giving you a cost range instead of a single number.
222
268
 
223
269
  <br>
224
270
 
225
- ## How the Agent Changes Behavior
271
+ ## Confidence Tiers
226
272
 
227
- The real power isn't showing _you_ what you spent - it's telling _the agent_ what everything costs, in context, so cost becomes a factor in every recommendation.
273
+ Every spend figure carries a confidence badge. burnwatch never pretends to know more than it does.
228
274
 
229
- When Claude sees `Scrapfly: $127 / $50 budget, 254% over` in its context, it:
275
+ | Badge | Meaning | Source |
276
+ |-------|---------|--------|
277
+ | ✅ **LIVE** | Real billing API data | Polls service API with your key |
278
+ | 🟡 **CALC** | Fixed monthly cost | You enter your plan cost |
279
+ | 🟠 **EST** | Instrumented estimate | Usage signals + pricing formula |
280
+ | 🔴 **BLIND** | Detected, not tracked | Service exists but no config |
230
281
 
231
- - Suggests free alternatives (Cheerio, Playwright) before reaching for Scrapfly
232
- - Warns before generating code that would make more API calls
233
- - Factors cost into architecture decisions
234
- - Acknowledges budget constraints without you having to mention them
282
+ The brief always shows the untracked count. You never get a clean-looking dashboard hiding a surprise.
235
283
 
236
- This feedback loop doesn't exist anywhere else today. The agent has cost memory.
284
+ <br>
285
+
286
+ ## Supported Services
287
+
288
+ | Service | Tier | Billing Model | The Thing That Gets You |
289
+ |---------|------|--------------|------------------------|
290
+ | Anthropic | ✅ LIVE | Per-token | Opus is 15x more per token than Haiku. Your agent picks models. |
291
+ | OpenAI | ✅ LIVE | Per-token | GPT-4o-mini is 66x cheaper than o1. Model choice matters a lot. |
292
+ | Scrapfly | ✅ LIVE | Credit pool | Anti-bot bypass burns 5-25x base credits. Silently. |
293
+ | Browserbase | ✅ LIVE | Per browser-hour | Charged by time, not sessions. Long sessions cost more. |
294
+ | Vercel | ✅ LIVE | Compute + overages | Function GB-hours is the #1 surprise on Vercel bills. |
295
+ | Supabase | ✅ LIVE | Tiered + overages | Database size grows fast with vector embeddings. |
296
+ | Google Gemini | 🟡 CALC | Per-token | Generous free tier, but Flash 2.0 is so cheap people forget to check. |
297
+ | Voyage AI | 🟡 CALC | Per-token | Embedding-only. Cost scales with corpus size, not query count. |
298
+ | Upstash | 🟠 EST | Per-command | $0.20/100K commands. Free tier: 10K/day. Easy to forget it's metered. |
299
+ | Resend | 🟠 EST | Per-email | $0.90/1K emails overage on Pro. Fine until your app goes viral. |
300
+ | Inngest | 🟡 CALC | Per-execution | Runs AND steps both count. A 5-step function is 6 executions. |
301
+ | PostHog | 🟡 CALC | Per-event | 1M events/mo free. That sounds like a lot until it isn't. |
237
302
 
238
303
  <br>
239
304
 
240
- ## Claude Code Setup
305
+ ## Billing Manifests
241
306
 
242
- burnwatch is designed to work natively with Claude Code. When you run `npx burnwatch init`, it:
307
+ The `billing/` directory contains one JSON file per service. Each manifest encodes:
243
308
 
244
- 1. **Detects** all paid services in your project
245
- 2. **Copies hooks** to `.burnwatch/hooks/` (session start, prompt submit, file change, stop)
246
- 3. **Installs skills** to `.claude/skills/` three agent skills become available:
247
- - `/setup-burnwatch` Guided onboarding that walks you through configuring all services
248
- - `/burnwatch-interview` Conversational interview that confirms plans, budgets, and API keys one service at a time
249
- - `/spend` — Quick spend check (or `/spend scrapfly` for a specific service)
250
- 4. **Registers hooks** in `.claude/settings.json`
309
+ - **Billing dimensions**: every axis the service charges on (tokens, sessions, bandwidth, etc.)
310
+ - **Variants**: per-model rates with regex code patterns for auto-detection (Haiku vs Sonnet vs Opus)
311
+ - **Plans**: what's included, overage rates, hard caps
312
+ - **Cost multipliers**: feature flags that multiply cost (anti-bot bypass, JS rendering, stealth mode)
313
+ - **Typical dev usage**: realistic usage patterns for smarter projections
251
314
 
252
- ### Agent-driven configuration
315
+ ### Adding a new service
253
316
 
254
- Instead of running CLI commands manually, let the agent interview you:
317
+ Drop a JSON file in `billing/`:
255
318
 
319
+ ```json
320
+ {
321
+ "$schema": "./billing.schema.json",
322
+ "serviceId": "my-service",
323
+ "name": "My Service",
324
+ "lastVerified": "2026-03-25",
325
+ "pricingUrl": "https://my-service.com/pricing",
326
+ "billingDimensions": [
327
+ {
328
+ "id": "api_calls",
329
+ "name": "API calls",
330
+ "unit": "call",
331
+ "ratePerUnit": 1.00,
332
+ "ratePer": 1000
333
+ }
334
+ ],
335
+ "plans": [
336
+ {
337
+ "id": "pro",
338
+ "name": "Pro ($29/mo)",
339
+ "monthlyBase": 29,
340
+ "included": { "api_calls": 50000 },
341
+ "overageRates": { "api_calls": 1.00 }
342
+ }
343
+ ]
344
+ }
256
345
  ```
257
- You: "Let's configure burnwatch"
258
346
 
259
- Agent: I found 11 services in your project. Let me walk through each one.
347
+ No code changes needed. The cost engine picks it up automatically.
260
348
 
261
- First — Anthropic. Defaulted to "API Usage" at $100/mo.
262
- I checked your API — you've spent $47.23 this month.
263
- Does $100/mo feel right, or want to adjust?
349
+ <br>
264
350
 
265
- You: That's good, keep it.
351
+ ## MCP Server
266
352
 
267
- Agent: Got it Anthropic set to $100/mo.
353
+ burnwatch ships an MCP server for use with any MCP-enabled LLM:
268
354
 
269
- Next — Scrapfly. Probe detected Pro plan, 250K/1M credits used.
270
- Keep the $100/mo budget?
355
+ ```bash
356
+ claude mcp add burnwatch -- node ./node_modules/burnwatch/dist/mcp-server.js
271
357
  ```
272
358
 
273
- The agent works through services by risk category (LLMs first, then usage-based, then infrastructure), batches free-tier services together, and writes each answer back immediately via `burnwatch configure`.
359
+ **Tools exposed:**
360
+
361
+ | Tool | Purpose |
362
+ |------|---------|
363
+ | `get_spend_brief` | Full spend table with alerts |
364
+ | `get_service_spend` | Detailed info for one service |
365
+ | `analyze_cost_impact` | Analyze a file for cost-impacting SDK calls |
366
+ | `get_utilization` | Project-wide utilization and overage projections |
367
+ | `get_billing_manifest` | Raw billing manifest for any service |
368
+ | `detect_paid_services` | Scan for paid services in a project |
369
+ | `list_registry_services` | All services in the registry |
370
+
371
+ <br>
372
+
373
+ ## Claude Code Integration
374
+
375
+ burnwatch runs as [Claude Code hooks](https://docs.anthropic.com/en/docs/claude-code/hooks), background scripts that fire on session lifecycle events:
376
+
377
+ | Hook | Event | What it does |
378
+ |------|-------|-------------|
379
+ | **Session start** | New or resumed session | Polls billing APIs, renders the spend brief |
380
+ | **Prompt submit** | You type a prompt | Detects service mentions, injects spend cards |
381
+ | **File change** | Code is written/edited | Cost impact analysis, new service detection, utilization update |
382
+ | **Session stop** | Session ends | Writes the spend ledger to disk |
383
+
384
+ burnwatch also installs three **agent skills**:
385
+
386
+ - `/setup-burnwatch`: Guided onboarding
387
+ - `/burnwatch-interview`: Conversational service-by-service configuration
388
+ - `/spend`: Quick spend check (or `/spend scrapfly` for one service)
274
389
 
275
390
  <br>
276
391
 
@@ -283,46 +398,27 @@ burnwatch add <service> [options] Register a service for tracking
283
398
  burnwatch configure [options] Update service config (plan, budget, key)
284
399
  burnwatch interview --json Export current state as JSON (for agent use)
285
400
  burnwatch status Show current spend brief
401
+ burnwatch scan Full project utilization scan
286
402
  burnwatch services List all services in registry
287
403
  burnwatch reconcile Scan for untracked services
288
- burnwatch help Show help
289
404
  burnwatch version Show version
290
405
  ```
291
406
 
292
- ### `burnwatch add` options
293
-
294
- | Flag | Description |
295
- |------|-------------|
296
- | `--key <KEY>` | API key for LIVE tracking (saved to `~/.config/burnwatch/`) |
297
- | `--token <TOKEN>` | Alias for `--key` |
298
- | `--budget <N>` | Monthly budget in USD |
299
- | `--plan-cost <N>` | Monthly plan cost for CALC tracking |
300
-
301
- ### `burnwatch configure` options
302
-
303
- | Flag | Description |
304
- |------|-------------|
305
- | `--service <ID>` | Service to configure (e.g., `anthropic`, `scrapfly`) |
306
- | `--plan <NAME>` | Set the plan tier |
307
- | `--budget <N>` | Set monthly budget in USD |
308
- | `--key <KEY>` | Set API key for LIVE tracking |
309
- | `--exclude` | Exclude service from tracking |
310
-
311
407
  <br>
312
408
 
313
- ## Config Model
409
+ ## Config & Security
314
410
 
315
- Sensitive credentials never live in your project directory.
411
+ Credentials never live in your project directory.
316
412
 
317
413
  ```
318
414
  ~/.config/burnwatch/
319
415
  config.json API keys, tokens (chmod 600, never in git)
320
416
 
321
417
  your-project/.burnwatch/
322
- config.json Tracked services, budgets, detection history
418
+ config.json Services, budgets, detection history
323
419
  spend-ledger.md Human-readable spend report (git-committable)
324
- .gitignore Ignores cache/snapshots, keeps ledger and config
325
420
  data/
421
+ utilization.json Code-derived usage projections
326
422
  events.jsonl Append-only event log
327
423
  cache/ Billing API response cache
328
424
  snapshots/ Point-in-time spend snapshots
@@ -330,51 +426,17 @@ your-project/.burnwatch/
330
426
 
331
427
  <br>
332
428
 
333
- ## Reconciliation
334
-
335
- burnwatch doesn't need to run in every session. It takes snapshots when present and computes deltas between them.
336
-
337
- ```bash
338
- burnwatch reconcile
339
- ```
340
-
341
- Re-scans your project for services introduced in sessions where burnwatch wasn't active. For billing APIs that expose cumulative usage (like Scrapfly's credit counter), it computes the delta between snapshots - attributing spend across the gap.
342
-
343
- <br>
344
-
345
- ## The Registry
346
-
347
- `registry.json` is the community knowledge base. Each service entry includes detection patterns, pricing formulas, gotchas, and alternatives:
348
-
349
- ```json
350
- {
351
- "scrapfly": {
352
- "packageNames": ["scrapfly-sdk"],
353
- "envPatterns": ["SCRAPFLY_KEY"],
354
- "billingModel": "credit_pool",
355
- "scalingShape": "linear_burndown",
356
- "apiTier": "live",
357
- "pricing": { "unitRate": 0.00015, "unitName": "credit" },
358
- "gotchas": ["Anti-bot bypass consumes 5-25x base credits"],
359
- "alternatives": ["cheerio", "playwright", "firecrawl"]
360
- }
361
- }
362
- ```
363
-
364
- The `gotchas` and `alternatives` fields aren't just metadata - the agent reads them and uses them to make better recommendations. Every PR that adds a service makes burnwatch smarter for every user.
365
-
366
- <br>
367
-
368
429
  ## Contributing
369
430
 
370
- Contributions are welcome. The easiest way to contribute is adding a new service to `registry.json`:
431
+ The fastest way to contribute: add a billing manifest.
371
432
 
372
433
  1. Fork the repo
373
- 2. Add your service entry to `registry.json` following the existing schema
374
- 3. Include: `packageNames`, `envPatterns`, `billingModel`, `apiTier`, `pricing`, and ideally `gotchas` + `alternatives`
375
- 4. Open a PR
434
+ 2. Create `billing/<service-id>.json` following `billing/billing.schema.json`
435
+ 3. Include billing dimensions, plans, and ideally cost multipliers
436
+ 4. Verify rates against the service's pricing page
437
+ 5. Open a PR
376
438
 
377
- See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
439
+ You can also add services to `registry.json` with detection patterns, or improve the cost-impact multiplier detection.
378
440
 
379
441
  <br>
380
442