npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

claude-code-router-enhanced

v2.0.1

Published

Enhanced Claude Code router with robust process management, graceful shutdown, and health monitoring

Readme

Claude Code Router

Enhanced Claude Code router with robust process management, graceful shutdown, and health monitoring capabilities.

npm version License: MIT

Features

🚀 Enhanced Process Management

  • Robust PID file handling with file locking
  • Graceful shutdown with connection draining
  • Automatic cleanup and recovery

📊 Health Monitoring

  • Built-in health check endpoints (/health, /ready, /alive)
  • Production-ready monitoring integration
  • Process metrics and status reporting

🔧 Production Deployment

  • PM2 ecosystem configuration included
  • Systemd service file for Linux servers
  • Docker-ready setup

🛡️ Reliability

  • Zero data loss during restarts
  • Configurable shutdown timeouts
  • Automatic resource cleanup

Installation

# Install globally
npm install -g @tehreet/claude-code-router

# Or install locally
npm install @tehreet/claude-code-router

Quick Start

  1. Create configuration file at ~/.claude-code-router/config.json:
{
  "Providers": [
    {
      "name": "gemini",
      "api_base_url": "https://generativelanguage.googleapis.com/v1beta/models/",
      "api_key": "YOUR_API_KEY",
      "models": ["gemini-2.5-flash", "gemini-2.5-pro"],
      "transformer": {
        "use": ["gemini"]
      }
    }
  ],
  "Router": {
    "default": "gemini,gemini-2.5-flash"
  }
}
  1. Start the service:
ccr start
  1. Check status:
ccr status
  1. Test health endpoint:
curl http://localhost:3456/health

Commands

ccr start          # Start the service
ccr stop           # Stop the service gracefully  
ccr status         # Show service status
ccr code "prompt"  # Execute code command
ccr --help         # Show help information

Health Endpoints

  • GET /health - Basic health status
  • GET /ready - Readiness probe (K8s compatible)
  • GET /alive - Liveness probe with metrics

Example response:

{
  "status": "ok",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "uptime": 3600,
  "pid": 12345
}

Production Deployment

PM2 (Recommended)

# Install PM2
npm install -g pm2

# Start with PM2 using included config
pm2 start ecosystem.config.js

# Save PM2 state
pm2 save && pm2 startup

Systemd (Linux)

# Install as system service
sudo ./scripts/install-systemd.sh

# Manage with systemctl
sudo systemctl start claude-code-router
sudo systemctl status claude-code-router

Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
EXPOSE 3456
CMD ["npm", "start"]

Configuration

Supported Providers

  • OpenRouter - Multiple model access
  • Gemini - Google's Gemini models
  • DeepSeek - DeepSeek models with tool use
  • Ollama - Local model serving
  • VolcEngine - Enterprise AI platform

Environment Variables

  • SERVICE_PORT - Port to run on (default: 3456)
  • NODE_ENV - Environment (development/production)
  • CONFIG_PATH - Custom config file path

Monitoring Integration

Prometheus

scrape_configs:
  - job_name: 'claude-code-router'
    static_configs:
      - targets: ['localhost:3456']
    metrics_path: '/health'

Kubernetes

livenessProbe:
  httpGet:
    path: /alive
    port: 3456
  initialDelaySeconds: 10

readinessProbe:
  httpGet:
    path: /ready
    port: 3456
  initialDelaySeconds: 5

API Usage

Send requests to the router exactly like the Claude API:

curl -X POST http://localhost:3456/v1/messages \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-flash",
    "messages": [
      {"role": "user", "content": "Hello, world!"}
    ]
  }'

Troubleshooting

Service Won't Start

# Check if port is in use
lsof -i :3456

# Check PID file
cat ~/.claude-code-router/.claude-code-router.pid

# View logs (PM2)
pm2 logs claude-code-router

Health Check Fails

# Test endpoints
curl http://localhost:3456/health
curl http://localhost:3456/ready
curl http://localhost:3456/alive

# Check service status
ccr status

Development

# Clone repository
git clone https://github.com/vibe-coders-only/claude-code-router.git
cd claude-code-router

# Install dependencies
npm install

# Build project
npm run build

# Start development server
npm start

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

Changelog

v2.0.0

  • ✅ Enhanced process management with file locking
  • ✅ Graceful shutdown with connection draining
  • ✅ Health monitoring endpoints
  • ✅ PM2 and systemd integration
  • ✅ Production deployment configurations