I run a small side project called aprimeforyou.com. The premise is simple to explain and slightly absurd to actually offer for sale: you give me your name, I give you a personalized prime number. You get a printable certificate, an entry in a public registry, and the satisfaction of owning a number that, mathematically, is yours.
The current implementation works like this. We take your name, run it through a SHA-256 hash, then search forward from the resulting integer until we hit a prime number. That prime — usually 39 digits long, the kind of thing that looks like the back of a barcode — is yours.
It’s a clean design. The hash gives you uniqueness; primes are inexhaustible; the math is genuinely interesting. I’ve shipped it, sold a handful, and friends seem to enjoy it.
But it’s been bothering me.
The itch
Two things, specifically:
- The numbers are too long to comprehend. Thirty-nine digits is a string of digits, not a number anyone can hold in their head. It’s the difference between a phone number and an IPv6 address. The certificate is beautiful, but the number on it doesn’t feel personal — it feels like a UUID.
- It’s a one-way street. SHA-256 is a cryptographic hash; it’s deliberately irreversible. So while your name produces your prime, your prime can’t produce your name back. There’s no way to look at the number and recover the thing that made it. That’s mathematically appropriate but emotionally wrong for a product premised on personal connection.
These problems aren’t accidents — they’re the cost of design choices that solve real things. The hash gives uniformity (everyone’s prime is the same impressive size, regardless of whether their name is “Ty” or “Alexander ‘The Great’ Taggart”). The irreversibility is a side effect of using a real one-way hash, which is what gives us collision resistance.
But “we made tradeoffs to solve real problems” doesn’t mean you can’t revisit them.
The idea
What I wanted: a prime that’s still distinctive, still mathematically grounded, but shorter, and recoverable given some small extra piece of information. I started sketching:
What if every customer also got a tiny key — like
E42— that, combined with their prime, would let them recover their original name? Same name twice still produces two different primes (uniqueness preserved), but each one decodes back to the original.
That’s the kernel. Now the hard part: figuring out if the math actually works.
Bringing it to Claude Code
I’ve been using Claude Code as my main development environment for the last few months, and I’ve started doing more of my early-stage design thinking inside it rather than in a notebook. The reason is mundane: when an idea gets to “let me just check the codebase,” “let me sketch what the algorithm would look like,” or “let me actually run the numbers on real data,” I’m already in the right tool. There’s no context switch.
So I opened a chat in the project, dumped the idea, and asked Claude to think through what the math might look like.
The first response did exactly what I wanted: it didn’t just say “yes, that works.” It restructured the problem. The original framing — “generate a prime, then make it reversible” — turned out to be backwards. The right shape is:
- Encode the name as a number.
- Encrypt that number with the customer’s key.
- Search nearby for a prime — and let the search itself land you on one.
- To reverse: decrypt the prime with the key, get the name back.
The “search for a nearby prime” step is what makes this work. The Prime Number Theorem tells us that ~1 in every ln(N) integers near a 128-bit number is prime — about 1 in 89. So you can keep tweaking a tiny “nonce” inside the encrypted block until you happen to land on a prime, which is fast in practice. The nonce becomes invisible to the user but does the heavy lifting of guaranteeing primality.
Claude sketched cipher choices (a small Feistel network, not AES — the block sizes are wrong for AES, and AES is overkill for what is fundamentally an educational easter egg), key length tradeoffs (a 3-character key is trivially brute-forceable, but that’s the point — the puzzle is the cryptanalysis lesson), and, crucially, was honest about a problem I’d missed: the prime length doesn’t actually shrink unless I shrink the input first.
A 30-character name is 240 bits as ASCII. Encrypting 240 bits gives you a ~75-digit prime. Worse than today.
The Huffman rabbit hole
This is where the conversation went somewhere genuinely interesting. To shrink the input, I needed to compress it. Claude proposed Huffman coding: a 1952 algorithm that assigns shorter bit-strings to more common letters and longer ones to rarer letters. “E” might cost 3 bits, “Q” might cost 9. For English text, this gets you about 4.1 bits per character on average instead of 8 — a ~50% reduction on long inputs.
I asked for an explanation of how Huffman actually works, because I wanted to really understand it, not just trust the recommendation. What came back was a small lecture: the prefix-free constraint, the binary-tree representation, the greedy algorithm, the Shannon entropy floor it approaches, the elegant proof that a greedy algorithm can be provably optimal. I learned things.
Then I asked the obvious follow-ups:
- What if someone enters “zzzzzzzzz” or a name from a language with totally different letter frequencies? This led to a clear-eyed discussion of cross-entropy, codebook overfitting, and the half-dozen practical mitigations (fallback flag, multiple codebooks, adaptive Huffman, just-use-Zstandard).
- Is there a way to compress letter combinations, not just single letters? This opened up the entire LZ77 / LZ78 family, which led to the modern compression stack (BWT, arithmetic coding, ANS), which led to the genuinely beautiful theoretical convergence between compression and language modeling: a sufficiently good language model is, formally, an optimal compressor. (DeepMind has a 2023 paper showing GPT-class models compress images better than PNG, despite being trained only on text. The deep theorem here is from Shannon, 1948.)
None of this was strictly necessary for my product. But it’s the kind of context that makes me trust the tool I’m about to commit (but verifying from other sources is always good anyway).
Running the numbers
Theory is theory. The next question was: does this actually shrink the primes for real names?
I generated a CSV of 500 made-up American names — John Williams, Jennifer Johnson, that sort of thing — and asked Claude to write a script that would:
- Build a Huffman tree from the corpus.
- Encode every name and verify roundtrip correctness.
- Report what cipher block sizes (and therefore prime lengths) would result.
We caught three real bugs together in the process:
- A NUL byte where a space should have been, introduced somewhere in the round-trip between my prompt and the file on disk. Caught by reading the actual bytes with
od -c. - A phantom symbol in the codebook sitting at exactly the right frequency to be a stray carriage return — the CSV had Windows line endings, and
split('\n')had left\rcharacters trailing on every name. Each name was costing four extra bits unnecessarily. - Missing apostrophe and hyphen in the codebook. The corpus didn’t contain “O’Brien” or “Mary-Jane,” so those characters had no codeword and would have hit a slow, wasteful escape path in production.
These are the kinds of bugs that are obvious in retrospect and would have cost me real time alone. The collaboration model — I notice the suspicious data, Claude proposes the diagnosis, we both verify with a quick command — is faster than either of us working solo.
The final numbers, on real-corpus data:
| Block size | Approx prime digits | % of names |
|---|---|---|
| 64-bit | ~20 digits | 64.2% |
| 96-bit | ~29 digits | 35.8% |
| 128-bit | ~39 digits | 0% |
Today, every customer gets a 39-digit prime. Under the new design, two-thirds of customers would get a ~20-digit prime — about the length of a credit card number, comprehensible at a glance. The remaining third gets ~29 digits. Nobody gets the old 39-digit experience.
That’s the product change. That’s the artifact.
The pragmatic close
A surprising amount of the value in this kind of session is in the closing-down phase. We had a working analysis script, a confirmed compression result, and a path forward. The temptation when working alone is to keep optimizing — train the codebook on a larger corpus, model out the worst-case names from non-English languages, sketch the cipher in detail.
Claude pushed back gently: this is a side project with single-digit weekly sales; the algorithm-version system already supports painless future migration; “ship the codebook we have, plus a couple of obvious fixes, and don’t pre-optimize for users who don’t exist yet.” That matched my instinct, but having it stated cleanly made me commit to it instead of drifting into another two hours of refinement.
We finished by drafting two GitHub tickets in the format my project’s /start workflow expects (see Code Cannon skills!) — one for the algorithm work, one for a /decode page where customers can actually use their key to recover their name.
On the working method
I want to be careful not to mythologize this. Claude Code didn’t have the idea, didn’t decide what to build, didn’t make the product judgments about what tradeoffs were acceptable. Those were mine. What it did was function as an extraordinarily capable thinking partner: explaining unfamiliar math at the level of detail I asked for, sketching code I could run immediately, catching bugs in real time, modeling out scenarios I hadn’t thought of, and — perhaps most usefully — pushing back on premature optimization at the right moment.
The thing I keep coming back to is how integrated this kind of work feels. The same session moved through: a half-formed product idea, a math primer on cryptography, a compression theory deep-dive, a working analysis script, debugging a CSV parser, looking up the existing algorithm-versioning code in the repo, drafting GitHub issues in the project’s specific format, and a blog post draft. None of those steps required leaving the editor. None of them lost context. The “agent” framing for tools like this often gets reduced to “code generation,” but the more important capability is staying in one conversation across the whole arc of an idea.
There’s a version of this post I could write that’s entirely about the math — Huffman codes are genuinely beautiful, and I’d like to write that post too. But this one is really about a working method I’ve started to trust: have the half-formed idea, take it into a tool that can think with you about all of it (the math, the code, the tradeoffs, the implementation), and let the conversation decide what’s worth building.
The 39-digit number is going to become a 20-digit number, plus a tiny key like E42, soon. I’ll write again when it ships.