`, or run `/debug [issue]` mid-session to start logging and have Claude diagnose from the log. Look up exact messages in the [error reference](https://code.claude.com/docs/en/errors); when CLAUDE.md, settings, hooks, MCP servers, or skills don't take effect, follow [Debug your configuration](https://code.claude.com/docs/en/debug-your-config). [Debug Quick Commands](#debug-quick-commands) also covers safe mode and `/feedback`.
>
> **Q: Do I need to reboot after editing PATH?**
>
> > **A: No reboot required, but you must open a new terminal window.** A terminal inside an editor such as VS Code or a JetBrains IDE takes its PATH from the editor, so quit and reopen the editor itself.
Debug Quick Commands
_`claude doctor` checks the install, auto-updates, settings files, and Remote Control eligibility. Debug logs go to `~/.claude/debug/.txt` (or the `--debug-file` path), and only while debug logging is on._
> [!Note]
>
> ```bash
> claude # Open Claude UI (if on PATH)
> claude --version # Show the installed CLI version
> claude update # Native installer: check for and install an update
>
> claude doctor # Read-only install and settings diagnostics
> /doctor # Full checkup from an interactive session
> /status # Active login and settings sources
>
> claude --debug # Launch with diagnostic logging
> claude --debug-file ./claude-debug.log
> /debug [issue] # Start logging mid-session; Claude reads the log
> claude --safe-mode # Start with your customizations disabled
> /feedback # Report a problem to Anthropic
>
> Get-Command claude -All # Windows PowerShell: find conflicting installs
> where.exe claude # Windows CMD/PowerShell
> which -a claude # macOS/Linux (bash/zsh)
> ```
|
Path Temp Fix
**The native launcher normally lives in `.local/bin`. Add that directory for the current shell, then reinstall if the launcher is absent.**
> [!Note]
>
> #### Windows (CMD):
>
> ```bash
> set PATH=%USERPROFILE%\.local\bin;%PATH%
> where.exe claude
> claude --version
> ```
>
> #### Windows (PowerShell):
>
> ```powershell
> $env:Path = "$env:USERPROFILE\.local\bin;$env:Path"
> Get-Command claude -All
> claude --version
> ```
>
> #### Linux/MacOS (bash/zsh)
>
> ```bash
> export PATH="$HOME/.local/bin:$PATH"
> which -a claude
> claude doctor
> ```
For an npm installation only, the launcher is under the global npm prefix. Prefer migrating with `claude install` (`claude install stable` also moves auto-updates to the stable channel); otherwise inspect the prefix with `npm prefix -g` and add its executable directory to `PATH`.
|
Windows Path Perm Fix
**Replace `` with your own Windows username (without the angle brackets)**
- **Start → type: Environment Variables**
- **Open Edit the system environment variables → Environment Variables**
- **Under User variables for ``, select `Path` → `Edit` → `New`, then add:**
```path
C:\Users\\.local\bin
```
> **npm installation only:**
```path
C:\Users\\AppData\Roaming\npm
```
- **Remove duplicates, any entry containing `%PATH%`, and stray quotes (`"`). Click `OK`.**
- **Open a `new` Command Prompt/PowerShell and verify:**
```C
where.exe claude
claude doctor
```
> [!Tip]
>
> ### Optional Run directly (when PATH is broken)
>
> > **Windows (PowerShell/cmd)**
>
> ```powershell
> & "$env:USERPROFILE\.local\bin\claude.exe" --version
> & "$env:USERPROFILE\.local\bin\claude.exe" doctor
> ```
>
> > **npm installation:**
>
> ```powershell
> & "$env:APPDATA\npm\claude.cmd" doctor
> ```
>
> The `.cmd` launcher also sidesteps `running scripts is disabled on this system` (`PSSecurityException`) for `claude.ps1` or `npm.ps1`. To allow npm's `.ps1` shims instead, run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`.
>
> > **`'claude' is not recognized` right after an update (native install):**
>
> If `%USERPROFILE%\.local\bin` is on `PATH` but has no `claude.exe`, a failed update may have left only a `claude.exe.old.` backup. Restore the newest backup, or rerun `irm https://claude.ai/install.ps1 | iex` if there is none:
>
> ```powershell
> Get-ChildItem "$env:USERPROFILE\.local\bin\claude.exe.old.*" | Sort-Object Name | Select-Object -Last 1 | Rename-Item -NewName claude.exe
> claude --version
> ```
|
Installation / Node.js Issues
**Native repair (recommended; no Node.js required)**
```bash
claude doctor
claude install --force stable
```
The channel you pass also becomes your auto-update channel. `latest` is the default; a newly launched model can need a newer version than `stable` serves.
**Package-manager installs**
```bash
brew upgrade claude-code # or claude-code@latest
winget upgrade Anthropic.ClaudeCode
sudo apt update && sudo apt upgrade claude-code # Debian/Ubuntu
sudo dnf upgrade claude-code # Fedora/RHEL
apk update && apk upgrade claude-code # Alpine
```
**npm install (Node.js 22+)**
```bash
node --version
npm --version
npm install -g @anthropic-ai/claude-code@latest
```
> [!Warning]
> **npm 12 skips Claude Code's postinstall step by default**, so `claude` stays a placeholder that prints `Error: claude native binary not installed.` (on Windows the shell can't run it). Switch to the native installer and run `npm uninstall -g @anthropic-ai/claude-code`, or allow the step for your user and reinstall (update npm 12.0.x to 12.1+ first):
>
> ```bash
> npm config get allow-scripts # add any packages listed here to the next command's list
> npm config set "allow-scripts=@anthropic-ai/claude-code" --location=user
> npm install -g @anthropic-ai/claude-code@latest
> ```
>
> The same error appears when optional dependencies are skipped (`--omit=optional`, or `optional=false` in `.npmrc`), because the native binary ships as one.
Do not use `sudo npm install -g`. If two installations conflict, locate both before removing the one you no longer want.
|
Authentication Issues
> Subscription users should authenticate through the browser flow. API keys and third-party provider credentials are separate deployment paths.
```bash
claude auth status
claude auth login
claude auth login --console # Console/API billing instead of subscription login
claude auth logout # Then log in again to reset a broken login
```
If a subscription login unexpectedly behaves like API billing, another credential is outranking it. Claude Code uses the first it finds: a cloud provider (`CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX`, or `CLAUDE_CODE_USE_FOUNDRY`), `ANTHROPIC_AUTH_TOKEN`, an approved `ANTHROPIC_API_KEY` (always used with `-p`; toggle **Use custom API key** in `/config`), `apiKeyHelper`, `CLAUDE_CODE_OAUTH_TOKEN`, a profile named in `ANTHROPIC_PROFILE` or federation credentials, and only then your `/login`. A signed-in Claude apps gateway session outranks all of them. `/status` (or `authMethod` in `claude auth status`) shows which one is active. Do not print secret values into logs. While API-key or provider auth is active, the subscription-only features listed under [Initial Setup](#initial-setup) stay unavailable.
If the browser doesn't open or ends on a failed `localhost` page (WSL2, SSH, containers), press `c` at the login prompt to copy the URL, open it on your local machine, and paste the code it shows at `Paste code here`; if pasting does nothing, use `claude auth login`, which reads the code from standard input. On macOS, if `claude doctor` warns `macOS Keychain is not writable`, run `security unlock-keychain ~/Library/Keychains/login.keychain-db`.
Use `claude --debug-file ./claude-auth-debug.log` for a reproducible error report, then remove credentials from that log before sharing it.
|
|
**Inspect permissions**
```bash
/permissions
```
The UI shows each allow/ask/deny rule and its source, and also opens mid-turn (changes apply from Claude's next tool call). In auto mode, **Recently denied** lists blocked actions (`r` retries one with manual approval), and the **Auto mode** tab edits the classifier rules. To reset a scope, edit the originating `settings.json` and remove the rules or set empty arrays:
```json
{
"permissions": {
"allow": [],
"ask": [],
"deny": []
}
}
```
|
MCP (Model Context Protocol) Issues
> **Debug MCP servers**
Start with `/mcp`: it shows each server's status, approves `.mcp.json` servers whose approval prompt was dismissed, and offers **Reconnect** for a server that connects but lists no tools. A server that fails to start often has a relative path in `command` or `args`, which resolves against your launch directory; use absolute paths.
```bash
claude --debug='mcp'
claude --debug-file ./claude-mcp-debug.log
```
> **List & remove MCP servers**
```bash
claude mcp list
claude mcp get
claude mcp login
claude mcp logout
claude mcp remove
```
|
Repair or Reinstall (Windows / PowerShell)
Start with a non-destructive repair. This preserves settings, MCP configuration, credentials, sessions, and project history:
```powershell
claude doctor
claude install --force stable # or latest; this also sets your auto-update channel
Get-Command claude -All
claude --version
```
If `claude` itself won't start, rerun the installer with `irm https://claude.ai/install.ps1 | iex`. For WinGet, use `winget upgrade Anthropic.ClaudeCode` or reinstall that package. For npm, use Node.js 22+ and `npm install -g @anthropic-ai/claude-code@latest`; on npm 12, follow the [npm 12 warning](#installation--nodejs-issues) first.
> [!Caution]
> Do not delete `~/.claude`, `~/.claude.json`, project `.claude/`, or `.mcp.json` as a routine installation fix. Those paths contain settings, credentials, MCP configuration, trust decisions, session history, and data shared by the CLI, IDE integrations, and Desktop. Follow the [official uninstall instructions](https://code.claude.com/docs/en/setup#uninstall-claude-code) and back up anything you need before intentionally removing user data.
|
One‑Shot Health Check (copy/paste)
**Windows (PowerShell):**
```powershell
Get-Command claude -All
claude --version
claude doctor
claude auth status
```
**macOS/Linux (bash/zsh):**
```bash
which -a claude
claude --version
claude doctor
claude auth status
```
|
---
Appendix: Useful Paths
- **Native launcher:** Windows `%USERPROFILE%\.local\bin\claude.exe`; macOS/Linux/WSL `~/.local/bin/claude`
- **Native versions:** `%USERPROFILE%\.local\share\claude\` or `~/.local/share/claude/versions/`
- **User settings:** `~/.claude/settings.json`
- **Claude state, sessions, and caches:** `~/.claude/` (`CLAUDE_CONFIG_DIR` relocates it together with `~/.claude.json`)
- **Credentials:** macOS Keychain; Linux and Windows `~/.claude/.credentials.json` (also the macOS fallback when the Keychain rejects writes)
- **Debug logs:** `~/.claude/debug/.txt` while debug logging is on, unless `--debug-file` sets a path
- **Global state and user/local MCP data:** `~/.claude.json` (not the user settings file)
- **Project settings:** `.claude/settings.json` and private `.claude/settings.local.json`
- **Shared project MCP:** `.mcp.json`
- **npm bin:** Windows `%APPDATA%\npm`; macOS/Linux `$(npm prefix -g)/bin`
|
Best Practices
> Curated guidance for safe, fast, and correct use of the Claude Code CLI and interactive REPL.
Effective Prompting
```bash
# Good: Specific and detailed
claude "Review UserAuth.js for security vulnerabilities, focusing on JWT handling"
# Bad: Vague
claude "check my code"
```
Tip: `claude "query"` starts the interactive REPL pre-seeded with your prompt; `claude -p "query"` runs **print mode** (non‑interactive) and exits.
---
Security Best Practices
1. **Start with minimal permissions**
- Prefer explicit allows and denies, either on the CLI or in settings files.
- `--allowed-tools` only pre-approves tools. To remove tools, use `--tools` (built-in tools) or `--disallowed-tools` (also MCP tools, e.g. `"mcp__*"`).
```bash
# Pre-approve only what this run needs; everything else follows the permission mode
claude --allowed-tools "Read" "Edit" "Bash(npm run test *)"
# Make only these built-in tools available
claude --tools "Read,Edit,Bash"
```
Or commit a project policy at `.claude/settings.json`:
```json
{
"permissions": {
"allow": ["Read", "Edit", "Bash(npm run test *)"],
"deny": [
"WebFetch",
"Bash(curl *)",
"Read(./.env)",
"Read(./secrets/**)"
]
}
}
```
New interactive terminal and VS Code sessions start in **auto mode** unless `permissions.defaultMode` or `--permission-mode` says otherwise: a classifier approves or blocks actions instead of prompting you, and broad allow rules that permit arbitrary code execution (such as `Bash(*)` or wildcarded interpreters) are set aside. Put every "never" rule in `permissions.deny` or a hook. To approve each action yourself, use `"defaultMode": "default"` or `--permission-mode manual`; `claude -p` runs with no configured mode already start in Manual mode.
2. **Handle secrets correctly**
- Use a secret manager to inject environment variables for Agent SDK/automation flows; do not put literal keys in commands, settings, shell history, or repositories.
- In the interactive REPL, prefer `/login` instead of configuring an API key unless API/provider billing is intentional.
- Deny access to sensitive files in settings (replaces older `ignorePatterns`):
```json
{
"permissions": {
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"]
}
}
```
3. **Audit permissions regularly**
```bash
/permissions
```
The browser shows merged allow/ask/deny rules and their user, project, local, plugin, or managed source.
4. **Avoid bypass modes in production**
- Do **not** use `--dangerously-skip-permissions` outside isolated/dev sandboxes.
- For unattended runs, restrict tools with `--tools`, pre-approve narrowly with `--allowed-tools`, and add `--permission-mode dontAsk` so anything else is refused; keep deny rules and the sandbox in place where supported.
- Run scripted, CI, and cron jobs as `claude --bare -p ...`: without `--bare`, `-p` runs the repository's hooks and `.mcp.json` servers with no workspace-trust dialog. Bare mode skips them and never reads your claude.ai login or keychain, so supply `ANTHROPIC_API_KEY`, an `apiKeyHelper` via `--settings`, or cloud-provider credentials.
---
1. **Use machine‑readable output in automations**
```bash
claude -p "summarize this error log" --output-format json
# valid: text | json | stream-json
```
2. **Bound non‑interactive work**
```bash
claude -p "run type checks and summarize failures" --effort low --max-turns 3 --max-budget-usd 1.00
```
Effort is the main control for how long Claude thinks; adaptive-reasoning models (such as Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable) ignore positive `MAX_THINKING_TOKENS` values.
3. **Keep sessions tidy**
In `~/.claude/settings.json`:
```json
{
"cleanupPeriodDays": 20
}
```
4. **Limit context scope**
```bash
# Focus on one package: start Claude there (loads that subtree plus ancestor CLAUDE.md files)
cd packages/api && claude
# --add-dir grants access to more directories; use it only when the task spans them
claude --add-dir ../shared
```
From a monorepo root, `claudeMdExcludes` skips CLAUDE.md files for packages you never work in. See the [large codebases guide](https://code.claude.com/docs/en/large-codebases).
5. **Pick the right model and effort**
- CLI aliases: `--model opus` (Opus 5.5 on the Anthropic API), `sonnet`, `haiku`, `fable`, `best`, or `opusplan`.
- Opus 5.5, Sonnet 5.5, and Haiku 5.5 default to `medium` effort: use `/effort high` or `xhigh` for tricky work, save `max` for hard problems (it tends to overthink ordinary tasks), and select `fable` (Fable 5.1) explicitly for the hardest, longest-running tasks.
- For reproducibility in settings, pin a full model ID only when automatic family upgrades are undesirable.
6. **Use rendering and accessibility controls deliberately**
- Use `--ax-screen-reader` for flat screen-reader-friendly output and `/config` for theme, motion, and terminal behavior instead of copying undocumented environment toggles.
7. **Inspect usage by source**
```bash
/usage
```
On Pro, Max, Team, and Enterprise plans, `/usage` breaks down recent usage by skills, subagents, plugins, MCP servers, and your heaviest `/loop` tasks, and flags costly patterns such as max effort or always-on context; press `f` to apply its fixes. When a claude.ai usage limit resets, a waiting session continues automatically unless you turn off "Continue automatically at usage limit" in `/config`.
8. **Keep the prompt cache working for you**
- A 200K+ token terminal conversation left idle for about 54 minutes is compacted before its one-hour cache expires, so your next message doesn't reprocess it all. Turn this off with `Idle compaction` in `/config` (or `"idleCompaction": false`); `CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS` changes the threshold.
- API-key and cloud-provider sessions cache for 5 minutes by default; `"promptCacheTtl": "1h"` keeps the main conversation cached through longer breaks (1-hour cache writes cost more), and `subagentPromptCacheTtl` does the same for subagents.
---
Monitoring & Alerting
**1) Health checks**
Use the built‑in **doctor** command to verify installation and environment.
```bash
# Every 15 minutes (a crontab entry must stay on one line)
*/15 * * * * "$HOME/.local/bin/claude" doctor >/dev/null 2>&1 || mail -s "Claude Code doctor failed" admin@company.com /tmp/daily-analysis.json
```
**3) Telemetry (optional)**
Claude Code emits OpenTelemetry metrics/events that you can ship to your observability stack (Datadog, Honeycomb, Prometheus/Grafana, etc.):
```bash
export CLAUDE_CODE_ENABLE_TELEMETRY=1 # required
export OTEL_METRICS_EXPORTER=otlp # otlp | prometheus | console | none
export OTEL_LOGS_EXPORTER=otlp # otlp | console | none
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector.example.com:4317
```
Set these in your shell, the `env` block of `~/.claude/settings.json`, managed settings, or a `--settings` file; Claude Code ignores them in a repository's `.claude/settings.json` and `.claude/settings.local.json` (`/status` and `claude doctor` list ignored variables). The `claude_code.session.count` metric confirms export works, and `tool_decision` events record permission and auto-mode decisions (`classifier_verdict`, `permission_mode`). Prompts stay redacted unless `OTEL_LOG_USER_PROMPTS=1`; if you enable it, mask `prompt_text` wherever you mask `prompt`. `OTEL_METRICS_INCLUDE_REPOSITORY=true` tags metrics and events with the repository. See [monitoring usage](https://code.claude.com/docs/en/monitoring-usage).
**4) Alert and runbook links**
A `claude-cli://open?repo=&q=` link in an alert, dashboard, or runbook opens Claude Code in your local clone of that repository with the investigation prompt filled in, unsent until you press Enter. The link handler registers once you send a prompt in an interactive session on that machine; GitHub Markdown strips such links. See [Launch sessions from links](https://code.claude.com/docs/en/deep-links).
---
Collaboration Best Practices
Team Workflows
**1) Share versioned configuration**
`.claude/settings.json` (checked into the repository):
```json
{
"permissions": {
"allow": [
"Read",
"Edit",
"Bash(npm run lint)",
"Bash(npm run test *)"
],
"deny": [
"WebFetch",
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
},
"model": "sonnet"
}
```
Committed `deny` rules apply right away; committed `allow` rules and hooks wait until each teammate accepts the workspace-trust dialog (a `-p` run without `--bare` runs the hooks without asking, but skips those allow rules in a folder never trusted on that machine, such as a CI checkout). Claude Code ignores `autoMode` and OpenTelemetry exporter variables in project settings, so keep them out of this file.
A family alias such as `sonnet` tracks the newest model on the Anthropic API; on cloud providers it resolves to a built-in default that can lag (Sonnet 4.5 on Bedrock), so pin `ANTHROPIC_DEFAULT_*_MODEL` or a full model ID there or whenever reproducibility matters (see [Cloud Providers and Gateways](#cloud-providers-and-gateways)).
**2) Documentation automation**
```bash
# Update docs with explicit tasks
claude "Update README.md to reflect the latest API endpoints and examples."
claude "Generate TypeScript types from schema.prisma and write to /types."
```
**3) Code review standards**
```bash
# Review a local diff with constrained tools. Put the prompt first: multi-value options
# (--tools, --allowed-tools, --add-dir) would swallow a prompt placed after them.
git fetch origin main
git diff origin/main...HEAD > /tmp/diff.patch
claude "Review /tmp/diff.patch using team standards:
- Security best practices
- Performance considerations
- Code style compliance
- Test coverage adequacy" \
--tools "Read,Grep,Bash" \
--allowed-tools "Read" "Grep" "Bash(git diff *)" "Bash(git log *)"
```
Knowledge Sharing
**1) Project runbooks**
```bash
claude "Create a deployment runbook for this app: steps, checks, rollback."
claude "Document onboarding for new developers: setup, commands, conventions."
```
**2) Architecture docs**
```bash
claude "Update architecture docs to reflect new microservices."
claude "Create sequence diagrams for the authentication flow."
```
> Tip: Keep durable context in **CLAUDE.md** at the project root. In the REPL, use `/memory` to manage it and `@path` to import file content into prompts.
---
Common Pitfalls to Avoid
Security
**❌ Don’t**
- Use `--dangerously-skip-permissions` on production systems
- Hard‑code secrets in commands/config
- Grant overly broad permissions (e.g., `Bash(*)`)
- Run with elevated privileges unnecessarily
**✅ Do**
- Store secrets in env vars and credential helpers
- Start from minimal `permissions.allow` and expand gradually
- Audit with `/permissions` and review the originating settings files
- Isolate risky operations in containers/VMs
**❌ Don’t**
- Load an entire monorepo when you only need a package
- Use `max` effort or unbounded turns/spend for simple tasks
- Ignore session cleanup
**✅ Do**
- Start `claude` in the package you need; use `--add-dir` only to grant extra directories
- Right‑size with `--effort`, `--max-turns`, and `--max-budget-usd`
- Set `cleanupPeriodDays` to prune old sessions
Workflow
**❌ Don’t**
- Skip project context (`CLAUDE.md`)
- Use vague prompts
- Ignore errors/logs
- Automate without testing
**✅ Do**
- Maintain and update `CLAUDE.md`
- Be specific and goal‑oriented in prompts
- Monitor via logs/OTel as appropriate
- Test automation in safe environments first
---
Third-Party Integrations
Provider Setup Examples
Use provider setup examples when connecting Claude Code to Anthropic-compatible gateways or third-party model providers. The pattern is usually:
1. Install Claude Code.
2. Set the provider base URL and authentication token.
3. Select the provider model names Claude Code should use.
4. Launch `claude` and run `/status` to confirm the provider, base URL, and proxy the session is using.
Cloud Providers and Gateways
| Provider | Setup |
| --- | --- |
| Amazon Bedrock | Pick **3rd-party platform** → **Amazon Bedrock** at the login prompt, or run `/setup-bedrock`. Manual: `CLAUDE_CODE_USE_BEDROCK=1` (plus `AWS_REGION` if your AWS profile sets none). |
| Google Cloud's Agent Platform (formerly Vertex AI) | Same login-prompt wizard, or `/setup-vertex`. Manual: `CLAUDE_CODE_USE_VERTEX=1`, `CLOUD_ML_REGION=global`, `ANTHROPIC_VERTEX_PROJECT_ID`. |
| Claude Platform on AWS | `CLAUDE_CODE_USE_ANTHROPIC_AWS=1`, `ANTHROPIC_AWS_WORKSPACE_ID`, `AWS_REGION`, plus AWS credentials or `ANTHROPIC_AWS_API_KEY`. |
| Microsoft Foundry | `CLAUDE_CODE_USE_FOUNDRY=1` and `ANTHROPIC_FOUNDRY_RESOURCE` (no wizard). |
| Claude apps gateway | Set `forceLoginMethod: "gateway"` and `forceLoginGatewayUrl` in managed settings (or in `~/.claude/settings.json` on a machine without managed settings), then run `/login`. |
On the four cloud providers above, aliases resolve to built-in defaults that can lag the newest release, so pin `ANTHROPIC_DEFAULT_FABLE_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL`. See the [enterprise deployment overview](https://code.claude.com/docs/en/third-party-integrations).
Behind a custom `ANTHROPIC_BASE_URL`:
- Models with a 1M context window (Opus 4.7+, Sonnet 5+, Haiku 5.5, Fable) use it. If the gateway stops at 200K, run `/autocompact 200k` (saved per model) or set `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`.
- Tool search is on; if the gateway rejects it, Claude Code retries without it. `ENABLE_TOOL_SEARCH=false` loads all tools upfront instead.
- If session titles, memory recall, or prompt hooks fail because the gateway rejects structured outputs, set `CLAUDE_CODE_DISABLE_STRUCTURED_OUTPUTS=1`.
> [!Note]
> Anthropic doesn't support routing Claude Code to non-Claude models. Features such as effort levels and extended thinking depend on recognizing Claude model IDs, so with providers like DeepSeek some may behave differently or not work; report problems to the provider.
DeepSeek Integration
1. ###### Install Claude Code with the native installer
```bash
curl -fsSL https://claude.ai/install.sh | bash
```
2. ###### Configure the current DeepSeek Anthropic-compatible endpoint
```bash
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN="$DEEPSEEK_API_KEY"
export ANTHROPIC_MODEL='deepseek-flash[1m]'
export ANTHROPIC_DEFAULT_OPUS_MODEL='deepseek-flash[1m]' # or 'deepseek-v4-pro[1m]' (billed at V4 Pro prices)
export ANTHROPIC_DEFAULT_SONNET_MODEL='deepseek-flash[1m]'
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432
```
3. ###### Launch `claude`
The provider credentials and base URL select DeepSeek billing and disable Claude.ai subscription-only features for that process. Use `deepseek-flash`: `deepseek-chat` and `deepseek-reasoner` were retired in July 2026, and `deepseek-v4-flash` is only a compatibility name routed to V4.1 Flash. An agent's own `model:` (such as `opus`) overrides `CLAUDE_CODE_SUBAGENT_MODEL` unless you also set `CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1`. Re-check the [official DeepSeek Claude Code integration guide](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code/) before pinning model names.