I Built a Free CLI That Tracks Your Coding Productivity (And It's Actually Useful)
After trying every productivity app on the market, I realized none of them actually told me how productive I really was. So I built my own.
The Problem
Every productivity tracker asks you to manually log what you did. That is stupid. Your git repo already knows everything.
Introducing DevMetrics
A simple Python CLI that reads your git history and tells you:
- How many commits you made this week
- Lines of code added/deleted
- Which files you changed most
- Your daily coding patterns
Install
pip install devmetrics-cli
Or just copy the script -- it is only 150 lines of Python.
Usage
Analyze any git repo
devmetrics analyze /path/to/your/project
Output:
{
"period_days": 7,
"total_commits": 23,
"lines_added": 1847,
"lines_deleted": 423,
"net_lines": 1424,
"avg_commits_per_day": 3.3,
"most_changed_files": [
["src/api.py", 8],
["tests/test_api.py", 5],
["README.md", 3]
]
}
Log non-coding sessions
devmetrics log 60 "code-review"
devmetrics log 30 "meeting"
devmetrics log 90 "deep-work"
Generate a full report
devmetrics report
This combines git stats with your logged sessions into a beautiful terminal report.
Why This Beats Other Tools
- WakaTime: Tracks editor time but costs $9/month for teams. DevMetrics is free.
- GitHub Insights: Shows PR stats but not your personal patterns. DevMetrics focuses on YOU.
- Manual logging: Nobody actually does this consistently. DevMetrics automates it.
The Code (Steal It)
Here is the core -- git log parsing in 20 lines:
import subprocess
from datetime import datetime, timedelta
from collections import Counter
def analyze_productivity(repo_path=".", days=7):
since = (datetime.now() - timedelta(days=days)).strftime("%Y-%m-%d")
result = subprocess.run(
["git", "log", f"--since={since}", "--format=%ad", "--date=short"],
capture_output=True, text=True, cwd=repo_path
)
commits_by_day = Counter(result.stdout.strip().split("\n"))
result2 = subprocess.run(
["git", "log", f"--since={since}", "--numstat", "--format="],
capture_output=True, text=True, cwd=repo_path
)
added, deleted = 0, 0
for line in result2.stdout.strip().split("\n"):
if "\t" in line:
parts = line.split("\t")
added += int(parts[0])
deleted += int(parts[1])
return {
"commits": sum(commits_by_day.values()),
"lines_added": added,
"lines_deleted": deleted,
"avg_per_day": round(sum(commits_by_day.values()) / days, 1)
}
That is it. No dependencies. No API keys. No cloud. Your data stays on your machine.
What I Learned Building This
The most productive week I ever had was 47 commits. The least productive was 3. The difference? I was working on a project I actually cared about during the 47-commit week.
Productivity is not about tools. It is about motivation. But tools help you see the patterns.
For better coding sessions, I recommend a good mechanical keyboard -- the tactile feedback genuinely makes you type more.
My Development Setup
Since we are talking about productivity, here is what I use daily:
- Editor: VS Code with Copilot
- Terminal: Alacritty (GPU-accelerated)
- Shell: Fish (better autocomplete)
- Monitor: LG 34WN80C Ultrawide -- split screen is productivity
- Chair: Hbada Ergonomic -- your back matters
- Lighting: BenQ ScreenBar -- no eye strain
Coming Soon
Features I am building:
- Weekly email reports
- Team dashboards
- Burnout detection (when your commit pattern suddenly drops)
- VS Code extension
Star the project to stay updated.
Try It
pip install devmetrics-cli
devmetrics report
Takes 10 seconds. Shows you exactly how your last week of coding went.
What is your productivity stack? Share below.
Disclosure: Amazon affiliate links. I earn a small commission at no extra cost to you.
Top comments (0)