How to Save Tokens by Changing Claude Code and Codex Settings
Key point
This summarizes ways to reduce token waste by adjusting settings in Claude Code and Codex.
Details
Prompted by the felt increase in token usage since Claude Opus 4.7 and related community issues, this summarizes settings in Claude Code and Codex CLI that can actually improve token efficiency.
There are three key perspectives.
- Reducing extra prompts that get automatically attached to every session
- Limiting long tool outputs that accumulate in conversation history
- Reducing external calls such as search, connectors, and IDE integration
Claude Code
The last version checked was 2.1.114, and the following settings are summarized as effective for saving tokens.
includeGitInstructions: falseautoConnectIde: falseCLAUDE_CODE_GLOB_NO_IGNORE=false- Setting output caps with
BASH_MAX_OUTPUT_LENGTH,CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS,MAX_MCP_OUTPUT_TOKENS - A combination of environment variables and flags for non-interactive tasks
In particular, the following options carry significant weight in practice.
ENABLE_CLAUDEAI_MCP_SERVERS=false: disable MCP serversCLAUDE_CODE_DISABLE_AUTO_MEMORY=1: prevent auto memory loadingCLAUDE_CODE_DISABLE_CLAUDE_MDS=1: ignore global/projectCLAUDE.mdCLAUDE_AGENT_SDK_DISABLE_BUILTIN_AGENTS=1: exclude built-in subagent and skill definitions--tools: selectively enable only the tools you need--strict-mcp-config: use only the MCP explicitly specified on the CLI--disable-slash-commands: remove slash command definitions--no-session-persistence: block session save/resume paths--exclude-dynamic-system-prompt-sections: exclude variable sections to improve cache reuse rate--system-prompt: allows replacing the system prompt itself
Also, leaving attribution empty is presented as another point of savings.
Codex CLI
The last version checked was 0.121.0, and by also analyzing that version's GitHub source code, the following is summarized.
- Turning off ChatGPT-connected MCP (apps/connectors):
features.apps = false web_search = "disabled"- Setting output caps with
tool_output_token_limit - A combination of flags for non-interactive mode
Flags that are useful in practice include the following.
--profile: bundle and reuse settings likeweb_search,tool_output_token_limit--json+--output-last-message FILE: reduce token re-consumption during pipeline post-processing--sandbox read-only: prevent retry loops after write failures--skip-git-repo-check: bypass trusted directory restrictions--ephemeral: don't save session files to disk--color never: clean up piped output
In conclusion, going beyond simply adjusting the model or reasoning level, addressing default connections, memory, system prompts, tool output, and session persistence can achieve noticeable token savings and improved boot speed.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.