plugins/claude-code-expert/archive/v7.6.0/skills/session-analytics/SKILL.md
Understanding and optimizing Claude Code session performance — token tracking, bottleneck identification, caching behavior, and cost estimation
npx skillsauth add markus41/claude session-analyticsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Understand where tokens go, identify waste, and optimize Claude Code sessions for cost and speed.
Give users the tools to measure, understand, and improve the efficiency of their Claude Code sessions.
Run /cost in any session to see:
Input tokens: 145,230
Output tokens: 28,450
Cache read tokens: 89,100 (cheaper — 10% of input price)
Cache write tokens: 12,400 (25% more than input price)
Total estimated cost: $0.87
| Category | What it represents | Cost relative to input | |----------|-------------------|----------------------:| | Input tokens | New content sent to the model each turn | 1.0x | | Output tokens | Content the model generates | 5.0x (Opus/Sonnet) | | Cache read | Content matched from prompt cache | 0.1x | | Cache write | Content added to prompt cache | 1.25x |
Cache reads are your best friend — they're 10x cheaper than fresh input tokens.
Each turn sends:
The conversation history is the main cost driver. It grows monotonically until /compact.
| Pattern | Symptom | Fix |
|---------|---------|-----|
| Repeated file reads | Same file in tool calls 3+ times | Read once, reference from memory |
| Over-broad Bash output | ls -R or cat on large files | Use Glob/Grep with limits |
| Unnecessary subagent spawning | Subagent for trivial lookup | Direct tool call instead |
| Large tool output | Bash command returns 500+ lines | Pipe through head or tail |
| Context thrashing | /compact then immediately re-read same files | Better anchor planning |
| Wrong model tier | Opus for file search | Switch to Haiku for lookups |
From most to least expensive per call (typical):
Good efficiency indicators:
Claude Code automatically caches the following between turns:
Cache hits occur when the same content prefix appears in consecutive turns. This means:
These actions invalidate the cache:
/compact — rewrites conversation historyEstimate cost using these heuristics:
| Task Type | Model | Typical Turns | Typical Cost | |-----------|-------|-------------:|-------------:| | Quick bug fix | Sonnet | 5-10 | $0.10-0.30 | | Feature implementation | Sonnet | 15-30 | $0.50-2.00 | | Large refactor | Sonnet | 30-60 | $2.00-5.00 | | Architecture analysis | Opus | 10-20 | $3.00-8.00 | | Code review (council) | Mixed | 20-40 | $3.00-10.00 | | Research task | Haiku | 5-15 | $0.02-0.10 |
| File Type | Avg Tokens/Line | 100-Line File | |-----------|----------------:|--------------:| | TypeScript | ~10 | ~1,000 | | Python | ~8 | ~800 | | JSON | ~6 | ~600 | | Markdown | ~5 | ~500 | | YAML | ~5 | ~500 |
Ordered by impact:
head, tail, --limit on commandsFor teams and repeat workflows:
| Metric | Formula | Target | |--------|---------|--------| | Cost per commit | total session cost / commits produced | < $1.00 | | Context efficiency | useful output tokens / total input tokens | > 15% | | Cache hit rate | cache read tokens / total input tokens | > 50% | | Tokens per task | total tokens / tasks completed | decreasing over time |
/cost periodicallytools
Build Teams-native agents with the Teams SDK (formerly Teams AI Library v2) — App class, activity routing, adaptive cards, streaming, AI-generated labels, feedback, message extensions, Teams-as-MCP-server, and the bring-your-own-AI pattern with Agent Framework.
tools
Run agents on Microsoft Foundry (formerly Azure AI Foundry) Agent Service — prompt agents vs hosted agents, threads/runs and the Responses API, built-in tools (Bing grounding, code interpreter, file search, MCP, OpenAPI, A2A), connected agents, Entra agent identity, SDKs, and observability/evaluations.
tools
Build and host custom engine agents with the Microsoft 365 Agents SDK — AgentApplication, the Activity protocol, channel reach via Azure Bot Service, hosting Agent Framework or Semantic Kernel engines, and the Agents Toolkit/Playground workflow. Successor to the Bot Framework SDK.
tools
Design, govern, and extend Microsoft Copilot Studio agents — topics, generative orchestration, knowledge, tools and MCP, agent flows, autonomous triggers, publishing channels, Copilot Credits pricing, and solution-based ALM on Power Platform.