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.
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=1is 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
/clearbetween unrelated tasks to drop irrelevant history.- Pick
/modeland/effortonce at the start. li>Reference files with - Silence verbose commands or offload them.
- Audit startup context with
/context. /compactbefore 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
Related news
- Claude CodeClaude Code cuts token usage by two-thirds after fixing context delivery with InsForgeA single backend change dropped Claude Code from 10.4M to 3.7M tokens, eliminated 10 errors, and cut cost from $9.21 to $2.81 — proving stronger models amplify context gaps instead of closing them.·shared tag: Claude Code
Claude CodeAnthropic Adds /checkup Command to Claude Code for Auto CleanupNew /checkup command in Claude Code automatically removes unused skills, splits CLAUDE.md files, enables Auto-mode, and pre-approves safe commands to reduce context bloat.·shared tag: Productivity
- Claude CodeClaude Code now finishes tasks before 5-hour limit cuts inAnthropic adds a grace reserve so sessions complete their current change instead of stopping mid-action.·shared tag: Productivity
- Claude CodeClaude Code plugin to catch security vulnerabilities during codingAnthropic released the security-guidance plugin for Claude Code to review code changes for common vulnerabilities and fix them in the same session.·shared tag: Anthropic
- AI AgentsClaude Code adds agent view for multi-session managementAnthropic introduces agent view in Claude Code, allowing developers to monitor and interact with multiple parallel agent sessions from a single CLI screen.·same source: claude.com
AnthropicAnthropic is introducing Claude Fable 5.2 and Mythos 5.2Anthropic releases Claude Fable 5.2 and Mythos 5.2, featuring 30% faster generation, lower API costs, and improved performance in agentic coding and scientific research.·shared tag: Anthropic
Comments
Weekly digest
The best of vibe coding, AI agents and open source — once a week, no spam.