AI อะไรเนี่ย
Claude

Claude Code Guide: Master 1M Context & Sessions with New `/usage` Command

Tools

Claude Code Guide: Master 1M Context & Sessions with New /usage Command

TL;DR

  • Claude Code now features a 1 million token context window, enabling complex tasks like full-stack development.
  • A new /usage command helps users monitor their token consumption within sessions.
  • Users must manage context rot, where performance degrades with growing context, through strategies like compaction.
  • Session management options include /rewind, /clear, Compact, and using Subagents for cleaner contexts.

Anthropic has released a practical guide for effectively leveraging Claude Code's impressive 1 million token context window. This expanded capacity allows developers to tackle significantly larger and more complex projects, such as building full-stack applications from the ground up, with greater reliability. To help users understand and optimize their interactions, a new slash command, /usage, has been introduced in Claude Code, providing immediate insights into current token consumption. This feature is crucial for managing the larger context window efficiently, as detailed in the comprehensive guide on Using Claude Code: Session Management and 1M Context.

Despite the massive context window, a phenomenon known as context rot can still impact model performance. This occurs as the context grows, spreading the model's attention across more tokens and potentially distracting it with older, irrelevant information. To combat this, Claude Code employs compaction. This process automatically summarizes the ongoing task into a smaller, more focused description when the context window approaches its limit, allowing the model to continue its work in a fresh context. Users can also trigger compaction manually to condense their session history and maintain focus, a technique further elaborated in the Build with Claude: Compaction Documentation.

Effective session management is paramount to making the most of Claude Code. Users have several powerful options to control their sessions. Beyond simply continuing a conversation, they can use /rewind to jump back to a previous message and re-prompt, effectively discarding later interactions and refining their approach. For entirely new tasks, the general rule of thumb is to use /clear to start a fresh session, preventing previous context from interfering. Alternatively, to delegate specific parts of a task, Subagents can be employed, providing a clean, isolated context for specialized work. Anthropic provides further insights into these strategies on their Claude Code Blog Category, including dedicated posts like Subagents in Claude Code Blog Post and the Claude Code: Sub-agents Documentation for in-depth understanding.

Summary

  • Claude Code now supports a 1 million token context window for more reliable and extensive development tasks.
  • The new /usage command helps users monitor and manage their token consumption effectively.
  • Combat context rot through automatic or manual compaction to maintain model performance and focus.
  • Strategic session management using /rewind, /clear, Compact, or Subagents is key to optimizing interactions and workflow.

Source: Using Claude Code: session management and 1M context