Live data from Hacker News

Show HN: Badge that shows how well your codebase fits in an LLM's context window

github.com

1–10 of 47 posts

Show HN: Badge that shows how well your codebase fits in an LLM's context window

#1
Small codebases were always a good thing. With coding agents, there's now a huge advantage to having a codebase small enough that an agent can hold the full thing in context.

Repo Tokens is a GitHub Action that counts your codebase's size in tokens (using tiktoken) and updates a badge in your README. The badge color reflects what percentage of an LLM's context window the codebase fills: green for under 30%, yellow for 50-70%, red for 70%+. Context window size is configurable and defaults to 200k (size of Claude models).

It's a composite action. Installs tiktoken, runs ~60 lines of inline Python, takes about 10 seconds. The action updates the README but doesn't commit, so your workflow controls the git strategy.

The idea is to make token size a visible metric, like bundle size badges for JS libraries. Hopefully a small nudge to keep codebases lean and agent-friendly.

GitHub: https://github.com/qwibitai/nanoclaw/tree/main/repo-tokens

Show HN: Badge that shows how well your codebase fits in an LLM's context window
github.com

Re: Show HN: Badge that shows how well your codebase fits in an LLM's context window

#4
This is an interesting concept. Thank you for sharing. I have an export.sh or export.ps1 script that takes the relevant files in my repository and puts them in a `dump.txt` file inside `docs/llm`.

I am not very good with AI though. Is there a quick and easy way to calculate token count and add this to my dump.txt file, ideally using just simple, included by default Linux tools in bash or simple, included by default Windows tools in powershell?

Thank you in advance.

Re: Show HN: Badge that shows how well your codebase fits in an LLM's context window

#7

What’s the going rate for tokens in terms of dollars? How much are companies spending on “tokens”? Also kind of ironic that small codebases are now in vogue, just when google monolithic repos were so popular.

> What’s the going rate for tokens in terms of dollars?

It depends on the provider/model, usually pricing is calculated as $/million tokens with input/output tokens having different per token pricing (output tends to be more expensive than input). Some models also charge more per token if the context size is above a threshold. Cached operations may also reduce the price per token.

OpenRouter has a good overview over provider and models, https://openrouter.ai/models

The math on what people are actually paying is hard to evaluate. Ime, most companies rather buy a subscription than give their developers API keys (as it makes spending predictable).

Re: Show HN: Badge that shows how well your codebase fits in an LLM's context window

#8
Useful and useless (or good and “less good”) aren’t easily mapped to big and small.

From a purely UX perspective, showing a red badge seems you’re conflating “less good” with size. Who is the target for this? Lots of useful codebases are large.

I do agree, however, that there’s value in splitting up domains into something a human can easily learn and keep in their head after, say, a few days of being deeply entrenched. Tokens could actually be a good proxy for this.

Re: Show HN: Badge that shows how well your codebase fits in an LLM's context window

#10
post #8

Useful and useless (or good and “less good”) aren’t easily mapped to big and small. From a purely UX perspective, showing a red badge seems you’re conflating “less good” with size. Who is the target for this? Lots of useful codebases are large. I do agree, however, that there’s value in splitting up domains into something a human can easily learn and keep in their head after, say, a few days of being deeply entrenche…

> Who is the target for this?

Agents. Going to be more tools and software targeted for consumption by agents

Post reply on HN