一键导入
claude-oauth-refresher
Keep your Claude access token fresh 24/7. Automatically refreshes OAuth tokens before expiry so you never see authentication failures.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Keep your Claude access token fresh 24/7. Automatically refreshes OAuth tokens before expiry so you never see authentication failures.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | claude-oauth-refresher |
| description | Keep your Claude access token fresh 24/7. Automatically refreshes OAuth tokens before expiry so you never see authentication failures. |
Automatic OAuth token refresh for Claude Code CLI on macOS
Keep your Claude account logged in 24/7 by automatically refreshing OAuth tokens before they expire.
This skill is macOS-only and requires:
claude command available)claude then login - stores tokens in Keychain)Not sure if you're set up? Run the verification script:
./verify-setup.sh
cd ~/bot/skills/claude-oauth-refresher
./install.sh
This installer runs ONCE and sets up automatic token refresh that runs every 2 hours.
The installer will:
After installation:
claude-oauth-refresh-config.json to change settingsDuring installation, you'll be prompted:
Configure Notifications:
💡 Recommendation: Keep all enabled for the first run to verify it works.
You can disable them later by:
1. Editing ~/bot/claude-oauth-refresh-config.json
2. Asking Bot: "disable Claude refresh notifications"
Enable "🔄 Refreshing token..." notification? [Y/n]:
Enable "✅ Token refreshed!" notification? [Y/n]:
Enable "❌ Refresh failed" notification? [Y/n]:
Recommendation: Keep all enabled initially to verify everything works, then disable start/success notifications once you're confident.
You can ask Bot to change notification settings for you! No need to edit JSON manually.
Disable specific notification types:
"disable Claude refresh start notifications"
"disable Claude refresh success notifications"
"turn off Claude token refresh start messages"
Enable notification types:
"enable Claude refresh start notifications"
"enable all Claude refresh notifications"
"turn on Claude token refresh success messages"
Check current settings:
"show Claude refresh notification settings"
"what are my Claude token refresh notification settings?"
Disable all notifications:
"disable all Claude refresh notifications"
"turn off all Claude token notifications"
Reset to defaults:
"reset Claude refresh notifications to defaults"
Bot will:
~/bot/claude-oauth-refresh-config.jsonChanges apply immediately on the next refresh (no need to restart anything).
The install script automatically detects your notification settings!
It reads ~/.bot/bot.json to find:
claude-oauth-refresh-config.json with these valuesExample: If you have Telegram enabled with chat ID 123456789, the installer creates:
{
"notification_channel": "telegram",
"notification_target": "123456789"
}
To override: Simply edit claude-oauth-refresh-config.json after installation to use a different channel or target.
If auto-detection fails: The installer will prompt you to configure manually (see "Finding Your Target ID" below).
Test detection before installing:
./test-detection.sh
# Shows what would be auto-detected without modifying anything
To receive notifications, you need to configure your notification_target in claude-oauth-refresh-config.json. Here's how to find it for each channel:
Format: Numeric chat ID (e.g., 123456789)
How to find:
# Option 1: Use Bot CLI
bot message telegram account list
# Option 2: Message @userinfobot on Telegram
# Send any message, it will reply with your ID
# Option 3: Check recent messages
bot message telegram message search --limit 1 --from-me true
Example config:
{
"notification_channel": "telegram",
"notification_target": "123456789"
}
Format:
user:U01234ABCDchannel:C01234ABCDHow to find:
# List channels
bot message slack channel list
# Find user ID
bot message slack user list | grep "your.email@company.com"
# Or click on your profile in Slack → More → Copy member ID
Example config:
{
"notification_channel": "slack",
"notification_target": "user:U01234ABCD"
}
Format:
user:123456789012345678channel:123456789012345678How to find:
# Enable Developer Mode in Discord (Settings → Advanced → Developer Mode)
# Then right-click your username → Copy ID
# Or list channels
bot message discord channel list
Example config:
{
"notification_channel": "discord",
"notification_target": "user:123456789012345678"
}
Format: E.164 phone number (e.g., +15551234567)
How to find:
+[country code][number] (no spaces, dashes, or parentheses)Examples:
+15551234567+447911123456+61412345678Example config:
{
"notification_channel": "whatsapp",
"notification_target": "+15551234567"
}
Format (preferred): chat_id:123
How to find:
# List recent chats to find your chat_id
bot message imessage thread list --limit 10
# Find the chat with yourself or your preferred device
Alternative formats:
+15551234567 (E.164 format)your.email@icloud.comExample config:
{
"notification_channel": "imessage",
"notification_target": "chat_id:123"
}
Format: E.164 phone number (e.g., +15551234567)
How to find:
+[country code][number] (no spaces, dashes, or parentheses)Example config:
{
"notification_channel": "signal",
"notification_target": "+15551234567"
}
File: claude-oauth-refresh-config.json
{
"refresh_buffer_minutes": 30,
"log_file": "~/bot/logs/claude-oauth-refresh.log",
"notifications": {
"on_start": true,
"on_success": true,
"on_failure": true
},
"notification_channel": "telegram",
"notification_target": "YOUR_CHAT_ID"
}
| Option | Type | Default | Description |
|---|---|---|---|
refresh_buffer_minutes | number | 30 | Refresh tokens this many minutes before expiry |
log_file | string | ~/bot/logs/claude-oauth-refresh.log | Where to write logs |
notifications.on_start | boolean | true | Send "🔄 Refreshing token..." notification |
notifications.on_success | boolean | true | Send "✅ Token refreshed!" notification |
notifications.on_failure | boolean | true | Send "❌ Refresh failed" notification with details |
notification_channel | string | telegram | Channel to use (see above for options) |
notification_target | string | YOUR_CHAT_ID | Target ID (see "Finding Your Target ID") |
🔄 Start (on_start)
✅ Success (on_success)
❌ Failure (on_failure)
Minimal (failures only):
{
"notifications": {
"on_start": false,
"on_success": false,
"on_failure": true
}
}
Verbose (all notifications):
{
"notifications": {
"on_start": true,
"on_success": true,
"on_failure": true
}
}
Silent (no notifications):
{
"notifications": {
"on_start": false,
"on_success": false,
"on_failure": false
}
}
When a refresh fails, you'll receive a detailed notification with:
❌ Claude token refresh failed
Error: Network timeout connecting to auth.anthropic.com
Details: Connection timed out after 30s
Troubleshooting:
- Check your internet connection
- Verify you can reach auth.anthropic.com
- Try running manually: ~/bot/skills/claude-oauth-refresher/refresh-token.sh
Need help? Message Bot or check logs:
~/bot/logs/claude-oauth-refresh.log
Network/Timeout Errors
Troubleshooting:
- Check your internet connection
- Verify you can reach auth.anthropic.com
- Try running manually: ./refresh-token.sh
Invalid Refresh Token
Troubleshooting:
- Your refresh token may have expired
- Re-authenticate: claude auth logout && claude auth
- Verify Keychain access: security find-generic-password -s 'claude-cli-auth' -a 'default'
Keychain Access Denied
Troubleshooting:
- Check Keychain permissions
- Re-run authentication: claude auth
- Verify setup: ./verify-setup.sh
Missing Auth Profile
Troubleshooting:
- Run: claude auth
- Verify file exists: ~/.config/claude/auth-profiles.json
- Check file permissions: chmod 600 ~/.config/claude/auth-profiles.json
# View recent logs
tail -f ~/bot/logs/claude-oauth-refresh.log
# Check launchd status
launchctl list | grep claude-oauth-refresher
# Manual refresh (for testing)
cd ~/bot/skills/claude-oauth-refresher
./refresh-token.sh
Option 1: Ask Bot (easiest)
"disable Claude refresh start notifications"
"show Claude refresh notification settings"
Option 2: Edit config file
nano ~/bot/skills/claude-oauth-refresher/claude-oauth-refresh-config.json
Changes apply automatically on next refresh (every 2 hours, or when you run manually).
No need to restart anything! The refresh script reads the config file each time it runs.
verify-setup.sh says Claude CLI not foundSolution:
# Install Claude CLI
brew install claude
# Or download from https://github.com/anthropics/claude-cli
verify-setup.sh says no refresh token foundSolution:
# Authenticate with Claude
claude auth
# Follow the prompts to log in
Solution:
notification_target format matches the examples abovebot message [channel] send --target "[your_target]" --message "Test"
bot gateway statuscat ~/bot/skills/claude-oauth-refresher/claude-oauth-refresh-config.json | jq .notifications
Solution:
# Re-authenticate from scratch
claude auth logout
claude auth
# Test refresh again
cd ~/bot/skills/claude-oauth-refresher
./refresh-token.sh
Solution:
The config file was renamed from config.json to claude-oauth-refresh-config.json.
# If you have an old config.json, run the installer to migrate:
cd ~/bot/skills/claude-oauth-refresher
./install.sh
# Choose to keep existing config when prompted
Solution:
# Re-run the installer (safe to run multiple times)
cd ~/bot/skills/claude-oauth-refresher
./install.sh
The installer will:
cd ~/bot/skills/claude-oauth-refresher
./uninstall.sh
This will:
Installer (install.sh) - Run ONCE to set up:
Launchd - Runs refresh-token.sh every 2 hours automatically
Refresh Script (refresh-token.sh) - Each run:
~/.config/claude/auth-profiles.json~/bot/logs/claude-oauth-refresh.logConfig Changes - Applied automatically:
claude-oauth-refresh-config.json anytime~/.config/claude/auth-profiles.json (permissions: 600)Logs: ~/bot/logs/claude-oauth-refresh.log
Issues:
./verify-setup.sh to diagnose./refresh-token.shcat claude-oauth-refresh-config.json | jq .notificationsNeed help? Open an issue with:
./verify-setup.shtail -20 ~/bot/logs/claude-oauth-refresh.logsw_verscat claude-oauth-refresh-config.json | jq 'del(.notification_target)'