You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
claude accountUsage spawns a full-config CLI: user hooks fire and MCP servers start on every usage read #28
What happens:claudeAccountUsage spawns claude -p --input-format stream-json --output-format stream-json --verbose --no-session-persistence with no option that limits which configuration is loaded. The child process therefore starts with the user's full configuration.
Repro (Claude Code 2.1.283, macOS): I set up a temporary project directory whose .claude/settings.json has a SessionStart hook, plus a .mcp.json server (with enableAllProjectMcpServers). Both write a marker file when they run. Then I ran claudeRuntime.accountUsage() from that directory.
OAR 0.8.0 as shipped: the SessionStart hook ran and the MCP server was started, and usage was returned.
The same control sequence (initialize then get_usage) with --safe-mode added: usage was still returned with the same shape (session, subscription_type, rate_limits_available, rate_limits, behaviors), and neither the hook nor the MCP server ran.
The 0.0.7 HTTP reader had no such side effect. With 0.8.0, every usage refresh now runs the user's hooks and starts their MCP servers.
Suggested fix: pass --safe-mode when spawning. Per claude --help, it disables CLAUDE.md, hooks, MCP servers and plugins while keeping auth. --bare is not an option, because it restricts auth to ANTHROPIC_API_KEY and skips keychain reads, which breaks OAuth subscriptions. Open question: I haven't checked which CLI version introduced --safe-mode. An older CLI may reject the flag, so the fix needs a fallback, such as retrying without the flag or gating on version.
Scope of what I tested: project-level hooks and MCP only. That user-level configuration is also disabled by --safe-mode comes from the help text; I didn't test it.
Activity
TennyZhuang commentedon Sep 29, 2026
Update after @XX's suggestion to test user-level config (
CLAUDE_CONFIG_DIRpointed at a temp dir, CLI 2.1.283):SessionStarthook ran in 4 of 4 reads.claude mcp listconfirmed the server config itself starts.--safe-mode: 3 of 3 reads returned usage, and neither the hook nor the MCP server ran.So both user-level and project-level config are affected, and
--safe-modeisolates both.fix(claude): isolate the account-usage query process with --safe-mode (…