spending-analysis
This tool retrieves payment history and usage metrics from Polar and Tinybird using command-line processing utilities.
Install
mkdir -p .claude/skills/spending-analysis && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5257" && unzip -o skill.zip -d .claude/skills/spending-analysis && rm skill.zipInstalls to .claude/skills/spending-analysis
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Analyze Pollinations revenue, pack purchases, and tier spending patterns. Query Polar for payment history and Tinybird for usage data.Key capabilities
- →Query Stripe checkout revenue data
- →Calculate weekly pack purchase volume
- →Analyze revenue by individual user
- →Track generation event spend by meter source
- →Join revenue and usage data via user_id
How it works
It executes SQL queries against the Tinybird production API using a read token to fetch Stripe event logs and generation metrics.
Inputs & outputs
When to use spending-analysis
- →Calculate monthly recurring revenue
- →Analyze user tier adoption rates
- →Audit pack purchase history
- →Investigate usage spikes by tier
About this skill
Requirements
- Run from the
pollinationsrepository root. - Install
curl,jq, andsops. - Use the production Tinybird read token. The staging workspace has no real revenue.
Setup
export TINYBIRD_TOKEN=$(sops -d operations/kpi/secrets/env.json | jq -r '.TINYBIRD_READ_TOKEN')
Never print the token. Revenue queries must filter successful Stripe checkout events so asynchronous payment methods are counted exactly once.
Weekly pack revenue
curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT toStartOfWeek(timestamp) AS week, round(sum(amount_cents) / 100, 2) AS revenue_usd, count() AS purchases FROM stripe_event WHERE payment_status = 'paid' AND event_type IN ('checkout.session.completed', 'checkout.session.async_payment_succeeded') AND timestamp >= now() - INTERVAL 90 DAY GROUP BY week ORDER BY week DESC FORMAT JSON" \
| jq '.data'
Recent pack purchases
curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT timestamp, user_id, session_id, amount_cents / 100 AS amount, currency, payment_method FROM stripe_event WHERE payment_status = 'paid' AND event_type IN ('checkout.session.completed', 'checkout.session.async_payment_succeeded') ORDER BY timestamp DESC LIMIT 100 FORMAT JSON" \
| jq '.data'
Revenue by customer
curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT user_id, round(sum(amount_cents) / 100, 2) AS revenue_usd, count() AS purchases FROM stripe_event WHERE payment_status = 'paid' AND event_type IN ('checkout.session.completed', 'checkout.session.async_payment_succeeded') AND timestamp >= now() - INTERVAL 30 DAY GROUP BY user_id ORDER BY revenue_usd DESC LIMIT 50 FORMAT JSON" \
| jq '.data'
Weekly spend by balance bucket
curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT toStartOfWeek(start_time) AS week, splitByChar(':', selected_meter_slug)[-1] AS meter_source, sum(total_price) AS total_spend, count() AS requests FROM generation_event_v2 WHERE start_time >= now() - INTERVAL 60 DAY AND environment = 'production' GROUP BY week, meter_source ORDER BY week DESC FORMAT JSON" \
| jq '.data'
Notes
stripe_eventis the source of truth for pack-purchase revenue analytics.generation_event_v2records Pollen consumption, not cash revenue.- Both datasets use
user_id, so revenue and usage can be joined directly. - The dashboard's
daily_stripe_revenuepipe applies the same paid-event filter. - For pre-migration revenue history, note that Polar was the pre-Stripe merchant of record (Nov 2025–Jan 2026) and is retired. Do not combine historical Polar and Stripe totals without checking the cutoff for overlap.
When not to use it
- →When querying staging environments for revenue
- →When combining historical Polar data with Stripe totals without checking cutoffs
Prerequisites
Limitations
- →Requires production Tinybird read token
- →Generation events record consumption, not cash revenue
How it compares
It automates the extraction of financial metrics from production logs instead of manually querying the Stripe dashboard.
Compared to similar skills
spending-analysis side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| spending-analysis (this skill) | 1 | 2mo | Review | Intermediate |
| segment-cdp | 2 | 6mo | No flags | Intermediate |
| developing-in-lightdash | 1 | 27d | Review | Intermediate |
| coingecko | 1 | 8mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by pollinations
View all by pollinations →You might also like
segment-cdp
davila7
Expert patterns for Segment Customer Data Platform including Analytics.js, server-side tracking, tracking plans with Protocols, identity resolution, destinations configuration, and data governance best practices. Use when: segment, analytics.js, customer data platform, cdp, tracking plan.
developing-in-lightdash
lightdash
Build, configure, and deploy Lightdash analytics projects. Supports both dbt projects with embedded Lightdash metadata and pure Lightdash YAML projects without dbt. Create metrics, dimensions, charts, and dashboards using the Lightdash CLI.
coingecko
2025Emma
CoinGecko API documentation - cryptocurrency market data API, price feeds, market cap, volume, historical data. Use when integrating CoinGecko API, building crypto price trackers, or accessing cryptocurrency market data.
wellally-tech
huifer
Integrate digital health data sources (Apple Health, Fitbit, Oura Ring) and connect to WellAlly.tech knowledge base. Import external health device data, standardize to local format, and recommend relevant WellAlly.tech knowledge base articles based on health data. Support generic CSV/JSON import, provide intelligent article recommendations, and help users better manage personal health data.
groq-cost-tuning
jeremylongshore
Optimize Groq costs through tier selection, sampling, and usage monitoring. Use when analyzing Groq billing, reducing API costs, or implementing usage monitoring and budget alerts. Trigger with phrases like "groq cost", "groq billing", "reduce groq costs", "groq pricing", "groq expensive", "groq budget".
omero-integration
davila7
Microscopy data management platform. Access images via Python, retrieve datasets, analyze pixels, manage ROIs/annotations, batch processing, for high-content screening and microscopy workflows.