Cost audit

From berkcangumusisik/claude-code-practices · View interactive version

Cost audit is an AI agent skill from the GitHub repository berkcangumusisik/claude-code-practices. Analyzes the current session's token usage, pinpoints where tokens were wasted, and produces concrete optimization actions

How to use this skill

Skill file

Goal

Make it visible where the tokens in this session actually went. Not guesses — evidence. Output: "do these 3 things next time and you save ~X%."

Step 1 — Capture current cost

/cost

Note the output: total tokens, input/output split, cache hit rate, total $.

Step 2 — Find the leaks

Scan the transcript for these signals:

| Signal | How to detect it | Why it wastes tokens |

|---|---|---|

| Unnecessary file reads | Read calls touching node_modules/, dist/, *.lock, coverage/ | Missing .claudeignore |

| Re-reading the same file | Same path appears in multiple Read calls | Context lost — /compact should have happened earlier |

| Reading entire large files | Read without limit on files >500 lines | Should have used offset/limit or Grep |

| Bash + grep/cat/find | Bash calls to grep, cat, find, ls -R | Dedicated tools (Grep/Glob/Read) are cheaper and more precise |

| Vague prompt → many tool calls | Single-word asks ("improve", "fix", "look") followed by 5+ tool calls | Prompt wasn't specific |

| Repeated onboarding research | Same concept re-discovered across sessions | Belongs in CLAUDE.md |

Step 3 — Report

Give the user a report in this shape:

## Session summary
- Total: <tokens> (<$>)
- Cache hit: <%>

## Top 3 leaks
1. [Evidence]: X files under src/components/ were read in full; ~Y tokens combined
   Fix: add to .claudeignore → <lines>
   Estimated savings: ~Z%

2. ...

3. ...

## Action list
- [ ] Create .claudeignore with <lines>
- [ ] Add a "<topic>" section to CLAUDE.md
- [ ] Use `/compact <hint>` earlier in long sessions

Step 4 — Optional auto-fixes

If the user approves:

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.