New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

monthly-loc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monthly-loc

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

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
4
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

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:

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

OptionDescriptionDefault
-u, --userGitHub username to fetch contributions forToken owner
-e, --excludeComma-separated list of repository names to skipNone
-f, --exclude-filePath to file with repos to exclude (one per line)None
-m, --monthTarget month in YYYY-MM formatCurrent month
-n, --monthsFetch last N months (e.g., 12 for full year)1
-o, --outputOutput format: json, csv, tabletable
--include-filesOnly count files matching these patternsAll files
--exclude-filesExclude files matching these patternsNone
--show-filesShow individual file stats for each repofalse
--include-forksInclude forked repositoriesfalse

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

Keywords

github

FAQs

Package last updated on 19 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts