atxtechbro / atxtechbro/dotfiles
Create automated fix script for Claude Code macOS Opus access issue
- Dominant language
- Shell
- Stars
- 27
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
## Task: Create automated fix script for Claude Code macOS authentication issues
Following the **Spilled Coffee Principle** - if my laptop dies, I need a single script to fix Claude Code authentication issues on macOS.
## Background
Claude Code v1.0.51 on macOS incorrectly treats Claude Max ($200/month) users as Pro users, preventing Opus model access. See [anthropics/claude-code#3566](https://github.com/anthropics/claude-code/issues/3566) for details.
## Script Requirements
Create `utils/fix-claude-code-macos-auth.sh` that automates all potential fixes:
```bash
#!/usr/bin/env bash
# Fix Claude Code macOS authentication issues
# Addresses: https://github.com/anthropics/claude-code/issues/3566
set -e
echo "🔧 Claude Code macOS Authentication Fix Script"
echo "============================================="
echo "This script will attempt multiple fixes for the Opus model access issue"
echo ""
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# 1. Clear keychain entries
echo "📌 Step 1: Clearing macOS Keychain entries..."
security delete-generic-password -s "Claude Code" 2>/dev/null || echo " No keychain entry found (this is OK)"
security delete-generic-password -s "Claude Code-credentials" 2>/dev/null || echo " No credentials entry found (this is OK)"
# 2. Backup and remove potentially corrupted config
echo "📌 Step 2: Backing up and removing Claude config files..."
if [ -f ~/.claude.json ]; then
cp ~/.claude.json ~/.claude.json.backup.$(date +%Y%m%d_%H%M%S)
echo " Backed up ~/.claude.json"
fi
rm -f ~/.claude.json
rm -rf ~/.claude/
# 3. Clear all Claude Code installations
echo "📌 Step 3: Removing all Claude Code installations..."
if command_exists npm; then
npm uninstall -g @anthropic-ai/claude-code 2>/dev/null || true
fi
# Find and remove all node_modules installations
find ~/.nvm/versions/node -name "@anthropic-ai" -type d -exec rm -rf {} + 2>/dev/null || true
find /usr/local/lib/node_modules -name "@anthropic-ai" -type d -exec rm -rf {} + 2>/dev/null || true
find /opt/homebrew/lib/node_modules -name "@anthropic-ai" -type d -exec rm -rf {} + 2>/dev/null || true
# 4. Set environment variables to prevent Bedrock interference
echo "📌 Step 4: Setting environment variables..."
export CLAUDE_USE_BEDROCK=false
export DISABLE_BEDROCK=true
export CLAUDE_CODE_USE_BEDROCK=false
# Add to appropriate shell config if not already present
SHELL_CONFIG=""
if [ -n "$ZSH_VERSION" ]; then
SHELL_CONFIG="$HOME/.zshrc"
elif [ -n "$BASH_VERSION" ]; then
SHELL_CONFIG="$HOME/.bashrc"
fi
if [ -n "$SHELL_CONFIG" ] && [ -f "$SHELL_CONFIG" ]; then
if ! grep -q "CLAUDE_USE_BEDROCK=false" "$SHELL_CONFIG"; then
echo "" >> "$SHELL_CONFIG"
echo "# Claude Code macOS fix" >> "$SHELL_CONFIG"
echo "export CLAUDE_USE_BEDROCK=false" >> "$SHELL_CONFIG"
echo "export DISABLE_BEDROCK=true" >> "$SHELL_CONFIG"
echo "export CLAUDE_CODE_USE_BEDROCK=false" >> "$SHELL_CONFIG"
echo " Added environment variables to $SHELL_CONFIG"
fi
fi
# 5. Reinstall Claude Code
echo "📌 Step 5: Reinstalling Claude Code..."
if command_exists npm; then
npm install -g @anthropic-ai/claude-code@latest
else
echo "❌ npm not found. Please install Node.js first."
exit 1
fi
# 6. Prompt for restart
echo ""
echo "✅ Fix script completed!"
echo ""
echo "🔄 IMPORTANT: Please restart your machine now"
echo " After restart:"
echo " 1. Run 'claude' in terminal"
echo " 2. Log in with your Claude Max account"
echo " 3. Try '/model opus' to verify it works"
echo ""
echo "If the issue persists after restart, the bug is in Claude Code itself"
echo "and requires a fix from Anthropic (tracked in issue #3566)"
```
## Additional Features
1. **Make it idempotent** - Safe to run multiple times
2. **Add rollback option** - `--rollback` flag to restore from backup
3. **Add verification** - After restart, add `--verify` flag to check if Opus is accessible
4. **Add to setup.sh** - Include option to run this if Claude Code auth issues detected
## Testing
- Test on macOS with the authentication issue
- Test on macOS without the issue (should be harmless)
- Test rollback functionality
## Success Criteria
- Single command fixes all known workarounds
- Follows dotfiles automation principles
- Survives the "spilled coffee test"
Related:
- https://github.com/anthropics/claude-code/issues/3566
- https://github.com/atxtechbro/dotfiles/issues/847 (closed)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the requested utils/fix-claude-code-macos-auth.sh script and inspect setup.sh before deciding how it should be integrated. Review the listed keychain, Claude configuration, npm installation, environment-variable, --rollback, and --verify behaviors; done means the script is idempotent, rollback and verification work, and the documented macOS test cases are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, macos, shell
- Domain
- cli, operating-systems, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100