Skip to content
SlashClone

Gross margin by customer

@agentcosts/gross-margin-by-customer

Gross margin per customer for an AI product: revenue minus LLM cost minus allocated hosting and other cost of revenue. Flags negative and below-target customers, names the task driving their cost, and gives the price each one would need to hit your target margin.

SkillFinancev1.0.0 (latest)Tested
Activity
New: be the first to try it

Real output from this kit

How this works

  1. It is a skill: written instructions Claude reads when your request matches what the skill is for. You do not call it by name; just ask for the task.
  2. While it works, it reads and changes files in the places it lists, nowhere else.
  3. It runs these commands on your computer: node scripts/margin.mjs.
  4. Nothing runs until you choose to use it, and you can remove it any time.

SKILL.md

Gross margin by customer

AI products have a cost of goods that moves with usage, so two customers on the same plan can have very different margins. This kit puts revenue, model costs, and the rest of cost of revenue side by side per customer and month, so pricing conversations start from facts.

Inputs

  1. Usage in the shared schema (timestamp, customer, task, model, tokens..., cost_usd). From app logs, or from provider exports via the llm-usage-normalizer kit. Blank cost_usd is priced with --prices (check those prices against each provider's current pricing first).
  2. Revenue data/revenue.csv: customer,month,revenue. Use recognized monthly revenue (an annual contract is 1/12 per month), net of discounts. Customer names must match the usage file exactly.
  3. Other cost of revenue (optional) data/cogs.csv: item,month,amount,allocation. Allocation is usage (by LLM cost share, good for hosting and vector databases), revenue (payment fees), even (per-customer tools), or customer:<name> (dedicated infrastructure). Only cost of revenue belongs here, not sales or R&D.
  4. Target margin (default 70%, --target 0.7). Ask the user; 60 to 80% is common for software with AI features.

Steps

  1. Check that customer names match between usage and revenue. List names that appear in only one file and fix them with the user (usually a naming mismatch or an unmapped API key).
  2. Run:

    node scripts/margin.mjs data/usage.csv --revenue data/revenue.csv --cogs data/cogs.csv --prices data/llm-prices.csv --target 0.7 --out out/margin
  3. Read out/margin.md and report per month: overall gross margin, each negative customer, each below-target customer, and the task that drives their cost.
  4. Explain the levers for each problem customer, in this order:

    • Cost: cheaper model for that task's simpler steps, better prompt caching, fewer retries (a low success rate burns money).
    • Packaging: usage caps or overage on the heavy task (see consumption-guardrails).
    • Price: price_for_target is what they would need to pay to hit the target. Use usage-pricing-simulator to test a new model on everyone before changing one deal.
  5. Mention unattributed LLM cost (internal use, evals, trials). It is real cost even though it is not in any customer's margin.

Output template

**October gross margin: 57% (target 70%).**
- cobalt-labs: -116% ($60 revenue, $130 cost). 96% of cost is research_agent. Needs $433/mo for 70%.
- northwind-co: 40%. research_agent again. Needs $477/mo.
- Everyone else is above 80%.
Biggest lever: research_agent cost per run. Next: model choice for its steps, then usage-based pricing for it.

Guardrails

  • Margins use the price table you give it. Say "based on the example prices" if the user has not checked them.
  • Revenue and margins per customer are sensitive. Keep them in out/ and do not paste the full table into shared channels.
  • This kit does not change prices or contracts. It informs a decision people make.

README.md

Gross margin by customer

Shows the gross margin of every customer of your AI product: revenue minus model costs minus allocated hosting and other cost of revenue. It flags who is negative or under target, which task drives their cost, and what they would need to pay to hit your target.

Who it is for: founders and finance leads at AI products preparing pricing changes, renewals, or board reviews.

Example

Input: examples/usage.csv (October LLM usage), examples/revenue.csv, examples/cogs.csv (hosting, vector database, support tooling, dedicated storage), examples/prices.csv.

Output (out/margin.md):

CustomerRevenueLLM costOther COGSGross marginStatusBiggest costPrice for 70%
cobalt-labs$60$66.22$63.53-116.3%negativeresearch_agent (96%)$433
northwind-co$240$73.26$69.7540.4%below targetresearch_agent (94%)$477
bluepeak$149$3.30$7.9292.5%okcode_review (99%)$37

What it can access

  • Runs node scripts/margin.mjs (Node built-ins only).
  • Reads data/. Writes out/margin*.
  • No network.

Setup

None. If your usage comes from provider exports, run @agentcosts/llm-usage-normalizer first. Check the example prices against each provider's current pricing before trusting the numbers.

Files

  • README.md
  • SKILL.md
  • examples/cogs.csv
  • examples/prices.csv
  • examples/revenue.csv
  • examples/usage.csv
  • kit.json
  • scripts/lib.mjs
  • scripts/margin.mjs
  • scripts/usage.mjs

Did it work?

0worked for them0did not work

Sign in to say whether it worked for you.

Nobody has said yet. Tried it? Tell the next person.