An installer shell script for Claude Code that automates fetching and installing the correct native binary. It accepts an optional target (stable/latest/VERSION), validates the form of that argument, and refuses to run under sudo from a regular user's shell unless explicitly allowed via CLAUDE_INSTALL_ALLOW_SUDO. It finds curl or wget (fails if neither), optionally uses jq and zstd if available, and always downloads the latest version string from downloads.claude.ai before fetching the versioned manifest. The script detects OS and CPU (macOS/linux, x64/arm64), handles Rosetta on Macs and musl-based Linux builds, and rejects Windows/unsupported platforms. Binaries go into $HOME/.claude/downloads and are made executable; the installer then invokes the downloaded binary's install command to set up launchers and shell integration.
The installer validates inputs and integrity: it extracts SHA256 checksums and sizes from manifest.json (using jq or a bash regex fallback), supports downloading a zstd-compressed blob when appropriate and verifying both compressed and decompressed checksums, and enforces checksum format (64 hex chars). It includes robust error handling and user-facing messages - restoring terminal state on interrupted installs, coloring stderr for emphasis, explaining exit 137 as likely OOM on Linux, and cleaning up partial files. Failure paths print actionable guidance and exit with meaningful codes.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.