Skip to main content

Track your daily lines of code across all GitHub repositories.

Project description

CLC - Commit Line Counter

Track lines of code across all your GitHub repositories.

Get terminal stats, SVG cards for your profile, or a full HTML dashboard. Runs locally or on a cron via GitHub Actions.

License: MIT Python 3.10+ GitHub stars


Quick start

git clone https://github.com/Rudra-Tiwari-codes/CLC.git
cd CLC
pip install -r requirements.txt

Create a GitHub Personal Access Token (classic) with repo + read:user scopes at github.com/settings/tokens.

export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
# or create a .env file with GITHUB_TOKEN=ghp_xxxxxxxxxxxx

Usage

python daily_loc.py              # Last 30 days, terminal output
python daily_loc.py -d 7         # Last week
python daily_loc.py -d 90        # Last quarter
python daily_loc.py -u octocat   # Specific user
python daily_loc.py --max-repos 50         # Limit to 50 most recently pushed repos
python daily_loc.py -o stats.json          # Export to JSON
python daily_loc.py --clear-cache          # Wipe cached data
python daily_loc.py --exclude "fork|test"  # Skip repos matching regex

SVG card generation

python daily_loc.py --svg card.svg                     # Dark theme (default)
python daily_loc.py --svg card.svg --theme radical      # Radical theme
python daily_loc.py --svg card.svg --theme tokyonight   # Tokyo Night theme
python daily_loc.py --svg card.svg --no-animate         # Disable CSS animations

Custom themes

Use any 3 hex colors (background, text, accent):

python daily_loc.py --svg card.svg --theme "#1a1a2e,#eaeaea,#e94560"

Weekly / monthly rollups

python daily_loc.py --svg card.svg --group weekly    # Group by week
python daily_loc.py --svg card.svg --group monthly   # Group by month

Comparison mode

Compare your stats against any public GitHub user:

python daily_loc.py -d 30 --svg card.svg --vs torvalds

Multi-user leaderboard

Compare 3+ users side by side with a ranked leaderboard card:

python daily_loc.py --svg card.svg --leaderboard "antfu,craftzdog,sindresorhus"

Generates a separate *-leaderboard.svg with gold/silver/bronze rankings.

Interactive HTML dashboard

Generate a self-contained HTML report with interactive Chart.js charts:

python daily_loc.py --html report.html

Includes daily activity charts, language doughnut, coding hours distribution, top files, code churn, commit message patterns, achievements, and stat cards.

Historical trends

Track your stats over time in a local JSON history file:

python daily_loc.py --history              # Append today's stats to .clc-history.json
python daily_loc.py --history -d 7         # Track weekly snapshots

Contributor rank

See your rank among contributors in repos you contribute to:

python daily_loc.py --contributor-rank

Dark hours & work schedule

Configure what counts as "work hours" for the dark hours tracker:

python daily_loc.py --work-hours "8-18"    # 8 AM to 6 PM

Exclude patterns

Skip repos matching a regex pattern:

python daily_loc.py --exclude "fork|archived|test"

Shields.io badge JSON

Generate endpoint JSON files for dynamic shields.io badges:

python daily_loc.py --badge-json badges/

This creates badges/loc.json, badges/commits.json, badges/streak.json, and badges/net.json. Use them with shields.io endpoint badges:

![LOC](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/YOUR_USER/YOUR_USER/main/badges/loc.json)

Features

Feature Description
Language Breakdown Detects 50+ languages from file extensions, shows donut chart on SVG card
File Type Treemap Visual proportional treemap of languages in the SVG card
Repository Leaderboard Top repos ranked by total lines changed
Productivity Scoring Each day rated: Low / Medium / High / Beast Mode (based on percentiles)
Streak Tracking Current and longest consecutive coding streaks
Achievements Unlockable milestones: 1K Club, Week Warrior, Polyglot, Power Day, etc.
Net LOC Trend Sparkline graph showing your net output trend over time
Code Velocity Lines per day average with trend direction (up/down/stable) and peak day
Code Churn Tracks files changed repeatedly -- high churn flags unstable code
Top Files Changed Lists files with the most lines added/deleted
Commit Message Analysis Most common words in your commit messages (stop-word filtered)
Repo Health Score 0-100 composite from commit frequency, streak, diversity, breadth, volume
Dark Hours Tracker Coding done outside configurable work hours, night owl score, peak hour
Git Blame Depth Code survival rate -- how much of your code persists vs gets deleted
Contributor Rank Your rank among all contributors in repos you contribute to
Multi-User Leaderboard Compare 3+ users side by side with gold/silver/bronze rankings
Historical Trends Append stats to a JSON history file, track week-over-week progress
Interactive HTML Report Full dashboard with Chart.js charts: activity, languages, hours, files, churn
Exclude Patterns --exclude regex to skip repos by name
Animated SVG CSS animations for bars, donut chart, treemap, and achievement badges
10 Built-in Themes dark, light, radical, tokyonight, dracula, nord, catppuccin, ocean, sunset, cyberpunk
Custom Themes Define your own with 3 hex colors
Weekly/Monthly Rollups Aggregate daily stats into weekly or monthly buckets
Comparison Mode Head-to-head stats vs any public GitHub user
Shields.io Badges Generate endpoint JSON for dynamic README badges

SVG card themes

Theme Look
dark Blue on dark gray (default)
light Blue on white
radical Hot pink + cyan on deep purple
tokyonight Soft blue + teal on navy
dracula Purple + pink on charcoal
nord Ice blue on arctic
catppuccin Lavender on mocha
ocean Teal + mint on deep navy
sunset Orange + gold on violet
cyberpunk Neon red + cyan on black

Add to your GitHub profile (no API, no deployment)

Runs via GitHub Actions. No Vercel, no server. The action generates an SVG every 2 hours and commits it to your profile repo.

1. Create a token

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

2. Add the token to your profile repo

Your profile repo is github.com/<your-username>/<your-username>.

  1. Go to your profile repo -> Settings -> Secrets and variables -> Actions
  2. Click New repository secret
  3. Name: GH_PAT
  4. Value: paste your token

3. Add the workflow

Create .github/workflows/update-clc.yml in your profile repo:

name: Update LOC Stats Card

on:
  schedule:
    - cron: "0 */2 * * *"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  update-card:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install requests python-dotenv
      - run: curl -sL https://raw.githubusercontent.com/Rudra-Tiwari-codes/CLC/main/daily_loc.py -o daily_loc.py
      - name: Generate SVG card
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
        run: python daily_loc.py -d 30 --svg clc-card.svg --theme dark
      - name: Commit and push
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git diff --quiet clc-card.svg 2>/dev/null && echo "No changes" && exit 0
          git add clc-card.svg
          git commit -m "chore: update LOC stats card [skip ci]"
          git push

4. Add to your README

![My Coding Stats](./clc-card.svg)

5. Push and done

Card auto-updates every 2 hours.


How it works

Uses your GitHub token to pull repos and commits via the REST API. Commit details are cached locally so repeat runs are fast. Stats get broken down by day, language, repo, and file, then rendered however you want (terminal, SVG, HTML, JSON).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github_clc-3.0.0.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_clc-3.0.0-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file github_clc-3.0.0.tar.gz.

File metadata

  • Download URL: github_clc-3.0.0.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for github_clc-3.0.0.tar.gz
Algorithm Hash digest
SHA256 112454290847c5892a10c5a4bba1f74934e5de89a01948d016fd8b7347ff32ba
MD5 f505710b1812afa4e25f782e120d38ec
BLAKE2b-256 8c044d4b508d9d6f937bd81786bd3b9201e5bf0e7865d756914b1cb26390a23e

See more details on using hashes here.

File details

Details for the file github_clc-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: github_clc-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for github_clc-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e360c83a0c7487f19e0f15c38a9365b80bb26b5375048805c8d54a5d8114d098
MD5 a6bdb7ecb5a5187d5189f15a987ac8c7
BLAKE2b-256 805bcd4aabdb40cf1a893e354c70721c5f2e9dc7f07dbbc1555bdd0c82721e4f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page