DEV Community

Gracebuilder
Gracebuilder

Posted on

I built a static code scanner that scores your repo's carbon footprint

Most code quality tools tell you if your code is correct.
None of them tell you if it's efficient in the energy sense.

I wanted to change that. So I built sustainability-score —
a static-analysis tool that reads your repository and tells
you how its engineering choices affect carbon and cost
efficiency, grounded in the Green Software Foundation's
SCI specification.

The problem I was solving

The Green Software Foundation's Software Carbon Intensity
(SCI) specification gives us a framework for thinking about
software carbon. But measuring energy for a running system
is hard.

What isn't hard is reading a repo and asking: are the
engineering choices here pushing carbon up or down? That
is a static analysis problem. That is what this tool does.

How it works

The tool scores across five weighted pillars:

  • Code / Algorithm Efficiency — 30%
  • Cloud Infrastructure Choices — 25%
  • Containerization — 15%
  • CI/CD Practices — 15%
  • SRE / Operations — 15%

Each pillar starts at 100 and loses points per finding
by severity. High: minus 20. Medium: minus 10. Low: minus 4.

The part I am most proud of — honesty

Every finding is stamped with a data quality tier:

  • Tier 1 — static analysis only. Directional.
  • Tier 2 — static plus declared infrastructure.
  • Tier 3 — static plus operational telemetry.
  • Tier 4 — direct measurement. Full SCI computable.

A static scan never claims above Tier 1. The report says
plainly it is directional, not a measurement. Carbon washing
is a real problem and I did not want to add to it.

Try it

pip install -e .
sustainability-score /path/to/repo --md report.md

A sample report is included in the repo so you can see
the output before running it.

What is next

  • Broader per-language efficiency checks
  • JSON schema for the output format
  • A GitHub Action that posts advisory PR comments
  • A proposal to the GSF reference implementations collection

MIT licensed. Open source. Contributions and feedback welcome.

GitHub: https://github.com/srinathgopinath-code/sustainability-score

Top comments (0)