Skip to content

Usage

Basic Commands

Count Lines of Code

trueloc count USERNAME --since DATE

This counts all lines from merged PRs and direct commits since the specified date.

Clear Cache

trueloc clear-cache

Removes all cached data from ~/.cache/trueloc/.

Date Formats

trueloc supports multiple date formats:

Relative Dates

trueloc count USERNAME --since 5d      # 5 days ago
trueloc count USERNAME --since 2w      # 2 weeks ago
trueloc count USERNAME --since 3m      # 3 months ago
trueloc count USERNAME --since 1y      # 1 year ago

Natural Language

trueloc count USERNAME --since "last month"
trueloc count USERNAME --since "last week"
trueloc count USERNAME --since "yesterday"

ISO Dates

trueloc count USERNAME --since 2024-01-01
trueloc count USERNAME --since 2024-06-15

Date Ranges

trueloc count USERNAME --since 2024-01-01 --until 2024-06-30

Counting Modes

Per-Commit Mode (Default)

Counts every line touched in every commit across all PRs (merge commits, e.g. merging main into a PR branch, are excluded):

trueloc count USERNAME --since 2024-01-01

This gives you the "true" count of all lines you wrote, even if some were later deleted or modified.

Net Diff Mode

Only counts the final diff of each PR:

trueloc count USERNAME --since 2024-01-01 --net

This matches what GitHub shows in the PR diff view.

Filtering Options

Exclude Direct Commits

Only count lines from PRs, ignoring commits pushed directly to branches:

trueloc count USERNAME --since 2024-01-01 --no-direct-commits

Hide File Extensions

Skip the file extension breakdown in output:

trueloc count USERNAME --since 2024-01-01 --no-extensions

Single Repository

Count lines from a specific repository only:

trueloc count USERNAME --since 2024-01-01 --repo owner/repo-name

Output Options

JSON Output

Get machine-readable JSON output for scripting:

trueloc count USERNAME --since 2024-01-01 --json

Disable Caching

Force fresh API calls without using cached data:

trueloc count USERNAME --since 2024-01-01 --no-cache

Caching

trueloc caches API responses to avoid rate limiting and speed up repeated queries.

Cache Location

Cache is stored in ~/.cache/trueloc/. Repos with many commits are cloned into ~/.cache/trueloc/repos/ (bare clones, reused and updated on later runs); trueloc clear-cache removes them too. Use --no-local-git to only use the API.

Cache Strategy

Data Type TTL Reason
Commit stats Forever Immutable once created
PR commits Forever Immutable once merged
PR files Forever Immutable once merged
User repos 7 days Can change over time
Merged PR lists Incremental Re-checked for newly merged PRs after 1 hour

Cache Management

# Clear all cached data
trueloc clear-cache

Rate Limiting

When GitHub rate limits are hit, trueloc automatically:

  1. Detects the rate limit response
  2. Shows a progress bar with wait time
  3. Resumes automatically when the limit resets

Example Output

Running trueloc count basnijholt -s 1y produces:

                             Lines of Code by Month
┏━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Month   ┃ Additions ┃ Deletions ┃   Total ┃      Net ┃                       ┃
┡━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2025-01 │    +9,886 │      -933 │  10,819 │   +8,953 │                       │
│ 2025-02 │   +16,893 │    -5,776 │  22,669 │  +11,117 │                       │
│ 2025-03 │   +74,655 │   -30,098 │ 104,753 │  +44,557 │ ███                   │
│ 2025-04 │   +27,380 │    -7,696 │  35,076 │  +19,684 │ █                     │
│ 2025-05 │   +14,356 │    -3,983 │  18,339 │  +10,373 │                       │
│ 2025-06 │   +42,728 │   -17,681 │  60,409 │  +25,047 │ █                     │
│ 2025-07 │  +163,684 │   -93,242 │ 256,926 │  +70,442 │ ████████              │
│ 2025-08 │   +49,019 │   -15,727 │  64,746 │  +33,292 │ ██                    │
│ 2025-09 │   +13,597 │      -834 │  14,431 │  +12,763 │                       │
│ 2025-10 │  +180,196 │   -74,821 │ 255,017 │ +105,375 │ ████████              │
│ 2025-11 │  +711,228 │  -216,940 │ 928,168 │ +494,288 │ ████████████████████… │
│ 2025-12 │  +253,971 │   -72,893 │ 326,864 │ +181,078 │ ██████████            │
│ 2026-01 │  +211,498 │  -102,750 │ 314,248 │ +108,748 │ ██████████            │
└─────────┴───────────┴───────────┴─────────┴──────────┴───────────────────────┘
        Lines by Month - Top 3 Languages
┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┓
┃ Month   ┃     .py ┃    .js ┃ .ipynb ┃   Total ┃
┡━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━┩
│ 2025-01 │     286 │  8,407 │      - │   8,693 │
│ 2025-02 │   9,560 │  8,194 │      - │  17,754 │
│ 2025-03 │  69,628 │ 18,925 │      - │  88,553 │
│ 2025-04 │   6,840 │  6,520 │      - │  13,360 │
│ 2025-05 │   3,889 │  8,874 │      - │  12,763 │
│ 2025-06 │  30,345 │  9,076 │    142 │  39,563 │
│ 2025-07 │ 102,308 │ 59,393 │  2,039 │ 163,740 │
│ 2025-08 │  47,366 │  2,140 │      - │  49,506 │
│ 2025-09 │   2,581 │  4,569 │      - │   7,150 │
│ 2025-10 │ 148,358 │  6,873 │      - │ 155,231 │
│ 2025-11 │ 212,580 │  7,348 │ 54,103 │ 274,031 │
│ 2025-12 │ 150,940 │ 18,657 │ 11,973 │ 181,570 │
│ 2026-01 │  87,307 │    162 │  6,724 │  94,193 │
└─────────┴─────────┴────────┴────────┴─────────┘
                               Commits per Month
┏━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Month   ┃ PR Commits ┃ Direct ┃ Total ┃ PRs ┃ Avg/PR ┃                      ┃
┡━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ 2025-01 │         28 │     80 │   108 │  10 │    2.8 │ █                    │
│ 2025-02 │         57 │    132 │   189 │  12 │    4.8 │ █                    │
│ 2025-03 │        446 │    529 │   975 │  77 │    5.8 │ █████████            │
│ 2025-04 │        127 │    332 │   459 │  26 │    4.9 │ ████                 │
│ 2025-05 │         14 │     96 │   110 │   6 │    2.3 │ █                    │
│ 2025-06 │         93 │    372 │   465 │  29 │    3.2 │ ████                 │
│ 2025-07 │        483 │    366 │   849 │  34 │   14.2 │ ████████             │
│ 2025-08 │        111 │    153 │   264 │  13 │    8.5 │ ██                   │
│ 2025-09 │         19 │     44 │    63 │   6 │    3.2 │                      │
│ 2025-10 │        271 │    374 │   645 │  10 │   27.1 │ ██████               │
│ 2025-11 │        871 │    638 │ 1,509 │  91 │    9.6 │ ██████████████       │
│ 2025-12 │      1,261 │    842 │ 2,103 │ 255 │    4.9 │ ████████████████████ │
│ 2026-01 │        778 │    279 │ 1,057 │ 174 │    4.5 │ ██████████           │
└─────────┴────────────┴────────┴───────┴─────┴────────┴──────────────────────┘
                      Lines of Code by Repository (Top 15)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┓
┃ Repository                 ┃ PRs ┃ Commits ┃ Additions ┃ Deletions ┃   Total ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━┩
│ agent-cli                  │ 187 │     447 │  +456,555 │  -176,185 │ 632,740 │
│ glove80                    │   3 │     171 │  +399,278 │  -101,727 │ 501,005 │
│ aijournal                  │  23 │     413 │  +226,087 │   -96,154 │ 322,241 │
│ compose-farm               │ 148 │     354 │  +104,679 │   -40,606 │ 145,285 │
│ assistant-ui-anywidget     │   3 │      68 │   +88,792 │   -45,449 │ 134,241 │
│ glove80-tailorkey-hrm-tra… │   - │      15 │   +67,317 │   -36,474 │ 103,791 │
│ home-assistant-config      │   7 │     196 │   +96,970 │    -4,133 │ 101,103 │
│ dotbins                    │  87 │     382 │   +56,921 │   -28,684 │  85,605 │
│ basnijholt                 │   1 │     182 │   +42,461 │   -39,521 │  81,982 │
│ dotfiles                   │  24 │     878 │   +35,555 │   -16,168 │  51,723 │
│ adaptive-lighting          │  22 │      30 │   +29,316 │    -4,990 │  34,306 │
│ lesdeuxchevaux             │  86 │      90 │   +20,971 │    -6,913 │  27,884 │
│ .dotbins                   │   - │     102 │   +13,378 │   -12,303 │  25,681 │
│ matty                      │   4 │      57 │   +16,119 │    -7,407 │  23,526 │
│ nijho.lt                   │  20 │     126 │   +20,356 │    -1,812 │  22,168 │
└────────────────────────────┴─────┴─────────┴───────────┴───────────┴─────────┘
                          Top 10 Contributions by Size
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Ref     ┃ Description                   ┃ Additions ┃ Deletions ┃ Date       ┃
┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ 339c987 │ glove80: Expand TailorKey     │  +164,547 │      -113 │ 2025-11-09 │
│         │ variants for all alpha ...    │           │           │            │
│ PR #224 │ agent-cli: feat(server): add  │   +47,187 │   -21,668 │ 2026-01-15 │
│         │ Whisper ASR server wit...     │           │           │            │
│ PR #88  │ agent-cli: Add memory-proxy   │   +48,172 │    -7,943 │ 2025-11-23 │
│         │ based on SOTA systems b...    │           │           │            │
│ becf3a3 │ glove80: Retire redundant     │       +77 │   -54,763 │ 2025-11-08 │
│         │ sources/variants inputs       │           │           │            │
│ 1db6c4c │ glove80: Add canonical layout │   +54,811 │        -0 │ 2025-11-08 │
│         │ sources and generat...        │           │           │            │
│ 6568292 │ glove80: Add original files   │   +54,684 │        -0 │ 2025-11-08 │
│ PR #5   │ aijournal: Data models        │   +33,791 │   -16,493 │ 2025-10-31 │
│ 47d10c6 │ glove80-tailorkey-hrm-transf… │   +34,409 │        -0 │ 2025-11-07 │
│         │ Add base/HRM layer utilities  │           │           │            │
│ 1294c50 │ glove80-tailorkey-hrm-transf… │        +0 │   -34,195 │ 2025-11-07 │
│         │ Prune intermediate layout     │           │           │            │
│         │ snapshots                     │           │           │            │
│ PR #84  │ agent-cli: feat: add proxy    │   +24,787 │    -2,305 │ 2025-11-20 │
│         │ RAG server                    │           │           │            │
└─────────┴───────────────────────────────┴───────────┴───────────┴────────────┘
           Lines by File Extension (Top 15)
┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━┓
┃ Extension ┃ Additions ┃ Deletions ┃   Total ┃     % ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━┩
│ .py       │  +639,983 │  -232,005 │ 871,988 │ 36.1% │
│ .json     │  +499,306 │  -141,866 │ 641,172 │ 26.6% │
│ .md       │  +220,367 │  -121,747 │ 342,114 │ 14.2% │
│ .js       │  +127,403 │   -31,735 │ 159,138 │  6.6% │
│ .lock     │  +115,148 │   -24,765 │ 139,913 │  5.8% │
│ .ipynb    │   +38,825 │   -36,156 │  74,981 │  3.1% │
│ .nix      │   +15,467 │    -8,490 │  23,957 │  1.0% │
│ .txt      │   +15,816 │    -2,467 │  18,283 │  0.8% │
│ .sh       │   +10,565 │    -5,801 │  16,366 │  0.7% │
│ .yaml     │   +10,415 │    -5,831 │  16,246 │  0.7% │
│ keychain  │    +7,931 │    -7,922 │  15,853 │  0.7% │
│ .html     │   +11,329 │    -3,309 │  14,638 │  0.6% │
│ .tsx      │    +7,648 │    -4,941 │  12,589 │  0.5% │
│ .yml      │   +10,001 │    -1,596 │  11,597 │  0.5% │
│ .toml     │    +7,530 │    -2,310 │   9,840 │  0.4% │
└───────────┴───────────┴───────────┴─────────┴───────┘
Activity Stats
  Average lines per contribution: 484
  Average PR size: 1,236 lines
  Most productive day: Sun
  Lines by day of week:
    Mon: ▓▓▓▓▓▓▓▓▓ 213,687
    Tue: ▓▓▓▓▓▓▓▓▓▓▓▓ 294,270
    Wed: ▓▓▓▓▓▓▓▓▓▓ 250,674
    Thu: ▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 324,756
    Fri: ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 425,349
    Sat: ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 441,004
    Sun: ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 462,725
PR Size Distribution
      <100: ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  378 ( 50.9%)
   100-500: ▓▓▓▓▓▓▓▓▓▓            194 ( 26.1%)
    500-1K: ▓▓                     52 (  7.0%)
     1K-5K: ▓▓▓                    73 (  9.8%)
       >5K: ▓▓                     46 (  6.2%)
Quality Indicators
  Documentation: 14.9% of total lines
  Test-related: ~6.9% of code lines (estimated)
  Code churn: 36.4% (643,374 deleted per 1,769,091 added)
Total PRs: 743 (per-commit totals)
Direct commits: 4237
Total additions: +1,769,091
Total deletions: -643,374
Total lines changed: 2,412,465
Cache hits: 4980
Congratulations! You've written over a million lines of code since 1y!

Examples

Count last year's contributions

trueloc count myusername --since 1y

Get JSON for a specific quarter

trueloc count myusername --since 2024-01-01 --until 2024-03-31 --json

Quick check of recent activity

trueloc count myusername --since 1w --no-extensions

Fresh count without cache

trueloc count myusername --since 1m --no-cache