Reduce Claude Code token usage with /autocompact 400k
Lowering Claude Code’s auto-compact threshold to 400k tokens keeps conversation history smaller and can significantly reduce token consumption during long sessions.
If you use Claude Code, consider running /autocompact 400k when needed.
Auto-compact is designed to compress a long conversation history into a brief summary instead of endlessly storing millions of tokens of full history. In a model with a 1M-token context window, default compression triggers only around 967k tokens.
Because each sent message can include the full previous conversation history, waiting until 967k tokens means every subsequent request repeatedly consumes a huge number of tokens.
Even with effective caching, most historical context is read from cache at a lower price, and compression itself costs about one ordinary request. However, the large read volume still counts toward usage limits, and costs accumulate over time.
The /autocompact 400k command lowers the compression trigger threshold to 400k tokens in advance. As a result, conversation history stays compact and context does not grow uncontrollably within a single request. This can substantially reduce token spend during extended Claude Code work.
Why it matters
AnalysisControlling context compaction helps developers manage token budgets, reduce costs, and avoid hitting usage limits during long AI-assisted coding sessions.
Discuss in community
Share your questions and insights with developers
Related in Ecosystem
Practical guides, core terminology, and agent skills
Claude Code Projects: How a Single AI Orchestrates a Team of Autonomous Agents
A deep dive into Claude Code Projects: Coordinator and Threads architecture, parallel branches, shared memory via MEMORY.md, and cloud agent management.
Vibe Coding for Non-Developers: How Marketers, Designers, and PMs Build Products with Claude and Cursor
A practical guide to Vibe Coding without the terminal: 45 techniques for working in Claude and Cursor tailored for marketers, designers, and PMs. From website edits to routine automation.
AI Refactoring: Safely Refreshing Legacy Code Without Changing Its Logic
A methodology for improving the internal structure, readability, and performance of existing Legacy Code using language models without altering its external behavior. It enables breaking down large spaghetti functions into neat modules and converting old JavaScript to modern TypeScript.
Claude Code
The official terminal agent from Anthropic, operating directly in the command line via Claude 3.7 Sonnet with native support for Bash, Git, file systems, and the MCP protocol.
Claude Code adds variable to disable dangerous-command protections
Claude Code now includes an environment variable that can bypass even the safety blocks that remained active with --dangerously-skip-permissions.
Hackers can hijack Codex and Claude Code via malicious files in the Downloads folder
A plain text file in ~/Downloads can trick AI coding agents into changing settings, installing malware, or leaking authorization tokens, according to Forever Security.