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

monthly-loc

v1.1.0

Published

CLI tool to fetch and aggregate monthly lines of code contributions from GitHub

Readme

monthly-loc

npm version License: MIT

A CLI tool to fetch and aggregate monthly lines of code (additions/deletions) contributed by a user across all their GitHub repositories.

Features

  • 📊 Track additions, deletions, and net lines of code
  • 📅 Support for single month or multi-month ranges (last 12 months, etc.)
  • 🏢 Works across personal repos AND organization repos
  • 🚫 Exclude specific repositories
  • 📁 Multiple output formats: table, JSON, CSV
  • ⚡ Optimized API usage with GitHub's commit search

Installation

npm install -g monthly-loc

Or run directly with npx:

npx monthly-loc --months 3

Setup

Create a GitHub Personal Access Token with repo and read:user scopes:

  1. Go to https://github.com/settings/tokens
  2. Click "Generate new token (classic)"
  3. Select scopes: repo and read:user
  4. Copy the token

Set it as an environment variable:

export GITHUB_TOKEN="ghp_your_token_here"

Usage

# Current month stats
monthly-loc

# Last 3 months
monthly-loc --months 3

# Last 12 months (full year)
monthly-loc --months 12

# Specific month
monthly-loc --month 2025-06

# Exclude specific repos
monthly-loc --exclude "test-repo,sandbox"

# Output as JSON
monthly-loc --months 6 --output json

# Output as CSV
monthly-loc --output csv > contributions.csv

# Check another user's public contributions
monthly-loc --user octocat --months 3

# Include forked repositories
monthly-loc --include-forks

# Only count specific file types (e.g., only code files)
monthly-loc --include-files "*.ts,*.js,*.tsx,*.jsx"

# Only count Python files
monthly-loc --include-files "*.py"

# Exclude specific file types from line count
monthly-loc --exclude-files "*.md,package-lock.json"

# Combine both: only JS/TS but exclude tests
monthly-loc --include-files "*.ts,*.js" --exclude-files "*.test.ts,*.spec.js"

# Show individual file stats for each repo
monthly-loc --show-files

# Combine with other flags
monthly-loc --months 3 --show-files --include-files "*.ts,*.js"

Options

| Option | Description | Default | | -------------------- | ---------------------------------------------------- | ------------- | | -u, --user | GitHub username to fetch contributions for | Token owner | | -e, --exclude | Comma-separated list of repository names to skip | None | | -f, --exclude-file | Path to file with repos to exclude (one per line) | None | | -m, --month | Target month in YYYY-MM format | Current month | | -n, --months | Fetch last N months (e.g., 12 for full year) | 1 | | -o, --output | Output format: json, csv, table | table | | --include-files | Only count files matching these patterns | All files | | --exclude-files | Exclude files matching these patterns | None | | --show-files | Show individual file stats for each repo | false | | --include-forks | Include forked repositories | false |

Sample Output

Table Format (Multi-Month)

GitHub Contributions - 2025-10 to 2025-12
User: akulsr0
================================================================================

📅 MONTHLY BREAKDOWN
--------------------------------------------------------------------------------
Month                  Commits     Additions      Deletions      Net Lines
--------------------------------------------------------------------------------
Oct 2025                     6        +2,085            -53        +2,032
Nov 2025                    33       +63,297         -3,337       +59,960
Dec 2025                     5          +621           -201          +420
--------------------------------------------------------------------------------
TOTAL                       44       +66,003         -3,591       +62,412

📦 BY REPOSITORY
--------------------------------------------------------------------------------
Repository                    Commits    Additions    Deletions    Net Lines
--------------------------------------------------------------------------------
repo-1                             24       +58,241        -3,464       +54,777
bazaar                             17        +7,745          -123        +7,622
repo-2                             2            +8            -1            +7
--------------------------------------------------------------------------------
TOTAL                              44       +66,003        -3,591       +62,412

📊 3 months | 4 repos with activity | 44 commits

JSON Format

monthly-loc --months 3 --output json
{
  "period": "2025-10 to 2025-12",
  "user": "akulsr0",
  "summary": {
    "total_additions": 66003,
    "total_deletions": 3591,
    "net_lines": 62412,
    "repos_with_activity": 4,
    "commits": 44,
    "months_analyzed": 3
  },
  "monthly_breakdown": [...],
  "repositories": [...]
}

Exclude File Format

Create a text file with one repository name per line:

# repos-to-exclude.txt
old-archive
test-sandbox
experimental-stuff

Then use it:

monthly-loc --exclude-file repos-to-exclude.txt

Requirements

  • Node.js 18.0.0 or higher
  • GitHub Personal Access Token

License

MIT © Akul Srivastava