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 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-usage-cli

v1.1.2

Published

Monitor Claude API usage with zero dependencies

Readme

Claude Usage Monitor

A completely self-contained Node.js package for monitoring Claude API usage with zero external dependencies.

Credits & Attribution

This package is based on the original Claude-Code-Usage-Monitor by Maciej ([email protected]). This version transforms it into a zero-dependency npm package while maintaining all original functionality.

Features

  • 📊 Zero Dependencies: Pure Node.js implementation
  • 🚀 Direct File Access: Reads Claude JSONL files directly (no external tools)
  • 🌍 Timezone Support: Built-in Intl API for timezone handling
  • 🎨 Rich Terminal UI: ANSI colors, progress bars, and formatted tables
  • 📈 Comprehensive Analytics: Project-wise usage tracking and summaries
  • Fast & Lightweight: Native argument parsing and caching

Installation

Global Installation

npm install -g claude-usage-cli

Local Installation

npm install claude-usage-cli

Usage

Command Line Interface

# Show overall usage summary
claude-usage-cli

# Show today's usage
claude-usage-cli today

# Show this week's usage
claude-usage-cli week

# Show this month's usage
claude-usage-cli month

# List all projects
claude-usage-cli projects

# Show specific project details
claude-usage-cli project my-project-id

# Use different timezone
claude-usage-cli --timezone "America/New_York"

# Quiet mode (minimal output)
claude-usage-cli --quiet summary

# Show help
claude-usage-cli --help

Available Commands

  • summary - Show overall usage summary (default)
  • project <id> - Show detailed usage for a specific project
  • projects - List all projects with usage statistics
  • today - Show today's usage
  • week - Show this week's usage
  • month - Show this month's usage
  • cache [clear|stats] - Manage internal cache

Options

  • -t, --timezone <tz> - Timezone for date formatting (default: system)
  • -c, --config-dir <dir> - Claude configuration directory
  • -p, --project-id <id> - Specific project ID to analyze
  • -v, --verbose - Verbose output
  • -q, --quiet - Quiet mode - minimal output
  • --no-color - Disable colored output
  • --include-empty - Include projects with no usage
  • -h, --help - Show help message
  • --version - Show version information

Architecture

Zero Dependencies Implementation

This package is completely self-contained and implements all functionality using only Node.js built-in modules:

Core Modules

  • lib/cli.js - Main CLI interface
  • lib/monitor.js - Core monitoring logic

Utilities (Zero Dependencies)

  • utils/args.js - Native argument parsing
  • utils/terminal.js - ANSI colors, progress bars, tables
  • utils/timezone.js - Intl API timezone handling
  • utils/claude-data.js - Direct JSONL file parsing

Data Sources

The monitor reads directly from Claude's local configuration:

  • Default Location: ~/.config/claude/projects/
  • File Format: JSONL (JSON Lines) conversation files
  • Cache: Built-in memory cache with configurable timeout

Supported Data

  • Total tokens (input + output)
  • Input tokens
  • Output tokens
  • Cache creation tokens
  • Cache read tokens
  • Request counts
  • Model information
  • Time ranges
  • Project statistics

API Usage

const { ClaudeUsageMonitor } = require('claude-usage-cli');

const monitor = new ClaudeUsageMonitor({
    timezone: 'UTC',
    verbose: false
});

// Get usage summary
const summary = await monitor.getSummary();
console.log(summary.formatted);

// Get project details
const project = await monitor.getProjectDetails('my-project');
console.log(project.formatted);

// List all projects
const projects = await monitor.listProjects();
console.log(projects.formatted);

Testing

# Run built-in tests
npm test

# Test CLI directly
node lib/cli.js --help
node lib/cli.js summary
./bin/claude-usage-cli --version

Configuration

Environment Variables

  • NODE_ENV=development - Enable debug output and stack traces

Custom Configuration Directory

claude-usage-cli --config-dir /custom/path/to/claude/config

Requirements

  • Node.js: >= 16.0.0
  • OS: Linux, macOS, Windows
  • Claude CLI: Local conversation files in JSONL format

License

MIT License

Contributing

This is a zero-dependency package. Please ensure any contributions maintain this requirement and use only Node.js built-in modules.