SuperAPI AI Directory

update-claude-code

Deployment & operations

View repository

Updated 10-16 01:33

About this skill

Update Claude Code

Steps

  1. Install the latest version globally using npm:
npm install -g @anthropic-ai/claude-code@latest
  1. Verify that the update succeeded:
claude --version
  1. Report the updated version number to the user.

  2. Clean up old versions: Check whether multiple leftover Claude Code versions exist on the machine, and if so, keep only the latest version:

# 检查本地版本目录
ls ~/.local/share/claude/versions/

# 获取当前 symlink 指向的版本
readlink ~/.local/bin/claude

If multiple version directories exist,do not just change the symlink—the automatic rollback mechanism will change the symlink back. The correct approach is to install via npm to completely bypass this mechanism:

npm install -g @anthropic-ai/claude-code@latest

The path of the npm-installed version (usually ~/.nvm/versions/node/vX.X.X/bin/claude or the system npm bin) has higher priority in PATH than ~/.local/bin/claude, and can completely bypass the automatic rollback mechanism.

After installation is complete, clean up the old version directories:

# 删除全部版本残留目录
rm -rf ~/.local/share/claude/versions/

Verify the version is correct again:

claude --version && which claude

Confirm that which claude outputs the npm path (such as ~/.nvm/...), rather than ~/.local/bin/claude。

Notes

  • curl -fsSL https://claude.ai/install.sh | bash This method is inaccessible in some regions (such as mainland China), and will return an HTML error page instead of the installation script,do not use。
  • The npm method is the most reliable update method; just use it directly, no proxy is needed.
  • If npm also fails, check whether npm is installed:npm --version, and prompt the user to install Node.js first.
  • Claude Code uses an automatic update mechanism, which downloads each version to the ~/.local/share/claude/versions/ directory,~/.local/bin/claude is a symlink. When a new version crashes, it automatically rolls the symlink back to the old version, causing the version displayed by --version to be lower than expected.Only modifying the symlink cannot solve the problem, the rollback mechanism will re-download the old version and change it back. You must install via npm to bypass this mechanism.
  • Clean up the ~/.local/share/claude/versions/ directory; the npm-installed version is unaffected and can still be used normally.