- Since 2.1.327, published 17 November, an interactive Claude Code session starts your login shell as soon as Claude begins its first Bash call. In my runs that was about 0.2 seconds before the permission prompt appeared.
- Refusing the command doesn't undo it. The shell also started when a deny rule or don't-ask mode refused the command without asking, and with the sandbox setting on it ran outside the sandbox.
claude -pstarted no early shell, and neither did a session with aPreToolUsehook on Bash.CLAUDE_CODE_DISABLE_SHELL_HEAD_START=1turns it off.
Entry 108 of the 173 in the 2.1.327 changelog starts with the word "Improved":
Improved the speed of a session's first Bash command: shell start-up files may now run before it's approved, even if it's refused; set
CLAUDE_CODE_DISABLE_SHELL_HEAD_START=1to turn this off
Some background. Claude Code doesn't read your .zshrc for every command. Once per session it starts your login shell, sources ~/.zshrc, and saves your aliases, functions and PATH to a snapshot file that every later command loads.
Up to 2.1.326 that happened when the first Bash command ran. I wrote earlier that this shell runs outside the sandbox, with the project as its working directory. The approval of the first command stood in front of it. I tested what is left of that.
What I ran
The native macOS binaries of 2.1.326 and 2.1.327, as interactive sessions in a pseudo-terminal. A script waits for the permission prompt, holds for a set number of seconds, then presses Enter or Esc. Haiku 5.5, default permission mode, project settings only, no MCP servers, and one prompt per session asking for touch build.marker.
To see shells start without editing my own startup files, I pointed $SHELL at a ten-line wrapper named zsh. It logs a timestamp, its arguments and whether it can create a file in my home directory, then hands over to /bin/zsh. Claude Code's --debug-file log was my second clock.
That came to 27 interactive sessions and 9 headless runs.
The shell starts before the prompt
One refused command on each version. Times are seconds after launch.
| Event | 2.1.326 | 2.1.327 |
|---|---|---|
Login shell starts (zsh -c -l, sources ~/.zshrc) |
never | 1.50 |
| Permission prompt on screen | 2.56 | 1.68 |
| Debug log: "Shell snapshot created successfully" | never | 3.16 |
| I press Esc | 8.58 | 7.69 |
touch runs |
never | never |
Three refusals on 2.1.327 gave the same order. In the 13 sessions where I could time both, the shell started 0.1 to 0.3 seconds before the prompt was on screen. On 2.1.326 nothing started until I said yes.
As far as I can read the minified code in the binary, the trigger is the first streamed piece of a Bash tool call. The command's text hasn't arrived at that point, so nothing about the command decides whether the shell starts.
A login zsh reads .zshenv, .zprofile and .zlogin by itself, and Claude Code's script sources .zshrc. A second shell, zsh -c env, starts at the same moment and reads .zshenv again. I ran the refusal once with bash as the shell and got the same result.
A rule that says no doesn't stop it
| Session on 2.1.327 | Was I asked? | Login shell started early |
|---|---|---|
| Default mode, I press Esc | yes | yes |
Deny rule Bash(touch *) in project settings |
no | yes |
--permission-mode dontAsk |
no | yes |
sandbox.enabled set, I press Esc |
yes | yes |
| First Bash call comes from a subagent | yes | no |
With the deny rule, Claude reported that the call "was denied by the permission settings". The debug log for that session shows a 137,605-byte snapshot, finished 1.6 seconds after the shell started.
With sandbox.enabled set in the project settings, the early shell could create a file in my home directory, and it had no SANDBOX_RUNTIME in its environment, the variable Claude Code sets for sandboxed commands. It ran outside the sandbox, as the snapshot shell did on 2.1.310.
What you get for it
My startup files take 1.4 to 2.1 seconds in a login shell. That is the wait the head start hides.
| I approve after | 2.1.326, Enter to command | 2.1.327, Enter to command |
|---|---|---|
| 0.3 s | 1.6 s | 1.0 s |
| 3 s, three runs each | 1.5 to 1.9 s | under 0.1 s |
You get that once per session.
Take 20 seconds and it runs twice
The binary throws a head start away when it is more than 20 seconds old by the time the command runs.
I approved one command after 15 seconds and one after 25. At 15 seconds the command started 0.08 seconds after Enter. At 25 seconds a second login shell started after Enter, and the command waited 1.5 seconds for it.
When I read a prompt slowly, then, my startup files run twice and the first command is as slow as it was on 2.1.326.
Where it doesn't happen
claude -p. A refused command in a headless run started no shell on either version. As far as I can read it, the code limits the head start to interactive sessions, the VS Code extension and the desktop app. I tested only the terminal.- A
PreToolUsehook that matches Bash. With a hook that does nothing but exit 0, no shell started before my answer. A hook that matches onlyEditdidn't prevent it. ZDOTDIRset. The debug log said "Shell snapshot: left for the first command to build". Thezsh -c envshell still started early, and my test.zshenvran before I answered.- The switch. With
CLAUDE_CODE_DISABLE_SHELL_HEAD_START=1in the environment, or in theenvblock of the project's.claude/settings.json, nothing started early.
From the code, untested: the head start is also skipped when a startup file in your home directory mentions /dev/tty, TTY, COLUMNS or LINES outside a comment, or is larger than 256 KB.
The switch is in the changelog. This morning it was not on the environment variables page of the docs, nor on the settings, permissions, sandboxing, security, hooks and interactive mode pages.
What I'd do
You answered the folder's trust question before any of this, and that screen says Claude Code will "be able to read, edit, and execute files here". I don't read this as a hole. What changed is what a refusal covers. Saying no to the first command no longer keeps your startup files from running in that folder.
Read .zshenv, .zprofile and .zshrc for anything that looks at the current directory: a .env that gets sourced, a version file, a virtualenv that activates itself. The shells Claude Code started in my runs had CLAUDECODE=1 in their environment, so a [ -z "$CLAUDECODE" ] guard keeps that convenience for your own terminal.
If a startup file does something you'd notice twice, such as writing a log line or starting an agent, remember the 20 seconds.
If you'd rather keep the old order, set the switch and pay the second and a half once per session. I ran with project settings only, so I didn't test it in ~/.claude/settings.json.
I didn't test the VS Code extension, the desktop app, Linux, Windows or fish. Plan mode gave me nothing to measure, because Claude never issued the Bash call. npm's stable tag is still 2.1.311, so a session pinned to stable doesn't have this yet.
The prompt still asks before Claude's command runs. It no longer asks before yours do.


