# AI usage audit skill

> A free Claude skill that reads how your app calls AI, traces every call and writes one report: each token leak, its file and line, the cause and the fix.

- Canonical page: https://inspectedbymarko.com/skills/ai-usage-audit/
- Site: Inspected by Marko (https://inspectedbymarko.com/)
- Last updated: 20 November 2026

## Find where your tokens go.

Every AI call pays again for everything it carries: the rules, the history, the tools. This free skill reads how your product calls AI, traces each call and writes one short report: every leak, its file and line, the cause and the fix.

- [Get the skill](https://inspectedbymarko.com/skills/ai-usage-audit/#free-skills)
- [See a sample report](https://inspectedbymarko.com/skills/ai-usage-audit/#report)

One skill · 84 checks · four scripts · free, MIT License

Handwritten under the buttons: “it reads your code. it never runs it.”

Receipt · One long chat (4 Nov 2026; Claude Code 2.1.311 · Sonnet 5.5 · medium). Eight short commit messages:

| Sent after | Tokens |
| --- | --- |
| Ticket 1 | 127,659 |
| Ticket 2 | 170,375 |
| Ticket 3 | 196,401 |
| Ticket 4 | 217,036 |
| Ticket 5 | 235,977 |
| Ticket 9 | 305,264 |
| Ticket 11 | 372,796 |
| Ticket 13 | 444,726 |

Messages: 8. Typed: 129 characters. Paid: 2,070,234 tokens. Every call sent the whole chat again. The pen circles 129 characters: “all that was typed.” Stamped: COUNTED, session files.

From video 03. One long Claude Code chat on 13 tickets, counted from its session files. Only the messages that asked for nothing but a commit. One run, n = 1.

On this page:
- [Why it grows](https://inspectedbymarko.com/skills/ai-usage-audit/#the-pile)
- [How it audits](https://inspectedbymarko.com/skills/ai-usage-audit/#the-trace)
- [A sample report](https://inspectedbymarko.com/skills/ai-usage-audit/#report)
- [Get the skill](https://inspectedbymarko.com/skills/ai-usage-audit/#free-skills)

## 01 Every new prompt pays for everything above it.

AI models keep nothing between calls. So every call sends the whole conversation again: the rules, the files, every earlier answer. That is why AI gets so expensive the longer you use it.

The pile · one page a turn (Sketch, not data). Turns in this chat:

| Turns in this chat | Pages sent | Pages written | Sent for each page written |
| --- | --- | --- | --- |
| 1 | 1 | 1 | 1× |
| 5 | 15 | 5 | 3× |
| 10 | 55 | 10 | 5.5× |
| 20 | 210 | 20 | 10.5× |
| 40 | 820 | 40 | 20.5× |

“a 10-turn session sends the first page 10 times” (From the skill’s severity guide). A sketch: every turn adds one page and nothing is trimmed. Real calls also carry the system prompt, the tool list and files. Caching makes old pages cheaper. They still count as tokens.

Handwritten on the sheet: “the last turn carries all the others.”

What I measured:

- Receipt · Calls nobody typed (4 Nov 2026): **4.4M of 18M tokens**. In one long Claude Code chat, 4.4 million tokens went to calls nobody typed. It sent prompt suggestions and session recaps on its own. Source: My own test, video 03: the long chat’s session files.
- Receipt · Skills on every call (5 Nov 2026): **Up to 83 skills**. In my first build, up to 83 skills were listed on every call. The build never used them: about 1.5 million tokens. Source: My own test, video 03: build 1’s session files.

Handwritten: “you’re paying for it in every single prompt.”

> “Two tokens do not cost the same.”

From video 03. My second build used about 6 times fewer tokens than the long chat. Its bill was 9% lower.

- Receipt · Price by kind (Checked 17 Nov 2026): **1 · 20 · 40 · 100**. A cache read, input, a one-hour cache write and output, as ratios at Sonnet 5.5 list prices. What the model writes costs 100 times what it reads from the cache. Source: [Anthropic, Claude Platform Docs, Pricing](https://platform.claude.com/docs/en/about-claude/pricing).

## 02 The leak is rarely in the call itself.

It sits in the chain around it: what triggers the call, what gets stuffed into it, what happens to the answer. So the skill finds every AI call in your code and follows each one end to end.

Example. Not a client’s code. `src/app/api/chat/route.ts`:

```ts
import OpenAI from 'openai';
import { retrieve } from '@/lib/retrieve';
import { RULES } from '@/lib/prompts/support-agent';

const client = new OpenAI();

export async function POST(req: Request) {
  const { message, customer } = await req.json();
  const chunks = await retrieve(message, { k: 25 });
  const system = [
    `Today is ${new Date().toISOString()}. Customer: ${customer.name}.`,
    RULES,
    ...chunks.map((c) => c.text),
  ].join('\n\n');

  const res = await client.chat.completions.create({
    model: 'gpt-4.1',
    n: 3,
    messages: [
      { role: 'system', content: system },
      { role: 'user', content: message },
    ],
  });
  return Response.json({ reply: res.choices[0].message.content });
}
```

Notes, in the pen:
1. line 9: “25 articles. every message.”
2. line 11: “the time goes first. no two prompts match.”
3. line 18: “three replies. line 24 shows one.”

What the skill’s scanner printed for this file (scan_ai_usage.py · 2 of its 6 leads · 17 Nov 2026):
- `src/app/api/chat/route.ts:16` asks for more than one output per call (n or candidate count): check how many are used.
- `src/app/api/chat/route.ts:11` puts the current date or time into text sent to the model: if that text sits before static content (or inside a cached block), it changes every request and defeats caching.

This is a map, not a verdict. Open every location and read the surrounding code before you conclude anything.

It never flagged line 9. The skill found that one by reading what goes into the prompt, piece by piece.

### Seven questions for every call

1. **Trigger.** What causes this call? A user message, a keystroke, a page load, a cron job.
2. **Frequency.** How often does that trigger fire? A call inside a loop runs once per item.
3. **Input.** What goes into the prompt, piece by piece, and about how many tokens is each?
4. **Settings.** Which model, output cap, reasoning effort, caching and service tier?
5. **Output.** What happens to the answer? How much of it is actually used?
6. **Failure handling.** What do retries, fallbacks and parse-failure loops run again?
7. **Repeats.** Is the same input sent more than once per user action?

From the skill’s discovery guide.

### 84 checks, in four catalogs.

**Calls and models**, 23 checks (`checks-calls-and-models.md`). When and how often the model is called, model choice, output and reasoning settings, spend visibility.
- CAL-07: Work nobody waits for runs synchronously at full price instead of a batch API
- CAL-06: Retry loops re-run the whole call: on parse failures, refusals, truncation or 400s, with no cap or backoff
- CAL-16: Output is longer than the product uses: no length or verbosity setting, explanations or reasoning written into an answer that is thrown away

**Context**, 21 checks (`checks-context.md`). What goes into each call: prompt caching, prompt size, history, retrieval, tools and agent loops, images.
- CTX-A01: Changing text sits ahead of the stable part of the prompt, so the prefix cache never hits
- CTX-C01: The whole history is re-sent every turn with no trimming, compaction, context editing or memory
- CTX-E01: Every tool and MCP definition is sent on every request, though each turn uses a few

**Prompts**, 28 checks (`checks-prompts.md`). Prompting quality, and the reliability and security problems that come from how prompts and outputs are handled.
- PRM-A01: The prompt never says what to return: format, length, audience, final-answer shape
- PRM-B01: Scaffolding written for an older model is still in the prompt
- PRM-F01: Output is trusted once it parses: values, refusals, truncation and enum casing go unchecked

**Dev setup**, 12 checks (`checks-dev-setup.md`). The AI instruction files and MCP configs your team’s coding agents load. Only when the repo has them.
- DEV-01: Always-loaded instruction files exceed the tool’s size guidance or hold material most sessions never use
- DEV-06: MCP servers and tool definitions load up front, including servers nobody uses
- DEV-11: Agent sessions run long across unrelated tasks, keep verbose output in context, or break the cache

Three of each, with their numbers. The zip has all 84.

**Before anything becomes a finding.**

> “A scanner hit or a catalog match is a lead. A finding is a claim you can defend.”

So it opens the code again, looks for whatever already handles the problem, and sizes it. Then a second pass has one job: prove the finding wrong. What survives partly is downgraded. What doesn’t is cut.

Looks like waste. Usually isn’t. The pen strikes all four:
- a high output cap (a cap, not a charge)
- a large model behind an eval-backed router
- caching a gateway already does
- a documented deliberate trade-off

## 03 One finding is one problem with its cause and its fix.

The top is for a founder: a verdict and the one thing to fix first. The findings are for a developer, or their AI coding tool: the file and line, the cause, the fix and how to confirm it worked.

### AI usage audit: Helpdesk AI

The sample report, laid out for this page. The skill’s own script rendered it from a made-up product, and its checker passed it: 0 errors, 0 warnings. File: `AI-Usage-Audit-Helpdesk-AI-2026-11-03.md`.

`AI USAGE AUDIT · HELPDESK AI · 3 NOV 2026 · 1 CRITICAL · 2 HIGH · 1 LOW`

**Most of the AI bill pays for text the model never uses. Every chat message carries about 50,000 tokens of help-center articles and asks for three replies while showing one.**

If you fix one thing, fix F-001: every chat message carries 25 help-center articles.

| Project | Date | AI in use | Checked by | Tool |
| --- | --- | --- | --- | --- |
| `helpdesk-ai` | 3 November 2026 | gpt-4.1 | The AI, against the code. Not yet by a person | AI usage audit skill 1.0.0 |

A support desk that drafts replies to customer messages from help-center articles. 7 AI calls across 5 features.

**What holds up.** The parts that are done right. Keep them through every fix.
1. Replies come back in a fixed schema and are validated in code before they are saved (src/lib/reply-schema.ts).
2. Token use is logged per feature, so each fix can be confirmed (src/lib/usage-log.ts).

**Fix order.**

| ID | Severity | Finding | Effort | Impact |
| --- | --- | --- | --- | --- |
| F-001 | Critical | Every chat message carries 25 help-center articles | Medium | About 50,000 tokens on every chat message, about nine tenths of its input. |
| F-002 | High | A timestamp at the top of the chat prompt blocks the caching discount | Small | 1,800 rule tokens at full price on every chat message. |
| F-003 | High | The chat makes three replies and throws two away | Small | Two of every three replies are paid for and never shown. |
| F-004 | Low | The weekly admin report sends 2,000 tokens it never uses | Small | 2,000 extra tokens once a week. |

**F-001 · Every chat message carries 25 help-center articles** (`CRITICAL · MEDIUM FIX`)
- Impact: About 50,000 tokens on every chat message, about nine tenths of its input.
- Where: `src/app/api/chat/route.ts:9`
- Issue: Every chat message sends 25 retrieved chunks (pieces of help-center text) of about 2,000 tokens each, whatever the question.
- Cause: The retrieval step (the lookup that finds help-center text for a question) returns its top 25 matches, and all of them go into the prompt.
- Fix: Retrieve fewer and smaller chunks. Add a reranker (a second pass that orders the matches) so the few that are sent are the right ones. Compare answer quality on a sample of real questions before and after.
- How to confirm: Input tokens per message drop from about 55,000 to under 10,000 in the usage dashboard.

**F-002 · A timestamp at the top of the chat prompt blocks the caching discount** (`HIGH · SMALL FIX`)
- Impact: 1,800 rule tokens at full price on every chat message.
- Where: `src/app/api/chat/route.ts:11`
- Issue: Every chat message re-sends the same 1,800-token rulebook at full price.
- Cause: OpenAI charges much less for prompt text it saw recently (prompt caching), but only when the prompt starts with exactly the same text. This prompt starts with the current time and the customer’s name, so no two requests match.
- Fix: Put the static rules first. Move the time, the customer details and the help-center articles to the end, or into the user message.
- How to confirm: From the second message on, the usage field shows cached tokens close to 1,800.

**F-003 · The chat makes three replies and throws two away** (`HIGH · SMALL FIX`)
- Impact: Two of every three replies are paid for and never shown.
- Where: `src/app/api/chat/route.ts:18`
- Issue: Each chat message asks the model for three replies. The widget shows the first one.
- Cause: The request sets n: 3, so the model writes three full answers for every message. What a model writes is the most expensive kind of token.
- Fix: Set n to 1 in the chat request. If support agents should pick between drafts, make extra drafts only when they ask.
- How to confirm: Output tokens per message fall to about a third in the usage dashboard.

**F-004 · The weekly admin report sends 2,000 tokens it never uses** (`LOW · SMALL FIX`)
- Impact: 2,000 extra tokens once a week.
- Where: `src/jobs/weekly-report.ts:12`
- Issue: The weekly report prompt still carries an example table from an earlier format.
- Cause: The table was never removed when the format changed.
- Fix: Delete the example table from the prompt.

**Worth testing.** Ideas that may help but are not proven problems here. Try a smaller model on ticket tagging. Keep it only if it tags 200 real tickets as well as the current one.

**Not checked.**
1. Cache hit rates at run time: the provider’s usage dashboard shows them.
2. Prompts stored in the database: not in the repository.

An AI read the source code. Nothing in the project was run: no AI calls, no builds, no requests to a live app.

**Fix it with your AI tool.** Paste this into the AI coding tool you use on this repository.

```text
Read AI-Usage-Audit-Helpdesk-AI-2026-11-03.md in this repository. Fix its findings in the Fix order, one at a time, starting with F-001. Leave Low findings until the rest are done.
For each finding:
1. Say in one sentence what you will change.
2. Make the smallest change that does what its Fix says.
3. Check it the way its "How to confirm" line says, or add a test that shows it.
4. Show me the diff and wait for my OK before the next finding.
Do not change prompts, models or settings a finding does not mention. If a fix changes what users see or which model answers, stop and ask me first. Never paste an API key into the chat.
```

The report's last line: “Made with the free AI usage audit skill from Inspected by Marko”

### What every report holds

1. **The verdict.** Two sentences, and the one thing to fix first.
2. **What holds up.** The parts done right, so nobody breaks them while fixing the rest.
3. **Fix order.** One table to schedule the work.
4. **Findings.** Impact, where, issue, cause and fix. The serious ones say how to confirm it.
5. **Worth testing.** Ideas that are not proven problems, kept apart from the findings.
6. **How it was done.** What was read, what was assumed, what was not checked.
7. **A fix prompt.** To paste into your AI coding tool, one finding at a time.

### Severity follows real impact

- **Critical:** 25% or more of AI spend, or waste that grows without limit
- **High:** 10% to 25% of spend, or a core feature regularly worse
- **Medium:** 3% to 10%, or a secondary feature
- **Low:** Under 3%, or hygiene

Its last line says which skill made it. A short note about a 20-minute call shows only when it found a Critical or High issue. It’s your report: delete either.

Handwritten: “good work gets credit. nothing is invented.”

## 04 Get the skill: Want to know where yours go?

One skill, nine guides and four scripts, in one zip. Open your project and ask where it wastes tokens. It reads the code, never runs it, and writes one report. Read every file before you run it. I would.

```text
ai-usage-audit-skill.zip
└─ inspected-by-m-ai-usage-audit/
   ├─ LICENSE  (MIT, word for word)
   ├─ README.md  (how to install and use it)
   ├─ SKILL.md  (the method and the workflow)
   ├─ references/  (9 guides)
   │  ├─ discovery.md  (finding and tracing every call)
   │  ├─ checks-calls-and-models.md  (23 checks)
   │  ├─ checks-context.md  (21 checks)
   │  ├─ checks-prompts.md  (28 checks)
   │  ├─ checks-dev-setup.md  (12 checks)
   │  ├─ vendor-facts.md  (dated prices and limits)
   │  ├─ severity.md  (how a leak is sized)
   │  ├─ report-spec.md  (what the report holds)
   │  └─ brand-and-help.md  (what it says about me)
   ├─ assets/
   │  └─ brand.json  (the credit line, the note)
   └─ scripts/  (Python 3)
      ├─ scan_ai_usage.py  (maps every AI call)
      ├─ estimate.py  (token and cost arithmetic)
      ├─ render_report.py  (writes the report)
      └─ check_report.py  (checks the report)
```

- **Works in:** Claude Code, or the Claude app with code execution on. With web search on, it checks prices on the vendor’s own page.
- **Needs:** Your code, or at least the prompts and call settings. Python 3 for the four scripts.
- **Never:** Runs your code: no installs, no builds, no AI calls, no requests to a live app.
- **Yours to:** Copy, change and share, under the MIT License.

How to get it: enter your email in the form on the page, “Get the audit skill.” ([Email me the skill](https://inspectedbymarko.com/skills/ai-usage-audit/#free-skills)). The zip comes by email (inspected-by-m-ai-usage-audit 1.0.0, 17 November 2026).

Free to copy, change and share, under the MIT License. It comes with no warranty: read a skill before you run it.

Box not ticked? You get the skill and nothing else, and your address is deleted after 30 days.

[How I use your email](https://inspectedbymarko.com/privacy/#what-we-collect)

## 05 Work with me: Your AI bill is in order. Are its answers?

If your product has paying customers and you want AI added to it, or the AI in it fixed, me and my team build it. Week one is a working prototype on a sample of your data, for $7,000. You try it, then you decide on the build.

- **Week one: the prototype:** $7,000 (USD · fixed price). A working prototype on a sample of your data. [See what week one includes](https://inspectedbymarko.com/work-with-me/#scope)
- **The build:** from $45,000
- **Monthly:** from $4,500 a month
- [See how it works](https://inspectedbymarko.com/work-with-me/#how-it-works)
- [Book a 20-minute call](https://inspectedbymarko.com/call/): Free, 20 minutes. For software companies with paying customers.
- [Not ready? Watch the videos on YouTube](https://www.youtube.com/@InspectedByMarkoEnglish)

---

Provider and data controller: OneCodeToRuleAll d.o.o. (OCTRA) · Seat: Sinđelićeva 6, 19000 Zaječar, Serbia · Registered with the Serbian Business Registers Agency, no. 21564516 · Tax ID (PIB) 111898813 · marko@inspectedbymarko.com
