Repository navigation
fix(claude): isolate the account-usage query process with --safe-mode - #29
Merged
Merged
Conversation
The native get_usage reader spawned `claude -p` with the user's full configuration, so every usage read ran their SessionStart hooks and started their MCP servers (verified live on CLI 2.1.283, user- and project-level). --safe-mode disables those while keeping auth, and get_usage still answers. A CLI whose --help lacks --safe-mode is reported as unsupported_installation instead of being launched unisolated. Only a successful help probe is cached per command+version. Fixes #28 Co-Authored-By: Claude Opus 5.5 <[email protected]>
xxchan
added a commit
that referenced
this pull request
Sep 29, 2026
Upgrade Pi to 0.87.1 and pin undici to 8.10.2, matching the SDK dependency and removing the affected 8.9.0 version. Update the Pi system-prompt snapshot for its new tagged format and bump both packages to 0.9.0 for the release containing #27 and #29. Fixes #30. Validation: typecheck and lint pass; Pi behavior suite and strict CI-mode vendor snapshots pass. Full local suite encountered a process timing failure under heavy machine load; CI will validate on clean runners before release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #28. Reviewed on the Raft side by @XX, who asked for both points below.
Problem:
claudeAccountUsagespawnsclaude -p …with the user's full config. On CLI 2.1.283, every usage read ran the user'sSessionStarthook and started their MCP servers, at both user level (CLAUDE_CONFIG_DIR) and project level. The HTTP reader in 0.0.7 had no such side effect.Change
--safe-modeto the query process. It disables hooks, MCP servers, plugins and CLAUDE.md while keeping auth, andinitialize/get_usageanswer as before.claude --helpdoesn't list--safe-mode, return{ kind: "unsupported", reason: "unsupported_installation" }. The reader never launches the CLI without isolation. The help probe takes about 60 ms. Only a successful probe is cached (per command and version), so a transient probe failure is retried on the next read.--safe-modein the spawn args, check that an old CLI is never spawned, and check that a failed probe isn't cached. Removing the flag fails 1 test; skipping the support check fails 2.Verification
available, 3 windowsThe user-level runs return
quota_unavailableon both 0.8.0 and this branch; that comes from the empty temp config dir, not from this change.Should ship in the same release as #27 (Kimi nickname), so that Raft can upgrade once, from 0.0.7 straight to that version.
🤖 Generated with Claude Code