This is the page leanprompt report --html writes for the dated-chat example, before the fix, on the leanprompt site. Back to the dated-chat example

leanprompt audit of dated-chat (before/)

1 place where this app pays for tokens it doesn't need

The biggest, at before/app.ts:11, about 6.7M tokens per 1,000 calls: the system prompt starts with the current time to the second.

Together about 6.7M tokens per 1,000 calls An estimate from the code, not a measurement.

Tokens per 1,000 calls, by finding, and each one's share of the total

What this costs you

Every figure here is an estimate from the code, not a measurement. Findings can overlap (one failed call can show up in two), so the sum may count some tokens twice. Money is not part of the score. The table lists this app's findings first, largest first, then its open questions, then the questions for the server's administrator, then the findings the project already knows about, which are not in the totals.

FindingWhereTokens per 1,000 calls
LP-PC-03before/app.ts:116.7M not cached

To see this in money, add to leanprompt.yaml:

  • volume: {calls_per_month: N}: how many calls the app makes a month (with targets:, on each entry)
  • prices: per model: input, cached_input and output per 1M tokens (US dollars, or set currency), with source and checked date (or, self-hosted, engine: {prefill_tokens_per_second: N})

leanprompt never guesses a volume or a price. Your coding agent can look up the provider's current price page and add it with the date; how.

What's wrong and what to change

1 open, 0 fixed. Largest first, by the audit's estimate of tokens lost per 1,000 calls.

The system prompt starts with the current time to the second.

Finding 1. before/app.ts:11 high LP-PC-03

Every call therefore begins with a different line, so a provider that caches by prefix can reuse nothing, and the roughly 6,000-token handbook after it is read again on every call.

What to change
Take the time out of the system prompt and put it in a labelled <environment> block at the top of the newest user message, as LP-PC-03 recommends. The system prompt is then the same on every call.
Why it matters
A prefix cache matches from the first token and stops at the first difference. With nothing changing at the top, the handbook can be served from the cache on every call after the first.
Estimate
about 6.7 million prompt tokens per 1,000 calls that the cache could have served
What the estimate assumes

An average call of about 6,800 prompt tokens (the handbook, the instructions and a short question) and 60 output tokens; every call after the first in a cache lifetime could reuse all but the newest message.

How to check the fix Send two requests a few seconds apart and compare the provider's cached prompt tokens: near zero before, close to the handbook's size after.

Fix it with your coding agent

Paste this into Claude Code, Codex, Cursor or any coding assistant. It will check each finding against your code and propose fixes one at a time, asking before it changes anything.

Please check and fix the LLM-call findings from a leanprompt audit of this repository.

1. If the leanprompt skills are not installed for you here, install them: npx leanprompt@0.1.0-dev.15 install
2. Read .leanprompt/findings.json and leanprompt-report.md. If they are missing, use the list below.
3. Check each finding against the code before you change anything. The audit can be wrong: if a finding does not hold, tell me why and leave that code alone.
4. Fix one finding at a time. Show me the change as a small diff and apply it only after I say yes.
5. Prove each fix with the measure-loop skill: a before and after on the same scenario. Ask me before running anything that sends real, billed requests.
6. When a fix is proved, set "fixed": true on its finding in .leanprompt/findings.json and run npx leanprompt@0.1.0-dev.15 score.

Findings, largest first:
1. LP-PC-03 at before/app.ts:11: The system prompt starts with the current time to the second. Every call therefore begins with a different line, so a provider that caches by prefix can reuse nothing, and the roughly 6,000-token handbook after it is read again on every call.

Score

One number from 0 to 100 for how well this app avoids paying for the same tokens twice; higher is better. It is computed from the findings above (static) or from your usage log (measured).

46static
E, prefill reuse
0.10
S, prefix stability
1.00
G, generation waste
0.00
Default shares
0 of 1

Findings scored with severity defaults, not estimates. The fewer, the more the static score says about this app.

A static score is an estimate from the audit's findings, not a measurement.

Scored 2026-11-27 (the date on the machine that ran it).

Questions for the owner

These were not answered during the audit. Until they are, the page shows tokens only and ranks the advice without a priority.

  • Priority: which matters most for this app, cost, speed or quality (or weights)? Not set, so the advice uses equal weights. Answer with priority: in leanprompt.yaml.
  • Volume: how many calls does the app make a month? Answer with volume: {calls_per_month: N, source: "..."} in leanprompt.yaml.
  • Prices: what does each model cost (input, cached input, output per 1M tokens, with the source and the date it was read, and the currency if not US dollars)? Answer with prices: in leanprompt.yaml.