Troubleshooting11 min read

Claude Code - Troubleshooting

SFEIR Institute

TL;DR

This Claude Code troubleshooting guide lists the most common problems, their causes, and tested solutions to resolve them quickly. You will find ready-to-use diagnostic commands, a quick resolution table, and the steps to follow when a problem persists after your correction attempts.

This Claude Code troubleshooting guide lists the most common problems, their causes, and tested solutions to resolve them quickly. You will find ready-to-use diagnostic commands, a quick resolution table, and the steps to follow when a problem persists after your correction attempts.

Claude Code troubleshooting encompasses all the techniques for identifying, diagnosing, and correcting malfunctions encountered while using this agentic coding tool. Claude Code relies on the Claude Sonnet 4 model by default and requires Node.js 18 or higher to function. over 70% of issues reported by users are resolved in under 5 minutes through methodical diagnosis.

How to quickly identify a problem with Claude Code?

Before looking for a solution, you need a reliable diagnosis. Open your terminal and run the following command to verify that Claude Code is properly installed:

claude --version

This command returns the installed version number. the stable version is Claude Code v1.0.32. If you get a "command not found" error, the problem is with the installation.

Then verify your API connection by launching a test conversation:

claude "Say hello"

If the response takes more than 30 seconds to arrive, the problem is likely network-related or tied to your API key. In practice, 85% of startup errors come from a missing or expired API key.

For a deeper look at the basics, see the installation and first launch guide which details each prerequisite.

Diagnostic commandWhat it verifiesExpected result
claude --versionInstalled versionv1.0.32 or higher
node --versionNode.js versionv18.0.0 minimum
claude config listActive configurationAPI key present
echo $ANTHROPIC_API_KEYEnvironment variableKey starting with sk-ant-

Key takeaway: Always run claude --version and node --version before any other troubleshooting action.

What are the most common problems and their solutions?

Here is the quick resolution table. You will find the 12 most frequent problems classified by category. Identify your symptom in the left column and apply the corresponding solution.

SymptomProbable causeSolution
"command not found: claude"Missing installation or incorrect PATHRun npm install -g @anthropic-ai/claude-code
"Invalid API key"Missing or expired API keyCheck the ANTHROPIC_API_KEY variable with echo $ANTHROPIC_API_KEY
Response stuck at "thinking..."Network timeout or oversized requestReduce context size or check your connection
"Rate limit exceeded"API quota exceeded (60 requests/min on free tier)Wait 60 seconds or upgrade to a higher tier
Claude does not see project filesWrong working directoryLaunch Claude Code from the project root with cd /path/project && claude
"EACCES permission denied" errorInsufficient npm global permissionsConfigure npm with npm config set prefix ~/.npm-global
Modifications not applied to filesRead-only file permissionsCheck permissions with ls -la and fix with chmod 644 file
"Context window exceeded"Conversation too long (>200,000 tokens)Use /clear to reset the context
Repeated crashes with no error messageOutdated Node.js version (<18)Update Node.js to version 22 LTS
Extreme slowness (>45 seconds per response)Unstable network or overloaded serverTest with curl -o /dev/null -w "%{time_total}" https://api.anthropic.com
Claude ignores the CLAUDE.md fileMisplaced file or incorrect syntaxPlace the file at the project root and verify the Markdown format
"Module not found" after updateCorrupted npm cacheRun npm cache clean --force && npm install -g @anthropic-ai/claude-code

Concretely, this table covers approximately 90% of cases encountered by users. To understand how agentic coding works and its mechanisms, see the dedicated guide.

Key takeaway: Check this table first - most problems are resolved with a single command.

How to resolve Claude Code installation errors?

Installation fails mainly for three reasons: incompatible Node.js version, insufficient system permissions, or package conflicts. Start by checking your environment:

node --version && npm --version

Node.js 18 is the minimum required. In practice, Node.js 22 LTS offers the best performance with Claude Code. If your version is lower, install the latest LTS:

# With nvm (recommended)
nvm install 22
nvm use 22

On macOS, the EACCES error occurs when npm tries to write to /usr/local/lib. the recommended solution is to reconfigure the global prefix:

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATH

After this configuration, re-run the installation:

npm install -g @anthropic-ai/claude-code

The average installation time is 45 seconds on a 100 Mbps fiber connection. If you encounter persistent problems, the complete installation and first launch guide covers each step in detail.

Key takeaway: Use Node.js 22 LTS and configure a dedicated npm prefix to avoid 80% of installation errors.

Why does Claude Code not recognize my API key?

The API key is the authentication point between your terminal and Anthropic's servers. An invalid key blocks all interaction. First verify its presence:

echo $ANTHROPIC_API_KEY

If the command returns nothing, the variable is not defined. Add it to your shell profile file:

# For zsh (macOS default)
echo 'export ANTHROPIC_API_KEY="sk-ant-your-key"' >> ~/.zshrc
source ~/.zshrc
API key problemVerificationCorrective action
Variable not definedecho $ANTHROPIC_API_KEY returns emptyExport the key in ~/.zshrc or ~/.bashrc
Expired key401 error in logsRegenerate the key on console.anthropic.com
Key from another providerDifferent prefix than sk-ant-Create a dedicated Anthropic key

In practice, 25% of users forget to source their profile file after adding the variable. Always run source ~/.zshrc after modification.

You can also configure the key directly in Claude Code via the essential slash commands. The /config command allows defining the key without modifying your profile files.

Key takeaway: Verify that the key starts with sk-ant- and that the profile file is properly sourced after modification.

How to handle context and memory problems?

Claude Code uses a context window of 200,000 tokens. When you exceed this limit, the tool loses the conversation thread or returns errors. Context management is a central aspect of how Claude Code works.

Monitor your context consumption through the indicator displayed in the terminal. When it exceeds 80%, run:

/clear

This command resets the conversation without losing your files. Concretely, a project with 500 JavaScript files consumes approximately 120,000 tokens on initial loading.

The CLAUDE.md file allows you to retain persistent instructions between sessions. Create it at your project root so Claude Code automatically retrieves your preferences. See the CLAUDE.md memory system guide to master this feature.

SituationTokens consumedRecommended action
Project < 50 files~30,000 tokensNo action needed
Project 50-200 files~80,000 tokensUse .claudeignore files
Project > 200 files~150,000 tokensSegment by folder and use /clear regularly
Conversation > 30 exchanges~180,000 tokensRun /clear and summarize the context

the .claudeignore file works like a .gitignore and reduces context consumption by 40 to 60% on large projects.

Key takeaway: Use /clear as soon as the context indicator exceeds 80% and configure a .claudeignore for large projects.

How to fix permission and security problems?

Claude Code applies a strict permissions and security model. By default, it asks for your approval before any file modification or shell command execution.

If Claude Code refuses to write to a file, check file system permissions:

ls -la target-file.ts

Recommended permissions are 644 for files and 755 for folders. Fix if needed:

chmod 644 target-file.ts
chmod 755 target-folder/

The "acceptEdits" permission mode allows you to speed up your workflow by automatically approving file modifications. Launch Claude Code with this option if you are working on a trusted project:

claude --allowedTools "Edit,Write"

To understand the different permission levels and choose the mode adapted to your context, explore the slash commands tips.

In practice, permission errors represent 15% of support tickets. The most frequent problem is a read-only .git directory that prevents Claude Code from creating commits.

Key takeaway: Configure permissions adapted to your trust level - strict mode for production, permissive mode for local development.

What advanced diagnostic tools to use?

When basic checks are not enough, you have advanced diagnostic tools. Enable verbose mode to get detailed logs:

claude --verbose

This mode displays each API call, tokens consumed, and response times. A response time exceeding 10,000 ms indicates a network problem.

You can also examine Claude Code's system logs. On macOS, they are located in the configuration directory:

ls -la ~/.claude/logs/
Diagnostic toolUsageWhen to use it
claude --verboseReal-time detailed logsIntermittent problems
claude config listShow active configurationAfter an update
curl https://api.anthropic.com/v1/messagesTest API connectivityNetwork errors
/statusCurrent session stateToken overconsumption

To better understand agentic coding principles and its glossary, see the dedicated resource. You will find definitions of technical terms used in error messages.

62% of developers using AI coding tools encounter at least one configuration problem per month.

Key takeaway: Enable verbose mode as your first reflex for any problem not resolved by the quick resolution table.

How to optimize Claude Code performance?

Claude Code latency depends on three factors: context size, network quality, and request complexity. Measure your baseline latency with this command:

time claude "Reply OK"

A time under 3 seconds is normal. Beyond 10 seconds, investigation is needed. Here are the concrete optimizations:

  1. Reduce context size with a targeted .claudeignore file
  2. Close long conversations with /clear after 20 exchanges
  3. Limit open files to those strictly necessary
  4. Use precise requests rather than vague instructions
  5. Prefer wired network over Wi-Fi for long sessions

In practice, a well-configured .claudeignore reduces average response time from 8 seconds to 3 seconds on a 1,000-file project.

The Claude Code training offered by SFEIR Institute teaches you in 1 day to configure and optimize your environment. You will practice on concrete labs covering installation, advanced configuration, and troubleshooting.

If you want to go further in AI-assisted development, the AI-Augmented Developer SFEIR Institute training covers in 2 days the complete integration of AI tools into your daily workflow. The advanced version of this training deepens in 1 day prompt engineering and automation techniques.

See the Claude Code silo home page to access all available resources.

Key takeaway: a well-configured .claudeignore and precise requests reduce latency by 50 to 70%.

When should you contact Anthropic support?

Contact support when you have exhausted the solutions in this guide without resolving the problem. Here are the criteria for escalation:

  1. The problem persists after a complete reinstallation
  2. You observe server-side 500 errors for more than 30 minutes
  3. Your API key is valid but systematically rejected
  4. Claude Code produces incoherent results in a reproducible manner
  5. You encounter data loss (files modified without your approval)

Prepare this information before contacting support:

  • Claude Code version (claude --version)
  • Node.js version (node --version)
  • Operating system and version
  • Verbose logs from the problematic session
  • Steps to reproduce the problem

The official channel is the Anthropic GitHub repository. Open an issue with the "Bug Report" template and attach your anonymized logs. The average response time is 48 hours for critical issues.

For problems related to first conversations with Claude Code, the dedicated guide resolves most initial blockers.

Key takeaway: Escalate to support only after testing all solutions in this guide and precisely documenting the problem.

Are there errors specific to Claude Code updates?

Claude Code updates can introduce temporary incompatibilities. Run the update with the standard command:

npm update -g @anthropic-ai/claude-code

After each update, verify that the CLAUDE.md file is still compatible. Major versions can change the expected format. See the CLAUDE.md memory system guide for current specifications.

VersionNotable changeRequired action
v1.0.0 -> v1.0.15New configuration formatMigrate claude.json to the new schema
v1.0.15 -> v1.0.25.claudeignore support addedCreate a .claudeignore file at the root
v1.0.25 -> v1.0.32Context window extended to 200K tokensNo action needed

Concretely, 12% of reported problems occur within 24 hours of an update. Wait 24 to 48 hours after a major release before updating a production environment.

If an update breaks your installation, roll back to the previous version:

npm install -g @anthropic-ai/claude-code@1.0.25

Key takeaway: Test each update on a secondary project before applying it to your main environment.

Recommended training

Claude Code Training

Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.

View program