👻

Finding and Cleaning Up Orphan Claude Processes

Discover zombie Claude Code processes that are wasting resources. Learn how to detect and remove orphaned Claude sessions.

OrphanCleanupProcesses
Quick Command
$ claude-trace -j | jq '.orphaned_count'

!The Problem

Claude Code processes continue running after their parent terminal or editor session has closed, consuming resources unnecessarily.

?Common Causes

  • Terminal or VS Code crashed without properly closing Claude
  • Force-quitting an application running Claude
  • SSH disconnection without proper session cleanup
  • Bug in Claude's process management
  • Multiple Claude instances from different sources (CLI, IDE extension)

🔍How to Diagnose

Claude Trace automatically detects orphaned processes:

```bash
# Orphaned processes show PPID of 1
claude-trace -v

# JSON format for scripting
claude-trace -j | jq '.processes[] | select(.is_orphaned == true)'
```

In the menu bar app, orphaned processes are highlighted with a warning indicator.

Solution

1. **Use Claude Trace's cleanup feature**: Click "Kill All Orphans" in the menu bar dropdown

2. **Manual cleanup**:
   ```bash
   # Find orphaned Claude processes
   claude-trace -j | jq -r '.processes[] | select(.is_orphaned) | .pid' | xargs kill -9
   ```

3. **Verify cleanup worked**:
   ```bash
   claude-trace
   ```

🛡Prevention

- Use Claude Trace to monitor for orphans regularly
- Close Claude sessions properly before closing terminals
- Set up Claude Trace to launch at login for continuous monitoring
- Check for orphans after system wake from sleep

Monitor Claude Code in Real-Time

Get Claude Trace for instant visibility into every Claude process.

Get Claude Trace