Cost and usage awareness

Claude Code · Practical · 10 min

Every message resends the whole context, so habits, not just prices, decide what a session costs.

Claude Code is billed by tokens, the pieces of text the model reads and writes. On a subscription you draw on plan limits; with an API key or cloud provider you pay per token. Either way, the same habits keep usage down. (Prices and limits change, so check your plan rather than memorizing numbers.)

The key fact: each request carries the whole conversation. A one-line question in a session that has been open all day still pays for the full history. Prompt caching makes re-reading cheaper, but a long pause can let the cache expire.

Tracking:

  • /usage (alias /cost) shows the session's token use and a cost estimate; on subscription plans it also shows plan limits and what is consuming them.
  • /context shows how full the window is and why.
  • In scripts, claude -p --output-format json returns a cost estimate in its output.

Reducing:

  • /clear between unrelated tasks; it costs nothing. /compact itself is a large request.
  • Choose the model: a smaller, faster model handles most coding work; reserve the strongest for hard reasoning. /model switches; /effort lowers how much thinking the model does on simple tasks.
  • Write specific prompts. "improve this codebase" triggers broad scanning; naming the file and function does not.
  • Keep CLAUDE.md short; move occasional workflows into skills, which load on demand.
  • Disable MCP servers you are not using; prefer CLIs like gh.
  • Push noisy work (test runs, log digging) into subagents so only a summary returns.
  • Use plan mode for complex work: re-doing a wrong implementation is the most expensive outcome.

Parallel sessions, scheduled loops and agent teams multiply usage, because each has its own context.

Example

> /usage
  Total cost:            $0.55        (estimate, list price)
  Usage by model:
     <model>:  1.2k input, 5.3k output, 940.0k cache read, 50.0k cache write
> /context            # what's in the window right now
> /model              # pick a lighter model for routine edits
> /effort low         # less thinking for a simple task
> /clear              # switching tasks: start clean (free)

Remember

  • Every request resends the context, so long sessions cost more per message
  • /usage and /context show where tokens go
  • Clear often, pick the right model and effort, and write specific prompts

Watch out for

  • Leaving a large session open across a long break, so the next message reprocesses everything without the cache.

Check yourself

  1. Which change most reduces cost for a day of unrelated small tasks?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: code.claude.com/docs/en/costs

Builds on

Unlocks

Nothing builds on this yet.