update-claude
SKILL.md
update-claude Skill
What this skill does
When invoked, install the update-claude shell function into the user's shell configuration file. This function safely updates Claude Code (@anthropic-ai/claude-code) in nvm environments by removing the old package directory before reinstalling, which avoids the common ENOTEMPTY error.
Instructions
- Detect the user's shell by checking
$SHELL(bash or zsh). - Determine the rc file path:
- For zsh:
${ZDOTDIR:-$HOME}/.zshrc - For bash:
$HOME/.bashrc
- For zsh:
- Check if the
update-claudefunction already exists in the rc file. If it does, inform the user and skip. - Append the following function to the rc file:
# Claude Code updater - avoid ENOTEMPTY errors in nvm environments
update-claude() {
echo "Current version: $(claude --version 2>/dev/null || echo 'unknown')"
local pkg_dir="$(npm root -g)/@anthropic-ai/claude-code"
echo "Package path: $pkg_dir"
echo "Removing old version..."
rm -rf "$pkg_dir"
echo "Installing latest version..."
npm install -g @anthropic-ai/claude-code@latest
if [ $? -eq 0 ]; then
echo "Update complete! Version: $(claude --version)"
else
echo "Installation failed. Check error logs."
return 1
fi
}
- Source the rc file to make the function immediately available.
- Confirm success to the user by showing which file was modified.
Usage after installation
The user can run update-claude in their terminal at any time to safely update Claude Code.
Weekly Installs
3
Repository
amu815/update-c…de-skillGitHub Stars
1
First Seen
4 days ago
Security Audits
Installed on
amp3
cline3
opencode3
cursor3
kimi-cli3
codex3