I Built a SLOC Counter That Speaks Fluent CFO (and Still Thinks Like an Engineer)
In every serious conversation about software value, there is a moment of awkward silence. Engineers want to talk about architecture, trade offs, and the quiet heroism of keeping a 15 year old system alive. Leadership wants a number they can defend in a boardroom. Finance wants a model with calibrated constants and citations. And the codebase just sits there, vast and indifferent, shipping features while quietly accumulating entropy.
I got tired of translating between these worlds with hand gestures and optimism, so I built a tool that does the translating for me. It is not a flashy dashboard. It is not a “lines of code equals productivity” vanity metric. It is a pragmatic, zero dependency Python script that counts physical SLOC like a grown up, detects the lies we accidentally check in, and then turns that raw mass into COCOMO II estimates of effort, schedule, staffing, and cold hard dollars.
Think of it as SLOCCount’s more worldly cousin. Still opinionated, still imperfect, but finally ready for the meetings where real decisions get made.
Why SLOC Refuses to Die (Even in 2026)
Everyone loves to dunk on lines of code. “It’s not about quantity,” we say, while quietly knowing that quantity has a quality all its own.
Here is the uncomfortable truth. SLOC is software’s best proxy for mass. Not value. Not quality. Not elegance. Mass. Mass is the surface area you have to understand when you onboard. Mass is the attack surface for bugs and security debt. Mass is the cognitive load when you are estimating a rewrite, valuing an acquisition, or answering the dreaded question: “What did we actually build this year?”
And in a world increasingly flooded with AI generated scaffolding, glue code, and “it works, do not touch it” artifacts, mass matters more than ever. Most SLOC tools stop at counting. That is where the arguments start. Counting gives you a number, but it does not give you a narrative, and leadership will always ask for the narrative. What kind of code is this. How much is generated junk. How dense is the decision making. What does this imply for real world effort and cost.
If you want SLOC to be useful, it has to graduate from trivia to translation.
Estimation Model That Survived Reality
COCOMO II is one of those rare artifacts that actually got better with age. It is a calibrated estimation model built from decades of real project data. It takes software size, usually KSLOC, plus project characteristics, and produces estimates of effort, schedule, and team size.
It is not magic. It is calibrated. And this is the part I love, it forces your assumptions into the open. Most estimation fights are not about math. They are about hidden assumptions. Is this an organic project with a cohesive team and a familiar domain, or is it embedded with hard constraints and unresolved risks. Are we leveraging modern tools, or fighting the build system daily. Do we have the kind of team cohesion that makes coordination cheap, or the kind that makes every meeting a small scale disaster.
COCOMO makes you pick a story about your project, then attaches arithmetic to it. My tool implements the Post Architecture model with the classic constants, including A = 2.94 and B = 0.91, plus mode presets that shift scale factors accordingly. Effort multipliers stay nominal at 1.0 by default for a clean baseline, because sometimes the first honest number is the most useful one.
It will not replace your PMO’s sacred spreadsheet. It will give you a number you can defend without lying to yourself.
And in my experience, “defensible without self deception” is a very premium feature.
What the Tool Actually Does
At its core, the script is ruthlessly practical.
It scans intelligently. It respects .gitignore, skips node_modules, venv, build directories, and the other usual suspects, then identifies languages by extension and by key filenames like Dockerfile, Makefile, and CMakeLists.txt. That second part matters because a surprising amount of your system lives in files that are not “code” until they break production. It detects generated code. It peeks at file headers for markers like “auto generated” or “do not edit,” then excludes those files from the counts. This single feature is the difference between a report that starts arguments and a report that ends them. If 40 percent of your SLOC is generated, that is not a rounding error, that is a strategy. It counts honestly. Physical SLOC, comments, blanks, and a humble complexity proxy based on control flow keywords. It is not pretending to be SonarQube. It is giving you enough signal to spot patterns that matter. You will notice when SQL is only 5 percent of SLOC but carries a disproportionate share of branching density. You will notice when complexity clusters in a small set of services, which is often where delivery slows down and incidents get born.
It runs fast. It parallelizes per file analysis with ProcessPoolExecutor, because due diligence windows close quickly and nobody has ever said, “Take your time, we love uncertainty.” It includes basic Git intel. Authors and commit count, just enough to remind you that this is not greenfield, it is a living organism with a history, and the history is usually where the interesting truths hide.
The default output is a clean, ASCII report you can paste into Slack without shame. Total SLOC, language distribution, complexity signals, COCOMO effort and schedule estimates, and a cost estimate based on your salary and overhead assumptions. Run it like this:
python3 sloc_cocomo.py ./my-repo --mode organic --salary 180000 --overhead 2.4
Or pipe JSON for your dashboard:
python3 sloc_cocomo.py ./my-repo --format json > analysis.json
The Part Where We Admit This Is Not an Oracle
This tool will not tell you the future.
COCOMO can overestimate when modern frameworks and cloud leverage shrink effort. It can underestimate integration hell, compliance overhead, or the gravitational pull of organizational entropy, which is a real physical force even if physics departments refuse to acknowledge it. But here is the deeper point. Even when the number is wrong, the conversation improves. Suddenly you are debating assumptions instead of vibes.
Is our process maturity high enough to justify an organic posture, or are we living in embedded reality because architecture risk never got resolved. Are we paying schedule penalties because coordination is expensive, or because we are trying to do novelty work while pretending it is routine. Is this 30 KSLOC cohesive, or is it a minefield wearing a clean shirt. That shift is leadership gold. It turns estimation from performance art into engineering.
Software Valuation Is Mostly About Exposure
When people ask, “What is this codebase worth?” they often mean, “How expensive will it be to change?”.
That is why mass matters. That is why generated code matters. That is why complexity density matters. And that is why a model like COCOMO is useful, not because it is perfect, but because it makes your exposure legible.
In 2026, legibility is the scarce resource. We are entering an era of exploding software mass. AI can generate thousands of lines in seconds. Frameworks emit mountains of boilerplate. Fragile, no-touch zones multiply. The result is that the physical size of systems grows faster than the human ability to reason about them.
So the question is no longer around how much code do we have. The question is: “How much of this is human intent, and how much is machine scaffolding that looks like intent?”. Distinguishing those two is going to become a core competency for engineering leadership. Not a nice to have. A survival trait.
Better Truth Interfaces for Codebases
We built observability for production systems because flying blind is expensive.
We now need truth interfaces for codebases for the same reason.
I built this tool because I was tired of bringing a knife to a gunfight of assumptions. It is not perfect. It is not pretending to be. But it is useful, and in software, useful beats perfect every time. If you are valuing IP, planning a modernization, or trying to answer “what did we actually build,” give it a spin. If you want the next level, driver customization, duplicate detection, first class reporting on generated and test proportions, and a longitudinal dashboard schema, those are the obvious upgrades.
Sometimes the best way to value code is to measure it honestly, translate it clearly, and let the real conversation begin. This tool has been open-sourced under the MIT license: https://github.com/josh-english-2k18/sloccount
Josh English is a member of the Applied AI Association (AAIA) gaming council, and can be followed on X (@JoshSeriesAI)