AI Gateway Docs

Troubleshooting

Common errors and fixes for Claude Code, Codex CLI, OpenClaw, and external integrations

Overview

A consolidated list of frequent issues and fixes across Claude Code, Codex CLI, OpenClaw, and external integrations — covering installation, authentication, networking, request errors, permissions, caching/billing, plugins, integrations, Codex CLI, and OpenClaw.

Setup guides: CC-Switch Setup, Node.js and Git Setup, Claude Code Setup, Codex CLI Setup.

Before troubleshooting on your own, check whether the issue is widespread in the community channel. If nobody else reports it, the problem is likely local.


Installation and Startup

Q1: First launch fails with "Unable to connect to Anthropic services"

Symptom: After installing Claude Code, the first claude invocation prints the following and exits:

Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ERR_BAD_REQUEST
Please check your internet connection and network settings.

Fix: Open ~/.claude.json (Windows: C:\Users\<user>\.claude.json) in a text editor and add this field to the top-level JSON object:

"hasCompletedOnboarding": true

Full example:

{
  "installMethod": "unknown",
  "autoUpdates": true,
  "firstStartTime": "2025-07-14T06:11:03.877Z",
  "userID": "...",
  "projects": { },
  "hasCompletedOnboarding": true
}

Make sure the closing } of projects is followed by a comma, otherwise the JSON is invalid. Validate the file:

cat ~/.claude.json | python3 -m json.tool

No errors means the format is valid. Re-run claude to enter the interactive UI.

Q2: command not found: claude

The npm global bin directory is not on PATH. Run npm config get prefix and append its /bin directory to the system PATH.

Q3: permission denied / EACCES during install (Mac / Linux)

Don't use sudo. Move the npm global prefix to your home directory:

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc   # zsh users: ~/.zshrc
source ~/.bashrc

Q4: permission denied during install (Windows)

Run PowerShell as Administrator:

npm config set prefix "$env:APPDATA\npm"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Q5: How do I remove an older npm install of Claude Code?

The current official recommendation is the native install script, not npm. Back up ~/.claude first, then uninstall the old package:

# Mac / Linux
if [ -d ~/.claude ]; then cp -r ~/.claude ~/.claude.backup; fi
npm list -g --depth=0
npm uninstall -g @anthropic-ai/claude-code
# Windows PowerShell
if (Test-Path "$env:USERPROFILE\.claude") { Copy-Item "$env:USERPROFILE\.claude" "$env:USERPROFILE\.claude.backup" -Recurse }
npm list -g --depth=0
npm uninstall -g @anthropic-ai/claude-code

Reinstall via the native script:

# Mac / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Or use a package manager: brew install --cask claude-code on macOS, winget install Anthropic.ClaudeCode on Windows.


Authentication and API Keys

Q6: 401 Invalid API Key / token rejected

Symptom: terminal returns 401 invalid x-api-key.

Cause: ANTHROPIC_BASE_URL is unset or wrong, so the request goes to the official endpoint.

Fix: confirm ~/.claude/settings.json has the correct Base URL and key:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://your-api-url",
    "ANTHROPIC_API_KEY": "sk-***"
  }
}

Note: Claude Code's Base URL does not need a /v1 suffix.

Q7: 401 token rejected — IDE or MCP overwrote the config

Symptom: the API key is correct yet 401 persists. Common after installing IDE plugins like Cursor or Continue.

Cause: IDE plugins or MCP servers overwrote apiKey / baseURL in settings.json.

Fix (pick one):

  • Recommended: rewrite the config with CC Switch — it overrides whatever was tampered with
  • Manual: inspect and fix the overwritten fields in ~/.claude/settings.json
  • Environment variables: set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY as system env vars (higher precedence than config files, harder to clobber)

Prevention: re-verify Claude Code connectivity after installing a new IDE plugin or MCP server.

Q8: 401 after switching providers

Symptom: previously used another proxy service; switched, configured the new one correctly, still get 401.

Cause: stale system environment variables from the old service (ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, ANTHROPIC_API_TOKEN) take precedence over config files.

Windows fix: Win + Rsysdm.cpl → Advanced → Environment Variables. Delete ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, and ANTHROPIC_API_TOKEN from both User and System scopes. Reopen the terminal. If it still fails, delete these and reconfigure via CC Switch:

C:\Users\<user>\.claude\claude.json
C:\Users\<user>\.claude\claude.json.backup

Mac / Linux fix: edit ~/.zshrc or ~/.bashrc, remove any lines starting with export ANTHROPIC_, run source ~/.zshrc, restart the terminal.

Q9: OAuth login conflicts with API key

Symptom: previously completed an OAuth login on the official site via claude. After switching to a proxy API, the new config is ignored — requests still go directly to api.anthropic.com. Especially common on servers (CentOS / Ubuntu).

Cause: an OAuth token (primaryApiKey / oauthToken) was written into ~/.claude.json and takes precedence over the API key in settings.json.

Fix:

# Step 1: log out of OAuth
claude auth logout

# Step 2: write the proxy API config
cat > ~/.claude/settings.json << 'EOF'
{
  "env": {
    "ANTHROPIC_API_KEY": "sk-your-api-key",
    "ANTHROPIC_BASE_URL": "https://your-api-url"
  }
}
EOF

# Step 3: verify
cat ~/.claude/settings.json

# Step 4: restart
claude

Prevention: on servers, write settings.json before the first claude invocation so OAuth never triggers.

Q10: 401 Invalid API Key format — invisible characters in the key

Symptom: the key looks right but still returns 401 or "Invalid format".

Cause: copying the key through PDFs / web pages / screenshots can introduce zero-width spaces, non-breaking spaces, or \r. OCR can also misread 0 vs O or 1 vs l vs I.

Check:

echo "$ANTHROPIC_API_KEY" | cat -A
# OK: line ends with just $
# Bad: ^M$ or other stray characters

Fix: re-copy the key using the dashboard's Copy button — never type by hand or route through PDFs / screenshots. Don't wrap the value in quotes:

export ANTHROPIC_API_KEY=sk-ant-api03-your-key

Q11: 403 Missing API Key / config conflict

Cause: config file was modified or multiple configs are colliding.

Fix: use CC Switch to rewrite the config, overwriting any tampered files.

Q12: Launch asks for authentication or shows a login prompt

Make sure ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY are configured, then restart the terminal (close the entire window, not just open a new tab).

Q13: Configuration precedence

Highest to lowest: system environment variables > ~/.claude.json (OAuth token) > ~/.claude/settings.json (written by CC Switch).

If edits to settings.json don't take effect, first check for higher-precedence env vars or leftover OAuth tokens.


Network and Connectivity

Q14: API Error (Connection error.)

Symptom: the request never reaches the server; retries don't help.

Cause: the network path to the server is broken at the TCP layer — usually a dead proxy node, flaky Wi-Fi, or an outbound firewall rule.

Debug steps:

  1. Run ping your-api-url to check reachability
  2. Replies → audit proxy config; timeouts → switch network (different Wi-Fi / disable proxy / change proxy node / phone hotspot)
  3. Make sure the proxy app has "system proxy" or "TUN mode" enabled — Claude Code is a CLI tool and won't go through browser-only proxy channels
  4. Once the network is back, re-run claude

Q15: API Error (Request timed out.)

Symptom: the request hangs and eventually times out.

Two possible causes:

  • A — Network latency: latency to the server is too high. Follow Q14.
  • B — Context too long: the session has accumulated too many tokens and exceeds the timeout window.

Fix for case B:

  • Type /clear to wipe the conversation
  • Or /compact to compress context while keeping a summary
  • Or exit and re-run claude for a fresh session

IDE users: IDE plugins inject heavy system prompts on top of Claude Code's own — the usable conversation budget shrinks fast. Check context length first when you see timeouts.

Q16: WebFetch broken even though the site loads in a browser

Symptom: WebFetch fails on URLs that work fine in the browser, even with a global-mode proxy.

Cause: before fetching the target URL, Claude Code sends a preflight to https://claude.ai/api/web/domain_info. Domestic networks or enterprise firewalls that block claude.ai cause the preflight to fail, which fails WebFetch entirely.

Fix: add this to ~/.claude/settings.json (Windows: C:\Users\<user>\.claude\settings.json):

"skipWebFetchPreflight": true

Merge with existing config:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://your-api-url",
    "ANTHROPIC_API_KEY": "sk-***"
  },
  "skipWebFetchPreflight": true
}

Restart Claude Code — the preflight is skipped and the target URL is fetched directly.


Request Errors

Q17: Returns 400 unrelated to message content

Symptom: requests to AWS groups return 400 with invalid beta flag in the logs; persists after starting a new conversation.

Cause: Claude Code attaches the experimental anthropic-beta header, which some AWS upstream groups don't support.

Fix: first confirm with an env var:

# Mac / Linux
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
claude
# Windows PowerShell
$env:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = "1"
claude

If it works, persist the setting in ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://your-api-url",
    "ANTHROPIC_API_KEY": "sk-***",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}

Fully close and reopen the terminal after saving.

Cause: a Claude Code bug producing a malformed request body.

Fix: resend, or run /compact — usually clears it.

Q19: 413 Request body too large

Symptom: API Error: 413 Request Entity Too Large.

Cause: too many tokens in the session — request body exceeds the server's body-size limit.

Fix: /clear (wipe) or /compact (summarize), or exit and start a new session.

Prevention: run /compact periodically during long tasks.

Q20: 400 Invalid model name

Symptom: API Error: 400 Invalid model name when using Opus.

Cause: Opus concurrency quota is exhausted; the server rejects with a downgrade.

Fix: don't touch the config — wait a moment and retry. Don't burn time changing settings.

Q21: 429 Rate Limit / quota exhausted

429 comes in two flavors with completely different handling:

  • rate_limit_error: too many requests per unit time — clears itself
  • insufficient_quota: monthly quota exhausted — top up or wait for reset

Determine which: visit https://your-api-url to check balance:

  • Balance remaining → rate limit; back off or reduce concurrency
  • Balance zero → quota exhausted; top up

Q22: Overloaded / 500

Cause: official service overload or outage.

Fix: check status.anthropic.com and wait for recovery.

Q23: API Error: response exceeded the 32000

Cause: a single reply exceeded the default output token limit.

Fix: in ~/.claude/settings.json under env:

"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000"

Q24: 503 model_not_found

Cause: the chosen model is offline or unavailable on the current channel.

Fix: use /model to switch to another available model, or contact the provider to confirm availability.

Q25: Context window exceeded — conversation truncated

Cause: the session has too many tokens; /compact or a new session wasn't run in time.

Fix: run /compact to compress, or /clear to start fresh.

Q26: Command timed out after 2m 0.0s

Cause: Claude Code waited too long for a shell command to return — unrelated to the API.

Fix: run the command manually in your terminal to see where it hangs.


Permissions

Q27: Permission denied — file read/write blocked

Three independent causes — diagnose each:

  • A — OS-level permission: ls -la /path/to/file to check the mode bits; fix with chmod 644 (files) or chmod 755 (directories)
  • B — Claude Code permission setting: you selected "Always deny" for that operation. Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux) → Claude: Manage Permissions. Switch the rule to "Ask" or "Allow".
  • C — .claudeignore glob misfire: cat .claudeignore and look for overly broad patterns. Delete or tighten the offending rule.

Prevention: use precise paths in .claudeignore, not wide globs. Review "Always deny" rules periodically. Keep project files at 644 and directories at 755.

Q28: skipAutoPermissionPrompt breaks Plan mode

Symptom: adding "skipAutoPermissionPrompt": true to settings.json breaks Plan mode; removing it restores it.

Fix: open ~/.claude/settings.json, delete the skipAutoPermissionPrompt line, save, restart the terminal.

Prevention: only add options documented in the official docs. Always sanity-test basic features after changing permission-related settings.

Q29: How does Claude Code's permission system work?

Claude Code asks for confirmation before file operations and shell commands. The first invocation shows a prompt with "Allow once", "Always allow", or "Always deny". A stray "Always deny" silently blocks all future requests in that category — fix it via the Permission manager.


Caching and Billing

Q30: Duplicate cache creation causing duplicate charges

Symptom: within a single request, the cache is created multiple times — billed twice. First-token latency above 30s is a strong tell.

Cause: when a fallback load triggers a key swap, the second forwarded hop carries certain request headers, causing the request to be misrouted and the cache to be recreated.

Fix:

  1. Confirm the pattern: trace the request path for repeated cache creation and a first-token time noticeably above 30s
  2. Remove the ccs proxy so the request doesn't traverse the middle layer that triggers the key-swap fallback
  3. If you must keep the forwarding chain, audit headers preserved in the second hop and drop the ones that cause misrouting
  4. Send a fresh, isolated request to verify

Prevention: keep the request path stable and singular; only preserve necessary headers when re-forwarding.

Q31: How do I enable 1-hour prompt caching?

For groups that support long caches, add to env in ~/.claude/settings.json:

"ENABLE_PROMPT_CACHING_1H": "1"

Trade-off: 1-hour caches are more expensive to rebuild. For high-frequency use the default short cache is usually better. Only enable for long-running tasks.

Q32: How do I see current token usage?

Type /cost in Claude Code to see the current session's token spend.


claude-mem Plugin

Q33: Knowledge base empty, pending_messages piling up

Symptom: observations table is empty (zero knowledge points extracted across many days), pending_messages is full of rows stuck at pending, sdk_sessions has no completed rows, worker_port is None everywhere.

Cause: the model channel the worker uses went offline (e.g. claude-sonnet-4-5 returning 503), the SDK subprocess kept crashing, and the backlog was wiped as "queue garbage" — destroying the source data permanently.

Fix:

  1. Diagnose before cleaning: observations at 0 means the pipeline is broken, not "time to clean up". A pile of pending rows is an alarm, not a cleanup signal — investigate the worker, don't delete.
  2. Change the model: edit ~/.claude-mem/settings.json and switch to a currently stable model:
{
  "CLAUDE_MEM_MODEL": "claude-haiku-4-5-20251001"
}
  1. Restart the worker: rm ~/.claude-mem/worker.pid — the next hook trigger will restart with the new config.
  2. Safe cleanup: only delete rows in completed or failed state. Never touch pending rows.
# Safe Python cleanup
cur.execute("DELETE FROM pending_messages WHERE status IN ('completed', 'failed')")
conn.commit()

Table cheatsheet:

  • pending_messages: input queue for knowledge extraction (raw material) — not garbage
  • observations: extracted knowledge (output) — zero means the pipeline is broken
  • sdk_sessions: subprocess session state — all worker_port None means it's broken

On Windows running Python, add sys.stdout.reconfigure(encoding='utf-8') or Chinese strings will trigger a GBK error.

Q34: Claude Code commands hang — worker zombie

Symptom: commands return nothing without error; Claude Code gets slower over time. curl http://127.0.0.1:37777/api/health TCP-connects but the HTTP response never comes — the port is in LISTEN state but the owning PID is dead.

Cause: after upgrading claude-mem the old worker died, port 37777 was left in LISTEN with no live process, the new worker keeps misjudging "port in use" and failing, and every tool call's hook times out, dragging the whole CLI.

Check:

curl -m 8 -sv http://127.0.0.1:37777/api/health
# TCP connects but HTTP never returns = zombie

Fix:

  1. Clear the leftover process and port
# PowerShell — find the PID listening on the port
Get-NetTCPConnection -LocalPort 37777 | Select-Object OwningProcess
# Kill it
Stop-Process -Id <PID> -Force

If Stop-Process says the process doesn't exist, kill every leftover node.exe and python.exe from Task Manager.

  1. Restart the worker from the correct directory
# Correct: the marketplaces directory
cd ~/.claude/plugins/marketplaces/thedotmack
npm run worker:status
npm run worker:restart

# Wrong: don't cd into cache/ — the worker scripts aren't there
  1. Verify
curl -m 5 -sv http://127.0.0.1:37777/api/health
# Normal response: {"status":"ok","initialized":true,"mcpReady":true}

Two directories, easy to confuse:

  • ~/.claude/plugins/marketplaces/thedotmack — main plugin dir, holds the worker scripts
  • ~/.claude/plugins/cache/thedotmack/claude-mem/<version>/ — runtime dependency cache, no worker scripts

Prevention: when Claude Code slows down, check the worker first — not the API or the model. After upgrading claude-mem, actively hit the health endpoint to verify.


External Integrations

Q35: External integration returns 403 block / 403 Forbidden

Check in order:

  1. The token's group matches the model type
  2. Base URL is correct — Claude omits /v1, Codex requires it
  3. User-Agent header is present and matches the model type (don't reuse Claude's UA for Codex)
  4. The client is actually sending the header (some UIs accept input but never transmit it)
  5. Authorization is still in Bearer sk-*** format

Q36: User-Agent examples

Claude integrations:

"User-Agent": "claude-cli/2.0.76 (external, cli)"

Codex integrations:

"User-Agent": "codex_cli_rs/0.77.0 (Windows 10.0.26100; x86_64) WindowsTerminal"

Chinese model integrations (browser-style UA):

"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0"

Q37: Does the Base URL need /v1?

  • Claude integrations (Anthropic Messages protocol): https://your-api-url (no /v1)
  • Codex integrations (OpenAI Responses protocol): https://your-api-url/v1 (with /v1)

The most common mistake is appending /v1 to a Claude URL, or forgetting it on a Codex URL.

Q38: Five things to confirm before any external integration

Any one of these out of sync can cause 403 / 401 / model-not-available errors:

  • Group: which model's group the key belongs to
  • Protocol: client speaks Anthropic Messages or OpenAI Responses
  • Base URL: Claude no /v1, Codex yes /v1
  • Headers: external integrations need the right User-Agent
  • Model: some groups allow empty, others require an exact model ID

Q39: JetBrains IDE shows the plugin but returns 401

Check, in order:

  1. The IDE is reading stale local auth state (OAuth leftover)
  2. The key has been moved to the correct group
  3. The plugin overrode the local settings.json

Recommended: configure Claude Code or Codex via CC Switch on the host first, confirm the CLI works, then let the IDE reuse that environment.

Q40: JetBrains / Trae works in CLI but fails in IDE

The key isn't the problem — IDE-side config is. Check whether the IDE is reading the wrong config file, dropping headers, or applying extra restrictions on local proxies / certificates.

Q41: Trae still can't connect after updating Base URL

Check:

  1. The Claude / Codex URLs aren't swapped (Claude no /v1, Codex with /v1)
  2. The plugin actually supports custom URLs
  3. The current plugin version supports external integrations at all
  4. If Claude works but Codex doesn't, you're probably missing /v1 on Codex or still using a Claude model name

Codex CLI Specifics

Q42: What's the Base URL format for Codex CLI?

Codex's Base URL requires /v1, unlike Claude Code:

Claude Code: https://your-api-url       (no /v1)
Codex CLI  : https://your-api-url/v1    (with /v1)

Q43: Where are Codex CLI's config files? How do I configure manually?

Two files:

  • ~/.codex/config.toml (Windows: C:\Users\<user>\.codex\config.toml)
  • ~/.codex/auth.json (Windows: C:\Users\<user>\.codex\auth.json)

config.toml reference:

model_provider = "custom"
model = "gpt-5.4"
model_reasoning_effort = "high"
disable_response_storage = true

[model_providers.custom]
name = "custom"
base_url = "https://your-api-url/v1"
wire_api = "responses"
requires_openai_auth = true
model_context_window = 1000000
model_auto_compact_token_limit = 900000

auth.json reference:

{
  "OPENAI_API_KEY": "sk-***"
}

Q44: How do I enable 1M context for Codex CLI?

In ~/.codex/config.toml make sure you have:

model_context_window = 1000000
model_auto_compact_token_limit = 900000
  • model_context_window: usable context window set to 1,000,000
  • model_auto_compact_token_limit: triggers compaction before hitting the limit

Q45: Codex CLI reasoning is too slow

Change model_reasoning_effort in config.toml from high to medium or low:

  • low: fast — simple code gen or quick Q&A
  • medium: balanced — day-to-day work (recommended)
  • high: slow — complex algorithms or architecture design

Q46: Codex CLI says the API key is invalid

  1. Double-check the key in ~/.codex/auth.json
  2. Confirm the proxy has remaining balance and the token isn't expired

Q47: Can Claude Code and Codex CLI conflict if installed together?

No. Their config files are isolated. CC Switch can manage both:

  • Claude Code → ~/.claude/settings.json
  • Codex CLI → ~/.codex/config.toml + ~/.codex/auth.json

OpenClaw Specifics

Q48: What is OpenClaw? How do I install it?

OpenClaw Gateway is an AI proxy gateway with built-in support for messaging channels like Feishu, Telegram, and Discord. Default Web UI: http://127.0.0.1:18789/.

# Install
npm install -g openclaw@latest

# First-run wizard
openclaw onboard --install-daemon

In the wizard: choose QuickStart → skip provider selection → select all models → keep default model → choose a notification channel (Feishu / TG / Discord) → configure Skills and Hooks (session-memory recommended).

Q49: OpenClaw provider config returns 403 block

OpenClaw is an external client — different providers need their own group and User-Agent.

Claude provider:

API endpoint: https://your-api-url
Protocol: Anthropic Messages
Headers:
  "Authorization": "Bearer sk-***"
  "User-Agent": "claude-cli/2.0.76 (external, cli)"

Codex provider:

API endpoint: https://your-api-url/v1
Protocol: OpenAI Responses
Headers:
  "Authorization": "Bearer sk-***"
  "User-Agent": "codex_cli_rs/0.77.0 (Windows 10.0.26100; x86_64) WindowsTerminal"

Chinese model provider:

Headers:
  "Authorization": "Bearer sk-***"
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0"

Key reminder: don't reuse Claude's UA on a Codex provider, and don't omit the browser-style UA on Chinese model providers.

Q50: Can one OpenClaw instance host multiple models?

Yes. A single OpenClaw can host Claude, Codex, and Chinese models simultaneously. Each provider needs the matching group and User-Agent — no mixing.

Q51: Configuring the Feishu channel

  1. Go to open.feishu.cn, create a custom-built enterprise app, and enable the bot capability
  2. In permissions, filter by im and check all related scopes
  3. Create a version and publish it. Save the App ID and App Secret
  4. Enter App ID and App Secret in the OpenClaw wizard, or via CLI:
openclaw config set -- channels.feishu.appId "your-app-id"
openclaw config set -- channels.feishu.appSecret "your-app-secret"
  1. In the Feishu open platform, add a "Receive Message" event
  2. Create a new version and publish again — otherwise the subscription doesn't activate
  3. From the Feishu workspace, message the bot to get a pairing code, then run:
openclaw pairing approve feishu your-pairing-code

Note: OpenClaw must be running while configuring Feishu subscriptions — start it via openclaw gateway if needed.

Q52: OpenClaw group-message response policy

  • Reply to all messages: fine for private test groups
  • Only on @mention: best for multi-person work groups (recommended)
  • No group replies: DMs only

CC Switch and Config Management

Q53: CC Switch changes don't take effect

  1. Restart Claude Code (close the whole terminal window, not just open a new tab)
  2. Check whether system env vars are overriding CC Switch's config (env vars take precedence)
  3. If needed, delete ~/.claude and reconfigure

Q54: How do I switch back to the official channel and re-OAuth?

  1. Back up ~/.claude and ~/.claude.json
  2. Clear old sessions, history, and auth leftovers
  3. In CC Switch, switch to the official channel; or wipe the proxy config and run claude to log in

Advanced Configuration and Efficiency

Q55: Reducing token usage and unnecessary traffic

Merge into ~/.claude/settings.json:

{
  "ENABLE_TOOL_SEARCH": true,
  "skipWebFetchPreflight": true,
  "env": {
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
  • ENABLE_TOOL_SEARCH: cuts down tokens leaked by tool-call searches
  • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: disables telemetry and update checks
  • skipWebFetchPreflight: skip the WebFetch preflight (essential on domestic networks)

Q56: Using CLAUDE.md to boost efficiency

Create a CLAUDE.md at the project root with the tech stack, directory layout, and dev conventions. Claude Code auto-loads it as context on startup:

# Project name

## Tech stack
- Frontend: React + TypeScript
- Backend: Node.js + Express

## Layout
- src/ — source code
- tests/ — test files

## Conventions
- ESLint + Prettier
- Commits follow Conventional Commits

Accurate project context cuts token consumption noticeably and keeps Claude Code from re-asking about the structure.

  • context7: live tech documentation lookup
  • deepwiki: knowledge base access
  • playwright: browser automation
  • exa: intelligent search

Q58: Using hooks

Place hook scripts under ~/.claude/hooks/ (global) or .claude/hooks/ (per project):

  • before-tool-use: fires before a tool call
  • after-tool-use: fires after a tool call
  • user-prompt-submit: fires when the user submits a prompt

Q59: Custom commands

Create .md files under ~/.claude/commands/ or .claude/commands/. For example, ~/.claude/commands/review.md gets triggered by typing /review in a conversation.

Q60: Common commands

  • /model: switch model (opus / sonnet / haiku)
  • /model sonnet[1m]: switch to the 1M long-context variant
  • /cost: current session's token usage
  • /compact: compress context to free up space
  • /resume: resume a previous conversation
  • /clear: wipe the current conversation
  • /help: list all commands
  • /exit or press Ctrl + C twice: quit

Q61: General triage checklist

  1. Confirm group, Base URL, and User-Agent align (see Q38)
  2. Check for stale env vars (Win + Rsysdm.cpl, or inspect ~/.zshrc)
  3. Check for OAuth tokens in ~/.claude.json (clear with claude auth logout)
  4. Rewrite the config via CC Switch, close and reopen the terminal, retry
  5. For external integrations, run through the 5-item checklist (group, protocol, Base URL, headers, model)

On this page

OverviewInstallation and StartupQ1: First launch fails with "Unable to connect to Anthropic services"Q2: command not found: claudeQ3: permission denied / EACCES during install (Mac / Linux)Q4: permission denied during install (Windows)Q5: How do I remove an older npm install of Claude Code?Authentication and API KeysQ6: 401 Invalid API Key / token rejectedQ7: 401 token rejected — IDE or MCP overwrote the configQ8: 401 after switching providersQ9: OAuth login conflicts with API keyQ10: 401 Invalid API Key format — invisible characters in the keyQ11: 403 Missing API Key / config conflictQ12: Launch asks for authentication or shows a login promptQ13: Configuration precedenceNetwork and ConnectivityQ14: API Error (Connection error.)Q15: API Error (Request timed out.)Q16: WebFetch broken even though the site loads in a browserRequest ErrorsQ17: Returns 400 unrelated to message contentQ18: API Error 400 (not content-related)Q19: 413 Request body too largeQ20: 400 Invalid model nameQ21: 429 Rate Limit / quota exhaustedQ22: Overloaded / 500Q23: API Error: response exceeded the 32000Q24: 503 model_not_foundQ25: Context window exceeded — conversation truncatedQ26: Command timed out after 2m 0.0sPermissionsQ27: Permission denied — file read/write blockedQ28: skipAutoPermissionPrompt breaks Plan modeQ29: How does Claude Code's permission system work?Caching and BillingQ30: Duplicate cache creation causing duplicate chargesQ31: How do I enable 1-hour prompt caching?Q32: How do I see current token usage?claude-mem PluginQ33: Knowledge base empty, pending_messages piling upQ34: Claude Code commands hang — worker zombieExternal IntegrationsQ35: External integration returns 403 block / 403 ForbiddenQ36: User-Agent examplesQ37: Does the Base URL need /v1?Q38: Five things to confirm before any external integrationQ39: JetBrains IDE shows the plugin but returns 401Q40: JetBrains / Trae works in CLI but fails in IDEQ41: Trae still can't connect after updating Base URLCodex CLI SpecificsQ42: What's the Base URL format for Codex CLI?Q43: Where are Codex CLI's config files? How do I configure manually?Q44: How do I enable 1M context for Codex CLI?Q45: Codex CLI reasoning is too slowQ46: Codex CLI says the API key is invalidQ47: Can Claude Code and Codex CLI conflict if installed together?OpenClaw SpecificsQ48: What is OpenClaw? How do I install it?Q49: OpenClaw provider config returns 403 blockQ50: Can one OpenClaw instance host multiple models?Q51: Configuring the Feishu channelQ52: OpenClaw group-message response policyCC Switch and Config ManagementQ53: CC Switch changes don't take effectQ54: How do I switch back to the official channel and re-OAuth?Advanced Configuration and EfficiencyQ55: Reducing token usage and unnecessary trafficQ56: Using CLAUDE.md to boost efficiencyQ57: Recommended MCP extensionsQ58: Using hooksQ59: Custom commandsQ60: Common commandsQ61: General triage checklist