Dev Environment Badge
Generate a snapshot badge of your project for your README — file stats, git info, and dev setup. The script runs locally; your data only leaves when you submit the token.
1
Review the script, then download and run it
The script scans your project files, reads git metadata, and captures basic system info for the badge.
#!/usr/bin/env python3
"""projstats - Generate a dev environment badge token."""
import os, json, base64, subprocess, platform, socket
from pathlib import Path
from datetime import datetime
def run(cmd):
try:
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
return r.stdout.strip()
except Exception:
return ""
root = Path(".").resolve()
exts = {}
total_files = 0
total_lines = 0
for f in root.rglob("*"):
if f.is_file() and ".git" not in f.parts:
ext = f.suffix or "(none)"
exts[ext] = exts.get(ext, 0) + 1
total_files += 1
try:
total_lines += sum(1 for _ in f.open(errors="ignore"))
except (OSError, PermissionError):
pass
stats = {
"generated": datetime.utcnow().strftime("%Y-%m-%d %H:%M UTC"),
"project": root.name,
"total_files": total_files,
"total_lines": total_lines,
"extensions": dict(sorted(exts.items(), key=lambda x: -x[1])[:8]),
"git": {
"branch": run("git rev-parse --abbrev-ref HEAD 2>/dev/null") or "n/a",
"commit": run("git log -1 --format='%h %s' 2>/dev/null") or "n/a",
"author": run("git config user.name 2>/dev/null") or "n/a",
},
"system": {
"hostname": socket.gethostname(),
"os": f"{platform.system()} {platform.release()}",
"arch": platform.machine(),
"python": platform.python_version(),
},
}
token = base64.urlsafe_b64encode(
json.dumps(stats, separators=(",", ":")).encode()
).decode()
print()
print("=" * 50)
print(" projstats - Badge Token")
print("=" * 50)
print(f" Project : {stats['project']}")
print(f" Files : {stats['total_files']}")
print(f" Lines : {stats['total_lines']:,}")
print(f" Branch : {stats['git']['branch']}")
print(f" Host : {stats['system']['hostname']}")
print(f" Python : {stats['system']['python']}")
print("=" * 50)
print()
print(f"Token: {token}")
print()
print("Paste this token at snipboard-app.pages.dev to generate your badge.")
Download projstats.py
Run with
python3 projstats.py in your project directory.
2
Paste your token
Copy the token from the terminal output and paste it here.
project
0
Files
0
Lines
0
Languages
Branch—
Commit—
Author—
Hostname—
OS—
Architecture—
Python—
Generated—