Anthropic Shares Six Habits for Maximizing Claude Code Sessions

Anthropic's new guide explains how prompt caching, model selection, and context hygiene change the real cost of every coding task — and why the same six habits apply to Codex and other agents.

cpaua3 min193
Anthropic Shares Six Habits for Maximizing Claude Code Sessions

Anthropic has published a guide on maximizing the value of Claude Code sessions, laying out six concrete habits that reduce token waste and keep the model focused on the actual task. The advice — clear context between tasks, pick model and effort level up front, @-mention files, silence noisy command output, audit startup context with /context, and /compact before long breaks — applies equally to Codex and nearly any agentic coding tool.

Why the same fix can cost different amounts

With traditional editors the price is flat; with agentic tools every turn carries a token bill. A single test fix might take a handful of turns if you point the model at the right file, or dozens of turns if it greps the repo, reads a dozen files, and drags all that history through every subsequent request. The model also has to "think around" irrelevant context on each turn, which degrades reasoning.

Three levers that set the price per token

The bill is driven by model size, input versus output tokens, and prompt caching. Larger models multiply every other cost. Output tokens — thinking, tool calls, visible text — run roughly 5× the price of input because decode keeps the GPU busy token by token. Prompt caching serves repeated prefixes at 0.1× the input price, but the cache key includes the model, effort level, and fast-mode flag; changing any of them mid-session forces a full re-prefill at full price.

Cache breaks you can avoid

  • /model or /effort switches invalidate the cache for the rest of the conversation.
  • Fast mode is part of the cache key; enable it at session start if you need it.
  • /compact rewrites the conversation, so the old cache no longer matches — cheap while the cache is warm, expensive after it expires.
  • Time: cache expires after an hour on subscriptions (five minutes on API keys unless ENABLE_PROMPT_CACHING_1H=1 is set). Resuming an old session usually rebuilds the system prompt from scratch.

Use /rewind instead of /compact when you only want to drop the last few turns; rewinding preserves the earlier cache at zero cost.

What inflates context and how to shrink it

Everything that enters the conversation — files read, command output — gets re-sent on every later turn. Cached re-sends are cheap but not free, and they occupy context the model must reason around. Two practical levers:

  • @-mention files (@utils.test.ts) instead of naming them. The file attaches to the first request, skipping a Read call and a search turn.
  • Quiet noisy commands with flags or run them in a subagent. Output over 30,000 characters is automatically written to a file and only a preview stays in context.

Run /context in a fresh session to see what loads before you type — tool definitions, system prompt, CLAUDE.md, MCP servers. Keep CLAUDE.md minimal; move workflow-specific instructions into skills that load on demand, and disable unused MCP servers with /mcp.

One session hygiene checklist

  1. /clear between unrelated tasks to drop irrelevant history.
  2. Pick /model and /effort once at the start.
  3. li>Reference files with @.
  4. Silence verbose commands or offload them.
  5. Audit startup context with /context.
  6. /compact before stepping away for more than an hour.

These habits transfer directly to Codex and other agents that share the same token economics. Teams adopting agentic workflows at scale may also want to audit usage patterns with tools like the AI Engineering Coach for VS Code.

Sources

Maximizing the value of your Claude Code sessions | Claude by Anthropic

Share

Author

cpaua

VibeCode blog admin. Writing about vibe coding, AI and open source.

Related news

Comments

To leave a comment, log in
Loading...

Weekly digest

The best of vibe coding, AI agents and open source — once a week, no spam.