Contents
In the reported measurements, a scheduled claude -p "ok" call consumed 39,968 input tokens. Adding --safe-mode, disabling tools, and replacing the system prompt reduced that by 98%, to 737 tokens.
Key Takeaways#
- Even a two-character prompt can load tens of thousands of tokens from settings, hooks, tool definitions, and the default system prompt.
--safe-modeand--tools ""reduced measured input usage by 93%; replacing the system prompt as well brought the reduction to 98%.--settings '{}'had no effect because it does not override any settings.- These results come from an authentication check using a fixed response. Jobs that perform actual work need tools and instructions suited to their purpose.
What Was Consuming 40,000 Tokens?#
This job periodically called claude -p "ok" from a macOS LaunchAgent to check that authentication still worked. The response content did not matter. Yet every response began with a message from a personal SessionStart hook saying that Obsidian notes had been loaded.
This short prompt inherited the interactive environment. Before Claude answered, personal instructions, hook content, skills, plugins, and MCP settings were added to the context. Built-in tool definitions and the default system prompt were also included.
The measurements show where reductions were possible. These results reflect one particular configuration; token counts will vary across environments.
| Invocation | Input tokens | Reduction | |---|---:|---:| | Standard claude -p "ok" | 39,968 | — | | Add --settings '{}' | 39,968 | 0% | | Add --safe-mode to the baseline command | 16,798 | 58% | | Also add --tools "" | 2,931 | 93% | | Also replace the system prompt | 737 | 98% |
Use a Minimal Invocation#
For a job whose sole purpose is to successfully receive a fixed response, the final command tested was:
claude -p "ok" \
--model haiku \
--safe-mode \
--tools "" \
--system-prompt "Reply with exactly: OK" \
--effort low \
--no-session-persistence \
< /dev/nullAt four calls per day, the measured input totals amount to roughly 1.12 million tokens per week for the baseline command and 20,636 tokens for the optimized command. These figures describe input volume, not estimated costs. Cached tokens and subscription usage require separate interpretation.
The final options address output and unattended execution. In this test, --effort low reduced thinking tokens from 102 to zero, leaving only four output tokens. Redirecting standard input from /dev/null avoided a three-second wait and a warning that could contaminate captured results when standard error and standard output were combined.
What Each Flag Removes#
--safe-mode skips personal and project context, including CLAUDE.md, hooks, skills, plugins, MCP servers, custom commands, agents, and automatic memory. According to the documentation, authentication, model selection, built-in tools, and permissions remain available. In this environment, it removed about 23,000 input tokens.
--tools "" disables built-in tools, removing another roughly 13,900 tokens. For jobs that need file access, explicitly select the required tools, for example with --tools "Read". This flag does not disable MCP tools. In the tested command, safe mode excluded MCP.
--system-prompt replaces the default system prompt, removing another roughly 2,200 tokens in this case. It also removes the default tool-use guidance and safety instructions. Limit this replacement to narrowly scoped calls, such as returning a fixed “OK.” Jobs that read files or make decisions need appropriate instructions.
Check Authentication and Version#
--settings '{}' does not reset settings. It overrides only the specified keys, so an empty object leaves existing settings intact. That is why the measured token count remained at 39,968.
--bare has separate authentication constraints. The tested CLI’s help specified ANTHROPIC_API_KEY or apiKeyHelper, excluding OAuth and keychain authentication. Passing CLAUDE_CODE_OAUTH_TOKEN also failed. Using a separate CLAUDE_CONFIG_DIR likewise required separate authentication in that directory.
Safe mode is described as a troubleshooting feature. Before using it in automation, check the help for your installed version and verify the command in the scheduler’s actual environment. A successful invocation shows that a request to the selected model worked, but does not guarantee that all interactive features are available.
Measure Input in Your Own Environment#
Output JSON and add together regular input, cache creation, and cache reads. Including all three measures the amount of input context processed, even when some comes from the cache.
claude -p "ok" --output-format json < /dev/null |
jq '.usage |
.input_tokens +
.cache_creation_input_tokens +
.cache_read_input_tokens'Run the baseline command first, then add each optimization one at a time. Use the same working directory and authentication environment as the scheduled job. The reported measurements used a nearly empty environment and an empty temporary directory to approximate unattended execution.
Next Steps#
Measure your existing scheduled command and the command with minimal flags once each, and record both totals along with the Claude Code version.
Source: https://zenn.dev/yosiki/articles/claude-p-cron-token-diet
Contents
