Want a quick read on repository health? Pair GitHub’s code frequency stats with Datasette to explore additions and deletions over time—fast, visual, and repeatable.
Inspired by Simon Willison’s note on exploring activity with Datasette, here’s a minimal workflow you can reuse across repos.
What is “code frequency” and why it matters
Code frequency is GitHub’s weekly tally of additions and deletions per repo. It’s a simple, comparable signal for development velocity and maintenance cadence.
See GitHub’s docs for details on the endpoint and its caveats: Code frequency API.
A minimal Datasette workflow
- Fetch weekly code frequency for each repo via the GitHub API, store owner, repo, week_start (Unix week), additions, deletions.
- Normalize into SQLite (one row per repo-week). Keep numbers as integers; store week_start as ISO date for easier grouping.
- Open the database with Datasette to browse, filter, and share a URL to any query.
- Visualize trends by sorting weeks ascending, then plot additions and deletions as lines or bars in your UI of choice—or export CSV from Datasette.
- Automate a nightly refresh (cron/GitHub Actions), append new weeks, and republish.
Useful queries to try
- Recent activity by repo (last 12 weeks): group by repo, sum(additions) and sum(deletions), order by total edits desc.
- Momentum check: compute a 4-week rolling average of net_lines = additions – deletions to smooth noisy bursts.
- Release impact: filter weeks around a tag/release date to see whether edits spike or stabilize post-release.
Why this is useful
- Engineering managers: spot regressions or slowdowns before they hit delivery.
- OSS maintainers: demonstrate sustained project health to sponsors with a shareable URL.
- Developers: compare repos and identify where refactors or docs rewrites absorbed effort.
Tips for reliable results
- Respect API caching: the statistics endpoint is generated asynchronously—cache responses and retry later if empty.
- Handle rate limits: use tokens, backoff on 403s, and persist ETags to avoid re-fetching unchanged weeks.
- Watch sign conventions: deletions are counts; keep them positive in storage and compute net lines as additions – deletions.
- Monorepos: segment by path (if you have commit-level data) or track per service repo for cleaner signals.
Takeaway
With GitHub’s code frequency and Datasette, you can build a lightweight, explainable signal for repo health in under an hour—and keep it fresh with a nightly job.
Enjoyed this nugget? Subscribe for weekly, practical AI tactics: theainuggets.com/newsletter

