🔥

Why is Claude Code Using So Much CPU?

Diagnose and fix high CPU usage from Claude Code CLI. Learn what causes CPU spikes and how to stop runaway processes.

CPUPerformanceDebugging
Quick Command
$ claude-trace -v

!The Problem

Claude Code is consuming excessive CPU resources, causing your Mac to heat up, fans to spin loudly, or other applications to become sluggish.

?Common Causes

  • File watcher monitoring too many files (e.g., node_modules, large repos)
  • Stuck or infinite loop in code generation
  • Multiple concurrent Claude sessions competing for resources
  • Background indexing or analysis tasks
  • Memory pressure causing swap thrashing

🔍How to Diagnose

Use Claude Trace to identify which specific process is consuming CPU:

```bash
# Quick overview of all Claude processes
claude-trace

# Watch mode for real-time monitoring
claude-trace -w 2

# Verbose mode to see project names
claude-trace -v
```

Look for processes showing sustained CPU usage above 80%. The STATE column shows if the process is actively running (R) or sleeping (S).

Solution

1. **Identify the culprit**: Use `claude-trace -v` to see which project is causing the spike

2. **Kill the runaway process**: Click the process in Claude Trace menu bar and select "Kill Process" or use:
   ```bash
   kill -9 <PID>
   ```

3. **Restart Claude in that project**: Close the terminal/editor session and reopen

4. **Check for file watcher issues**: If it recurs, add problematic directories to `.claudeignore`

🛡Prevention

- Create a `.claudeignore` file in your project root to exclude node_modules, .git, and build directories
- Use Claude Trace's notification thresholds to get alerted before CPU spikes become critical
- Regularly check for orphaned Claude processes with `claude-trace`

Monitor Claude Code in Real-Time

Get Claude Trace for instant visibility into every Claude process.

Get Claude Trace