Repository navigation
perf(cli): speed up generation via direct spawn and settings isolation - #18
Merged
Merged
Conversation
Run the CLI directly via spawn instead of a login shell with temp files; the prompt is fed through stdin and never touches disk. Add --setting-sources "" and --strict-mcp-config so the user's global CLAUDE.md/rules, hooks and MCP servers are not loaded into every call (they slowed generation several times over and polluted the output). Disable the startup update check and telemetry (DISABLE_AUTOUPDATER, CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC).
--strict-mcp-config and --setting-sources are not known to older Claude CLI releases and would fail with "unknown option" where the extension previously worked. Probe once per session: on an unknown-option error retry without the isolation flags and remember the result, so old CLIs pay the extra spawn only on the first generation. Other errors still propagate unchanged.
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.
Problem
Commit message generation through the Claude CLI is slow — and for anyone with a customized Claude Code setup (global CLAUDE.md/rules, hooks, MCP servers) it is also unreliable, because the CLI loads the user's entire global configuration on every invocation:
Stophooks add a whole extra model turn;Measured on macOS with haiku:
Changes
spawn, feeding the prompt through stdin — no login shell, nocat, no temp files. The diff never touches disk anymore, so the privacy guarantee thatprivacyModeapproximated with file permissions now always holds for the CLI path.--setting-sources ""and--strict-mcp-configso user/project settings, rules, hooks and MCP servers stay out of generation. Subscription auth is unaffected.DISABLE_AUTOUPDATER=1andCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1for the spawned process.unknown optionerror the call is retried without them and the result is remembered for the session, so old CLIs keep working and pay the extra probe only on the first generation. Other errors propagate unchanged.Notes for review
.cmdwrapper via shell; system prompt still skipped there, as before) is logically equivalent to the previous code but I could not test it on a real Windows machine.