TL;DR Run
which git gh. If either comes backnot found, install it and update Claude Code to 2.1.290 or later withclaude update: from that version on, the error names the missing program. If "Premature close" shows up inside an API error, it's your connection, not git.
"Premature close" is the generic message of a stream that closes before it finishes. Up to 2.1.289, on macOS and Linux, Claude Code showed it when it tried to run a program that isn't installed, such as git or gh, instead of saying which one was missing. Version 2.1.290 fixed it on October 5, 2026:
Fixed errors reading "Premature close" instead of naming the missing program when a tool Claude Code runs, such as git or gh, is not installed (macOS, Linux)
Missing program or network: how to tell
- It appears when Claude Code runs git or gh itself, for example when it creates a worktree with
claude --worktreeor talks to GitHub through gh. The program is almost certainly missing. Follow the steps below. - It appears inside an API or connection error. The same text shows up when the connection drops halfway through a response. git has nothing to do with it there: first check whether Claude Code is down or it's you.
How to fix it
1. Find the missing program
which git gh
With both installed, each one answers with its path:
/opt/homebrew/bin/git
/opt/homebrew/bin/gh
If one is missing, zsh says not found (bash prints nothing for it). This is the real output with both taken off the PATH:
git not found
gh not found
On macOS, /usr/bin/git exists even without Xcode's Command Line Tools. Check that git --version answers with a version number. If it offers to install the tools or errors out instead, install them with xcode-select --install.
2. Install what's missing
# macOS with Homebrew
brew install git gh
# Debian, Ubuntu
sudo apt install git
For gh on Linux, the GitHub CLI install guide has the repository for each distribution. If gh is new on your machine, sign in with gh auth login before going back to Claude Code.
3. Update Claude Code
claude update
From 2.1.290 on, if a program goes missing again, the error names it. I checked on 2.1.293: I took git off the PATH and ran claude --worktree in a repository. Instead of "Premature close", the output was:
Error creating worktree: Failed to resolve base branch "HEAD": git rev-parse failed
If claude update doesn't move you to a new version because you installed with Homebrew or npm, how to update Claude Code has the command for each case.
Official docs: Troubleshooting · Claude Code changelog, 2.1.290