yanicklandry/claude-process-manager

โ˜… 0Forks 0ShellGitHub โ†—Compare

README

cproc - Claude Process Manager

A command-line utility to list, monitor, and manage processes spawned by Claude AI assistant in terminal environments, with additional system monitoring capabilities.

Current Status: โœ… Installed and working at /Users/yanick/bin/claude-process-manager/ with symlink ~/bin/cproc

Overview

When using Claude in terminal applications, it often spawns background processes that can consume significant system resources. This tool helps you:

  • ๐Ÿ“‹ List all Claude-spawned processes with their working directories
  • ๐Ÿ›‘ Kill specific processes or all Claude processes at once
  • ๐Ÿ“Š Monitor system resource usage and active network listeners
  • ๐Ÿ“ View working directories of any running process

How is this different from claude process?

While Claude may have a built-in claude process command, cproc offers several advantages:

Feature claude process cproc
Availability May not exist or be limited โœ… Always available as standalone tool
Working Directories โŒ Not shown โœ… Shows where each process is running from
Process Hierarchy โŒ Limited โœ… Shows parent-child relationships
System Monitoring โŒ Claude-only โœ… System-wide resource monitoring
Network Ports โŒ Not included โœ… Shows active development servers
Bulk Operations โŒ Limited โœ… Kill multiple processes or all at once
Cross-platform โŒ Claude-dependent โœ… Works independently
Customizable โŒ No โœ… Open source, modify as needed

Key Differences:

  • ๐Ÿ—‚๏ธ Directory Context: cproc shows exactly which folder each process is running from
  • ๐Ÿ”— Process Tree: See parent shell processes and their children
  • ๐Ÿ“Š Resource Usage: Monitor memory consumption and system impact
  • ๐ŸŒ Network Awareness: Check which ports your development servers are using
  • โšก Bulk Management: Kill all Claude processes with one command
  • ๐Ÿ”ง Standalone: Works even if Claude's built-in commands are unavailable

Example Comparison:

# If claude process shows:
# PID 12345: python3

# cproc shows:
# ๐Ÿ“‹ Shell Process (PID: 12340):
#    Command: /bin/zsh -c -l source ~/.claude/shell-snapshots/...
#    ๐Ÿ“ Working Directory: /Users/yanick/my-project
#    ๐Ÿ‘ถ Child processes:
#       โ”œโ”€โ”€ PID: 12345 - python3 launch.py --api --listen
#       โ”‚   ๐Ÿ“ /Users/yanick/my-project

Installation

Quick Setup

  1. Clone this repository:

    git clone https://github.com/yanicklandry/claude-process-manager.git ~/bin/claude-process-manager
  2. Make the script executable:

    chmod +x ~/bin/claude-process-manager/cproc.sh
  3. Make sure ~/bin is in your PATH (add to ~/.zshrc or ~/.bashrc if needed):

    export PATH="$HOME/bin:$PATH"
  4. Create a symlink for easy access:

    ln -sf ~/bin/claude-process-manager/cproc.sh ~/bin/cproc

Manual Installation

  1. Download cproc.sh and place it in a directory in your PATH
  2. Make it executable:
    chmod +x /path/to/cproc.sh

Usage

Basic Commands

# List all Claude-spawned processes (default command)
cproc
cproc list
cproc ls
cproc l

# Kill specific process(es)
cproc kill 12345
cproc kill 12345 67890
cproc k 12345

# Kill ALL Claude processes
cproc kill all
cproc k all

# Show process status and resource usage
cproc status
cproc s

# Show working directory for process(es)
cproc cwd 12345
cproc pwd 12345 67890

# Show help
cproc help
cproc h

Examples

List all Claude processes:

$ cproc list
๐Ÿค– Claude-spawned processes:
================================

๐Ÿ“‹ Shell Process (PID: 58288):
   Command: /bin/zsh -c -l source ~/.claude/shell-snapshots/snapshot-zsh-...
   ๐Ÿ“ Working Directory: ~/Developer/2025/stable-diffusion-webui
   ๐Ÿ‘ถ Child processes:
      โ”œโ”€โ”€ PID: 58301 - python3 launch.py --api --listen --skip-torch-cuda-test --use-cpu all
      โ”‚   ๐Ÿ“ ~/Developer/2025/stable-diffusion-webui

๐Ÿ“Š Summary:
   Claude shells: 1

Kill a memory-hungry process:

$ cproc kill 58301
๐Ÿ›‘ Killing PID 58301...
โœ… PID 58301 killed.

Check process status:

$ cproc status
๐Ÿ“Š Process Status Summary:
==========================
๐Ÿค– Claude processes:
   None found

๐Ÿ” High-resource processes (>100MB RAM):
   1234 5.2% 512MB python3
   5678 3.1% 256MB node

๐ŸŒ Active network listeners:
   Port 3000: node 1234
   Port 8080: python3 5678

How It Works

The tool identifies Claude-spawned processes by looking for shell processes that:

  • Execute from .claude/shell-snapshots/ directories
  • Match the pattern snapshot-zsh-* in their command line
  • Are spawned by Claude's session management system

Common Use Cases

Memory Management

Large applications and development tools can consume significant RAM. Use cproc to:

  • Monitor which processes are using the most memory
  • Quickly terminate resource-heavy processes when done
  • Clean up orphaned processes that didn't shut down properly

Development Workflow

When working with multiple Claude sessions:

  • See what projects are currently running in the background
  • Identify which directory each process is running from
  • Clean up old development servers or background tasks

System Monitoring

  • Get a quick overview of all Claude-related system activity
  • Check which development servers and services are running
  • Monitor network port usage for web applications
  • Troubleshoot processes that might be stuck or unresponsive

Requirements

  • macOS (uses lsof and ps commands)
  • Bash 4.0+
  • Claude AI running in a terminal environment (like Warp)

File Structure

~/bin/claude-process-manager/  # or ~/bin/cproc/ for new installs
โ”œโ”€โ”€ cproc.sh       # Main script
โ”œโ”€โ”€ README.md      # This documentation  
โ”œโ”€โ”€ LICENSE        # MIT license
โ”œโ”€โ”€ .gitignore     # Git ignore file
โ””โ”€โ”€ .git/          # Git repository

Current symlink: ~/bin/cproc -> ~/bin/claude-process-manager/cproc.sh

Troubleshooting

"No Claude processes found"

This is normal if:

  • No Claude sessions are currently running background processes
  • All previous processes have completed and terminated
  • You're not running Claude in a terminal environment

Permission errors

Make sure the script is executable:

chmod +x ~/bin/claude-process-manager/cproc.sh  # or ~/bin/cproc/cproc.sh for new installs

Command not found

Ensure ~/bin is in your PATH:

echo $PATH | grep -o "$HOME/bin"

Contributing

Feel free to submit issues, feature requests, or pull requests. This tool is designed to be simple and focused on Claude process management.

License

MIT License - Feel free to use, modify, and distribute.

Author

Created to help manage resource-intensive AI processes spawned by Claude in terminal environments.

Contributors

yanicklandry

Issues