The page leanprompt report --html writes for shareAI-lab/learn-claude-code at commit 448c75b, audited 2026-11-27. Every figure on this page is an estimate from reading the code, not a measurement of the app in use. Corrections and takedown: email info@podwarden.com or open an issue. Back to the audit of shareAI-lab/learn-claude-code

leanprompt audit of shareAI-lab/learn-claude-code

Unattended audit: nobody was asked during the run, so priority, volume and prices were left open; the questions for the owner are listed at the end.

4 places where this app pays for tokens it doesn't need

The biggest, at s08_context_compact/code.py:554, about 7.7M tokens per 1,000 calls: every chapter's agent loop resends the whole growing conversation on each turn with no cache_control mark anywhere in the repository, so on Anthropic nothing is ever read from the prompt cache.

Together about 8.3M tokens per 1,000 calls An estimate from the code, not a measurement. Findings that overlap are counted once.

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

Plus 3 other problems the audit found, listed after the findings. Not scored.

What this costs you

Every figure here is an estimate from the code, not a measurement. Findings the audit marked as overlapping are counted once in the totals, the largest of each group; other findings can still overlap. 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-01s08_context_compact/code.py:5547.7M not cached; the fix writes 1M to the cache at the write price
LP-PC-02s15_integrated_harness/code.py:8587.4M not cached
LP-PC-02s09_memory/code.py:7311.2M not cached
LP-GE-06s15_integrated_harness/code.py:3184583k prompt, 17k output

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

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

Every chapter's agent loop resends the whole growing conversation on each turn with no cache_control mark anywhere in the repository, so on Anthropic nothing is ever read from the prompt cache.

Finding 1. s08_context_compact/code.py:554 high LP-PC-01

The compaction chapter teaches how to shrink context but never shows that the unchanged part of it can be reused at a tenth of the price.

What to change
Mark the end of the tools, the end of the system prompt and the newest message, on copies made at send time (a ten-line helper). Put it in s08, where context cost is the topic, and say in its README why it is safe next to compaction.
Why it matters
Without marks each turn pays the full input price for the system prompt, the tools and all earlier turns, although the model saw them seconds ago. A coding-agent loop returns within seconds, so a mark pays back after the first read.
Overlaps
Finding 2, 3 loses some of the same tokens; the totals count the larger once.
Estimate
about 7.7M prompt tokens per 1,000 loop calls not served from cache (estimate)
What the estimate assumes

default Anthropic target (claude-sonnet-4-6, .env.example), 9,000-token average call: about 2,000 for system plus tools and 7,000 of history (s08 compacts at 50,000 characters, about 12k tokens); about 1,000 new tokens per turn; calls seconds apart; first turns under the 1,024-token minimum lose nothing. The Anthropic-compatible hosts listed in .env.example (MiniMax, GLM, Kimi, DeepSeek) cache by their own rules: unknown, check each provider's docs. Figures are per 1,000 loop calls of one chapter run by a learner.

How to check the fix Run s08 for three tool turns inside five minutes; print response.usage. cache_read_input_tokens should be about the size of the previous request on turns 2 and 3 (it is 0 today), and cache_creation_input_tokens about the new turn.

The capstone rebuilds its system prompt on every model call and writes the current time to the second into it.

Finding 2. s15_integrated_harness/code.py:858 high LP-PC-02

The prompt is therefore different on every call, so once cache marks exist the provider can reuse nothing after the time line: not the skills catalog, not the memory text, not the conversation.

What to change
Remove the time line from the system prompt. If the model needs the date, give the date only, or put the time in the newest user message.
Why it matters
The cache reads a prefix byte for byte; one changed byte early in the system prompt re-prices everything after it, which is the whole conversation on every call.
Overlaps
Finding 1, 3 loses some of the same tokens; the totals count the larger once.
Estimate
about 7.4M prompt tokens per 1,000 loop calls would still miss the cache after marks are added (estimate)
What the estimate assumes

marks added as in the other finding; the part before the time line (about 750 tokens of fixed sections) and the tool list stay cacheable; 7,000 tokens of history plus a 400-token tail of the system prompt are lost on each call.

How to check the fix After adding marks, run s15 for two tool turns a few seconds apart and compare the system text of the two requests (identical) and cache_read_input_tokens (about the size of the earlier request, not 0).

The memory records chosen for each new user request are written into the system prompt (build_system, lines 353-354, used at line 731; the same in s15 lines 863-864).

Finding 3. s09_memory/code.py:731 medium LP-PC-02 how often is assumed

The system prompt then changes on every new request, so the whole earlier conversation is re-priced at its first call. Issue 311 reported this in May and PR 312 moved the records into the user turn; the current tree has them in the system prompt again.

What to change
Keep the memory index in the system prompt and put the selected records in the newest user message, as PR 312 did.
Why it matters
The system prompt sits before the messages, so any change to it makes every message after it a cache miss.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many loop calls a typical user request makes, and whether the .memory folder holds records
Overlaps
Finding 1, 2 loses some of the same tokens; the totals count the larger once.
Estimate
about 1.2M prompt tokens per 1,000 loop calls (estimate)
What the estimate assumes

6 loop calls per user request; one lost history of about 7,000 tokens per request; only matters once marks exist; applies when the memory store is not empty.

How to check the fix With marks on, send two requests that select different memories; cache_read_input_tokens on the second request's first call should cover the earlier conversation.

The capstone's loop calls update_context on every cycle (line 3184), and that runs the s09 memory selection (s09 lines 285-310), which is a separate model call.

Finding 4. s15_integrated_harness/code.py:3184 medium LP-GE-06 how often is assumed

The inputs are the same user text on every tool turn, so one request with six tool turns asks the model the same question six times. In s09 the same call runs once per request.

What to change
Run update_context once per user request, before the while loop, as s09 does; refresh only when a memory is written.
Why it matters
Each extra selection call sends the request text and up to 12,000 characters of catalog, adds a blocking round trip before every turn, and, because the answer is sampled, can change the system prompt between turns.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many loop calls a typical user request makes, and whether the .memory folder holds records
Estimate
about 580k prompt tokens and 17k output tokens per 1,000 loop calls (estimate)
What the estimate assumes

6 loop calls per user request, so 5 of 6 selection calls repeat; about 700 tokens per selection prompt, 20 output tokens; memory store not empty (selection returns early when it is).

How to check the fix Count messages.create calls for one request with five tool turns: after the fix the memory selection runs once, not five times.

Other problems the audit found

Problems the audit checked in the code that cost no tokens of their own, such as a spend meter that ignores cache tokens or a cut-off answer accepted as complete. They are not scored. Check each one before you change anything.

A compaction summary cut at 2,000 tokens replaces the whole history

Note 1. s08_context_compact/code.py:486 LP-GE-12 high not scored

summarize_history asks for at most 2,000 tokens and never reads stop_reason. A summary that stopped at the limit becomes the entire conversation (compact_history, line 504) and is trusted as complete. The same pattern is at s15_integrated_harness/code.py line 2205.

What to change
Read response.stop_reason; on max_tokens, ask again with a higher limit or keep the old messages instead of replacing them.
Why it matters
Nothing fails: the model continues from a summary that is missing its last items, such as remaining work and user constraints.

How to check the fix Stub the client to return stop_reason max_tokens: the compactor must not return a one-message history.

s15 compaction summarises the oldest 80,000 characters and drops the newest

Note 2. s15_integrated_harness/code.py:2193 not scored

summarize_history cuts the JSON with [:80000], which keeps the start of the conversation. When history is longer than that, the newest turns, which hold the current state, are not summarised and not marked as omitted. Issue 109 reported the same cut in the old chapter; agents/s06_context_compact.py:118 and agents/s_full.py:255 use [-80000:], and s08_context_compact/code.py:469-475 keeps head and tail with a marker.

What to change
Use the s08 approach: keep a head, a tail and an 'omitted' marker, or summarise only the older part and keep the newest messages.
Why it matters
A summary of the wrong end of a long conversation makes the agent restart from stale state.

How to check the fix Feed a history of 120,000 characters whose last message holds a distinctive string: it must reach the summary prompt.

The goal loop's token counter reads two usage fields and skips the evaluator

Note 3. s17_goal_loop/code.py:120 LP-GE-11 medium not scored

_usage_total adds input_tokens and output_tokens only (used at line 705) and the status shows it as 'Tokens' (line 349). Cache read and write tokens are left out, and the evaluator's own call (line 261) is never counted. It enforces nothing, so it only misreports; today, with no cache marks, only the evaluator is missing.

What to change
Add cache_read_input_tokens and cache_creation_input_tokens, and add the evaluator response's usage to the same total.

How to check the fix For one goal turn, the status total equals the sum of the usage of the main call and the evaluator call.

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-01 at s08_context_compact/code.py:554: Every chapter's agent loop resends the whole growing conversation on each turn with no cache_control mark anywhere in the repository, so on Anthropic nothing is ever read from the prompt cache. The compaction chapter teaches how to shrink context but never shows that the unchanged part of it can be reused at a tenth of the price.
2. LP-PC-02 at s15_integrated_harness/code.py:858: The capstone rebuilds its system prompt on every model call and writes the current time to the second into it. The prompt is therefore different on every call, so once cache marks exist the provider can reuse nothing after the time line: not the skills catalog, not the memory text, not the conversation.
3. LP-PC-02 at s09_memory/code.py:731: The memory records chosen for each new user request are written into the system prompt (build_system, lines 353-354, used at line 731; the same in s15 lines 863-864). The system prompt then changes on every new request, so the whole earlier conversation is re-priced at its first call. Issue 311 reported this in May and PR 312 moved the records into the user turn; the current tree has them in the system prompt again.
4. LP-GE-06 at s15_integrated_harness/code.py:3184: The capstone's loop calls update_context on every cycle (line 3184), and that runs the s09 memory selection (s09 lines 285-310), which is a separate model call. The inputs are the same user text on every tool turn, so one request with six tool turns asks the model the same question six times. In s09 the same call runs once per request.

Other problems found (check each against the code first; not scored):
- A compaction summary cut at 2,000 tokens replaces the whole history (s08_context_compact/code.py:486) [LP-GE-12]: summarize_history asks for at most 2,000 tokens and never reads stop_reason. A summary that stopped at the limit becomes the entire conversation (compact_history, line 504) and is trusted as complete. The same pattern is at s15_integrated_harness/code.py line 2205. Change: Read response.stop_reason; on max_tokens, ask again with a higher limit or keep the old messages instead of replacing them.
- s15 compaction summarises the oldest 80,000 characters and drops the newest (s15_integrated_harness/code.py:2193): summarize_history cuts the JSON with [:80000], which keeps the start of the conversation. When history is longer than that, the newest turns, which hold the current state, are not summarised and not marked as omitted. Issue 109 reported the same cut in the old chapter; agents/s06_context_compact.py:118 and agents/s_full.py:255 use [-80000:], and s08_context_compact/code.py:469-475 keeps head and tail with a marker. Change: Use the s08 approach: keep a head, a tail and an 'omitted' marker, or summarise only the older part and keep the newest messages.
- The goal loop's token counter reads two usage fields and skips the evaluator (s17_goal_loop/code.py:120) [LP-GE-11]: _usage_total adds input_tokens and output_tokens only (used at line 705) and the status shows it as 'Tokens' (line 349). Cache read and write tokens are left out, and the evaluator's own call (line 261) is never counted. It enforces nothing, so it only misreports; today, with no cache marks, only the evaluator is missing. Change: Add cache_read_input_tokens and cache_creation_input_tokens, and add the evaluator response's usage to the same total.

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).

47static
E, prefill reuse
0.14
S, prefix stability
1.00
G, generation waste
0.03
Default shares
0 of 4

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.