cd /news/developer-tools/a-one-number-triage-tool-for-c-code-… · home topics developer-tools article
[ARTICLE · art-135098] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

A one-number triage tool for C code (and a cheap feedback loop for LLM output)

A developer released c-score, a single-file, dependency-free Python tool that scores C functions on a single number derived from nesting depth, pointer depth, and dereference chains, and validated it against maintenance churn in libXt and libtiff plus 20+ years of git history for libtiff, curl, redis, and OpenMotif. The developer reports that the same score can be used as a cheap feedback loop to steer LLM-generated C toward flatter output in one rewrite round, while cautioning it is a triage aid rather than a bug detector.

by read2 min views17 publishedSep 20, 2026

C gets hard to trust in three predictable ways: deep nesting, pointers to

pointers, and a->b->c chains where nobody null-checks the middle pointer.

So I wrote a tiny scorer that squashes that into one number per function:

score(f) = nesting × pointer depth × deref chain

Each factor is one sentence:

if/ for/ while levelsint *, int **, int *** in params and locals (deeper is closer to a memory bug)a->b->c runs, i.e. null-derefs where the middle pointer came from somewhere else It's one file, zero dependencies, no parser worth mentioning.

I checked it against maintenance churn — how often a function actually gets

touched — on two very different codebases (libXt, a 40-year-old X11 toolkit,

and libtiff, a format parser):

I also ran it across 20+ years of git history for libtiff, curl, redis and

OpenMotif. None of them trend toward smaller functions — the median stays flat

and the biggest function only ever grows. Which is exactly why a cheap pointer

to the hot spots helps.

LLM-generated C has the same tell. The loop is:

generate → c-score file.c → "rewrite the top 3" → re-score

One round visibly flattens the output. A dumb, explainable number is enough to

steer an LLM — you don't need a real static analyzer for this.

It's a triage tool, not a bug detector. It won't find semantic bugs, and it

can't see a deep call stack full of side effects. The parser is not perfect,

and the Python is LLM-generated too. But the idea is the sound part — before

you pick it apart, run it on a real codebase.

pip install c-code-score
for f in src/*.c; do c-score "$f"; done \
  | awk '/^[^ ]/{n=$1} /^  score:/{print n,$2}' \
  | sort -k2 -rn | head

Repo: https://github.com/xtforever/c-score · https://codeberg.org/au1064/c-score

── more in #developer-tools 4 stories · sorted by recency
── more on @c-score 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/a-one-number-triage-…] indexed:0 read:2min 2026-09-20 ·