Anthropic Shares Official Claude Code Tips to Save Tokens
TL;DR – Quick Summary
- Anthropic shares official best practices for Claude Code sessions, centered on context hygiene, session management, and effort calibration.
- A concise CLAUDE.md file seeds every session with essential project context automatically, reducing repeated explanations and token waste.
- Running Claude Code from the relevant subdirectory rather than the repository root limits irrelevant context from the first message.
- The /clear, /compact, and /resume commands give direct control over what stays in context and what gets dropped between tasks.
- Matching effort level to task complexity cuts token spend on routine work without sacrificing quality where deeper reasoning matters.
Anthropic has shared official tips for running Claude Code sessions efficiently, and the guidance centers on three practical levers: context hygiene, session management, and effort calibration. Claude Code is an agentic AI coding assistant from Anthropic that operates in your terminal, reading and editing files, running commands, and maintaining a context window that determines both response quality and session cost. Claude Code runs on models supporting context windows of up to 200,000 tokens, according to Anthropic’s model documentation, which means every irrelevant file, log dump, or stale conversation turn is real spend on noise. On large projects with broad file trees, that cost compounds quickly. Knowing what Anthropic recommends, drawn from its published engineering guidance, gives you a repeatable system to keep sessions lean from the first prompt. A context window functions as a fixed-size working memory for the model: the more it fills with low-value content, the less room remains for meaningful work.
The official guidance covers setup habits, mid-session hygiene, and configuration choices that affect both quality and cost. This article walks through each area with concrete steps you can apply immediately, whether you are new to Claude Code or have been running sessions for months.
Quick Takeaways
- Create a concise CLAUDE.md at your project root to seed every session with project structure, constraints, and conventions automatically.
- Run Claude Code from inside the most relevant subdirectory when your task is scoped to one part of the codebase.
- Use /clear when switching to an unrelated task and /compact when a long session grows unwieldy without losing continuity.
- Set a lower effort level for routine edits and reserve higher effort for tasks where reasoning depth changes output quality.
Where to Start: Official Setup Guidance
The first steps Anthropic recommends are environmental: start in the right directory, have your CLAUDE.md in place, and control what context Claude Code reads before the first prompt. These choices set the baseline token cost for everything that follows.
The official guidance specifically advises running Claude Code from the most relevant subdirectory when your task is scoped to one part of the project. Working on a payment module? Launch from inside it. The model sees a smaller file surface, and the context window fills with signal rather than a full repository tree. On a monorepo with dozens of packages, this single habit meaningfully reduces startup context on every session.
Prompt discipline matters equally. The official guidance cautions against including full log files, long diffs, or entire configuration files when only a specific section is relevant. A prompt that pulls a 300-line config file for a question about three fields pays for 297 lines of context that contribute nothing to the answer. Include what the task needs and nothing else.
These two behaviors, directory scoping and prompt focus, are treated as foundational in Anthropic’s documentation. They set a ceiling on session cost before any tool-level configuration enters the picture. Pairing them with efficient code generation habits extends that discipline from the environment level to the task level itself.
Use CLAUDE.md to Keep Context Focused
CLAUDE.md is a plain text file Claude Code reads automatically at the start of every session. Placing one at your project root is the single most effective setup step for context efficiency. The official guidance recommends keeping it concise: project structure, architectural constraints, naming conventions, and recurring context that would otherwise require manual pasting into every session’s opening message.
A well-written CLAUDE.md acts as a standing brief. Instead of explaining your stack, testing framework, and branch naming rules at the start of every session, you write them once and the file handles it. Opening prompts become cleaner, clarification rounds drop, and the context window starts with structured signal rather than improvised copy-pasting from a previous chat.
Keep the file short and high-signal. A CLAUDE.md that documents every dependency or edge case is no more useful than no file at all. The target is the details that, when absent, force repeated re-explanation: your directory layout, primary constraints, and the conventions Claude Code should follow by default. On monorepos, scope additional CLAUDE.md files to individual subdirectories for module-level context. Claude Code reads both the root and subdirectory files, giving each session the right specificity automatically.
Token-Saving Techniques from Official Guidance
Beyond initial setup, token savings come from active session habits. The methods Anthropic documents are consistent across its guidance: be selective about what enters a prompt, manage what accumulates in conversation history, and avoid letting sessions drift from their original scope.
File inclusion is the most common waste point. Claude Code can read any file you reference, but including a full module when you need one function means paying for the whole thing. Point the model at the specific function, class, or configuration block the task requires. This reduces per-message cost without changing any configuration or workflow step.
Conversation history compounds over time. Every exchange in a session carries the full prior context. Early messages that were useful for orientation become dead weight as work progresses. Anthropic’s Claude Code cost management guide addresses this directly: long sessions accumulate cost faster than actual work output grows. Managing session length with /compact or /clear is a cost control measure, not just a tidiness preference.
For teams managing spend across parallel agents or multiple sessions, Anthropic’s usage limit best practices cover rate limit behavior and team-level spending patterns worth reviewing alongside these session-level habits.
When to Clear, Compact, or Restart a Session
Three session commands run through Anthropic’s guidance: /clear resets context entirely, /compact compresses history while preserving the work thread, and /resume restores a previously named session. Knowing when to reach for each one prevents the most direct source of compounding costs: sessions that outlive their usefulness.
Use /clear when you switch to a task unrelated to the current session. Stale context does not just cost tokens; it can mislead the model by mixing in contradictory history. A session that started on a database migration and drifts into UI styling carries two different mental models simultaneously. Clear it and start clean for the new task.
Use /compact when the session is still relevant but has grown long. /compact produces a compressed summary of conversation history while preserving continuity. You lose some granularity but keep the thread intact. This is the right move mid-task when you are still making progress in the same direction.
Before clearing, rename the session if you may want to return to it. A session named “api-auth-refactor” can be restored with /resume later, picking up where you left off without reconstructing context from scratch. Anthropic treats this as a standard step for significant feature work, not an edge case.
How to Adjust Effort for Cheaper, Faster Runs
Effort controls how much extended thinking Claude applies before generating a response. The official documentation describes effort as one of the more underused dials available to Claude Code practitioners. Higher effort means more reasoning tokens and slower responses; lower effort produces faster, cheaper output for tasks that do not require deep deliberation.
The practical rule is to match effort to complexity. Fixing a typo, reformatting a function, or generating boilerplate from a clear spec does not require the same reasoning depth as debugging a non-deterministic race condition or designing an API contract. Running high effort on routine tasks pays for reasoning the model does not need to produce a correct result.
Anthropic’s effort documentation covers available settings and their implications. The default calibration handles most general coding tasks, but deliberate adjustment by task category produces measurable savings when session volume is high enough to compound.
| Effort Level | Best Task Type | Token Impact | When to Use It |
|---|---|---|---|
| Low | Typo fixes, reformats, boilerplate from clear specs | Lower | High-volume routine work where depth adds no value |
| Medium (default) | Feature implementation, standard debugging, code review | Moderate | Most everyday coding tasks |
| High | Architecture decisions, hard bugs, multi-step reasoning | Higher | Tasks where correctness justifies the extra cost |
Practical Application
Beginner: Before your next Claude Code session, create a CLAUDE.md at the project root with your stack, top-level directory layout, and two or three default conventions, then launch from the most task-relevant subdirectory rather than the repository root.
Intermediate: Add session hygiene to your daily workflow: name sessions at the start of significant feature work using /session rename, run /compact when a session has grown long and earlier context is no longer relevant, and use /clear when switching to unrelated tasks. Review the official Claude Code best practices page periodically to confirm your habits match Anthropic’s current guidance.
Advanced: Calibrate effort level by task category, using low effort for constrained generation tasks driven by a tight CLAUDE.md and raising it to high only for complex debugging or architectural decisions. Monitor actual spend over time to validate that effort adjustments produce real savings at your session volume, and refine your CLAUDE.md based on which clarification rounds still recur despite the file being present.
All of the official guidance returns to the same underlying principle: most Claude Code waste is environmental and habitual, not model-level. Fix the environment first and the sessions improve automatically.
| feature | /clear | /compact | /resume |
|---|---|---|---|
| drops context | ✓ | partial | – |
| keeps continuity | – | ✓ | ✓ |
| best for | unrelated new task | long unwieldy session | returning to prior task |
| token impact | full reset | reduces noise | reloads prior |
Frequently Asked Questions
Q: What are Anthropic’s official best practices for Claude Code sessions?
Anthropic’s official best practices focus on three areas: creating a concise CLAUDE.md to seed every session with project context, launching from the relevant subdirectory to limit irrelevant file scope, and managing session length with /clear and /compact to prevent stale context from accumulating and compounding cost over time.
Q: How can I save tokens while using Claude Code?
Keep prompts focused on exactly what the task needs, avoid dumping full logs or entire files when only a section is relevant, use /compact to compress long sessions rather than letting history grow unchecked, and set a lower effort level for routine work. Each of these reduces token cost without affecting output quality for the task at hand.
Q: When should I use /clear in Claude Code?
Use /clear when you pivot to a task unrelated to the current session. Stale context costs tokens and can mislead the model with contradictory history from a different task. Always rename the session before clearing if you may want to return to it later using the /resume command to restore full context.
Q: Why is CLAUDE.md important for Claude Code efficiency?
CLAUDE.md is read automatically at session start, seeding the context window with project-specific information without manual pasting. A concise, high-signal CLAUDE.md reduces clarification rounds, shortens opening prompts, and keeps the model oriented to your project’s conventions and constraints from the first exchange onward, compounding savings across every session.
Q: Which effort level is best for cost-sensitive Claude Code tasks?
Low effort suits high-volume, routine tasks such as reformatting, boilerplate generation, or simple edits where additional reasoning adds no value. Reserve medium or high effort for feature implementation, complex debugging, or architecture work where the quality difference from deeper reasoning genuinely justifies the additional token cost involved.