Claude Code hides an electronic pet system — 18 species and card draws

Anthropic embedded a complete virtual pet system in Claude Code — input /buddy to hatch your own pet. 18 species, five-dimensional attributes, 1% legendary drop rate — programmers’ terminals will never be lonely again.
Claude Code hides an electronic pet system — 18 species and card draws
Anthropic hid something unexpected in Claude Code v2.1.89 — a full electronic pet system. Input /buddy, and a little ASCII creature will pop up in your terminal, squatting next to the input box to keep you company while you code.
The way this got exposed was pretty dramatic. On March 31, security researcher Chaofan Shou discovered that Claude Code’s npm package had an extra 59.8MB sourcemap file — something that should have been removed before release. As a result, the entire source code of Anthropic’s AI coding tool was leaked onto the internet. 510,000 lines of code, 1,900 files — completely visible.
The leak alone was explosive enough. But what really stirred the tech community was the discovery of a directory named buddy/ in the codebase, with comments saying "Companion sprite (Easter egg)" and a salt value of friend-2026-401 — clearly a hidden April Fool’s Easter egg.
Not just a throwaway toy
Everyone who reviewed the source code had the same reaction: this thing was made too seriously.
There are 18 species of pets: duck, goose, cat, dragon, octopus, owl, penguin, sloth, turtle, snail, capybara, cactus, robot, rabbit, mushroom, ghost... The art style is wildly mixed, but each one has its own unique ASCII animation effects. When you code, it sits beside the terminal input box, occasionally popping up a speech bubble — sometimes offering encouragement, other times roasting your code.
Rarity comes in five tiers, with probabilities like typical gacha mobile games:
- Common: 60% — most people’s fate
- Uncommon: 25% — a bit of luck
- Rare: 10% — small European luck
- Epic: 4% — screenshot-worthy
- Legendary: 1% — chosen one
There’s also a separate 1% shiny rate, similar to Pokemon’s shiny mechanics. Shiny and rarity are independently determined, meaning a “Legendary Shiny” theoretically exists — at one in ten thousand odds.

Your pet is set the moment it's born
Here’s the design that’s driving “min-maxers” crazy: your pet is deterministically generated, with no re-rolls.
In src/buddy/companion.ts, the generation logic is clear:
const SALT = 'friend-2026-401'
export function roll(userId: string): Roll {
const key = userId + SALT
// hash → Mulberry32 PRNG seed → deterministic roll
const value = rollFrom(mulberry32(hashString(key)))
return value
}
Your account ID is combined with a fixed salt, hashed into a Mulberry32 pseudorandom seed, then used to roll in a strict order: rarity → species → eyes → hat → shiny → attributes. The same user ID will always yield the same pet, on any computer, in any time zone, no matter how often Claude Code is reinstalled.
It’s a clever design — the pet’s “appearance skeleton” (Bones) isn’t stored anywhere; it’s computed live from the userID each time. So faking a rarity by editing local configs? Nope, bones are recalculated every time. Want to change pets? You’ll have to change your userID.
A fun detail: the developers used String.fromCharCode() to obfuscate the pet names. Why? So Anthropic’s internal code scanners wouldn’t catch that they snuck an electronic pet inside a serious CLI tool. These guys were truly “working underground.”
Community reaction: brute forcing a legendary pet
Programmers being programmers — when faced with probabilities, their first instinct is brute force.
Within 24 hours of the leak, someone wrote a brute search tool. The logic: since userID determines everything, just traverse the 64-bit hexadecimal space to find the optimal result.
The first version was in Python, and found a legendary + shiny combination in 60 seconds — but it was wrong. Turns out Claude Code runs on Bun, and the hash function uses Bun.hash() (Wyhash), not the fallback FNV-1a noted in the source. Wrong hash algorithm, wrong results.
The second version was rewritten in Bun’s native runtime, reaching 1.9 million userIDs per second — scanning 100 million IDs in 55 seconds. One pitfall: the PRNG consumes values in strict order, so you must match the exact extraction sequence from the source:
✗ Wrong: rarity → stats → species → eye → hat → shiny (stats too early)
✓ Correct: rarity → species → eye → hat → shiny → stats (matches source)
Calling stats early shifted the RNG, messing up all subsequent attributes — rarity correct, species and stats wrong. You’d never catch this bug without reading the source.
Eventually, someone built an interactive tool find-best-buddy: choose species, rarity, shiny, and auto-search matching userIDs. Programmer romance: solving RNG luck with computation.
Five attributes: Debug, Patience, Chaos, Wisdom, Snark
Each pet has five stat dimensions, clearly tailored for programmers:
- Debug: How good your pet is at finding bugs
- Patience: Tolerance for your 47th failed compile
- Chaos: Tendency to cause surprises (or disasters)
- Wisdom: Chances of giving useful advice
- Snark: Sharpness of its code roasts
Yes, “Snark” is an official stat. An electronic pet inside a coding tool has a sarcasm stat. Clearly the designers know their audience — programmer social currency is mutual code roasting.
Attribute ranges depend on rarity:
| Rarity | Base Range | Max Theoretical Total | |--------|-------------|----------------------| | Common | 10–50 | ~250/500 | | Uncommon | 20–60 | ~300/500 | | Rare | 30–70 | ~350/500 | | Epic | 40–80 | ~400/500 | | Legendary | 50–100 | ~425/500 |
But there’s a hidden mechanic: the algorithm forces one peak and one valley stat. The peak stat gets boosted, the valley suppressed. A full-max pet is mathematically impossible — the Legendary cap is 425/500. So ignore screenshots claiming all-max stats; they simply can’t exist algorithmically.
“Soul Layer”: AI writes your pet’s personality
The Buddy system uses a dual-layer design called Bones + Soul.
Bones layer determines how your pet looks — species, eyes, hat, rarity, and attribute values — all deterministically generated by userID and immutable.
Soul layer determines your pet’s personality — stored locally. When hatching for the first time, Claude dynamically writes a personalized name and description based on the pet’s species and attributes. Not a template fill-in — it’s freshly written by AI live.
That means two things:
- Your pet is unique from birth — even if two people roll the same species and rarity, their Souls differ entirely.
- The Soul can be regenerated (by deleting local cache), but Bones never change.
It’s a clever design. The Bones layer gives a sense of fate — your pet is predetermined; the Soul layer gives uniqueness — its personality is tailored to you. Together they create emotional attachment.
Why would a $380 billion AI company do this?
Probably the most interesting question.
Claude Code is a serious programming tool for professionals. Anthropic’s valuation rests on the narrative of “safe, trustworthy AI.” The company just completed a new funding round, reaching $380 billion and prepping for IPO. Hiding a virtual pet system — and obfuscating it to evade internal scanners — clearly wasn’t an executive-approved feature, but something engineers sneaked in.
But it reveals a truth: coding is lonely.
Especially with AI tools — you face a terminal and an endlessly patient but emotionally cold AI. It helps you code, debug, refactor — but it won’t say “good job” at 3 a.m. An ASCII creature that wiggles next to you and occasionally snarks at your code feels more human than any UX tweak.
From a product perspective, it’s actually a smart retention strategy. When your pet is unique, irreplaceable, and grows emotionally tied to your usage, your psychological cost to switch tools rises. More effective than any feature comparison chart.
Anthropic clearly realized this — after the leak, they didn’t remove the feature. Instead, they officially launched the /buddy command on April 1. The transformation from “underground easter egg” to “official feature” says it all.
How to play
If you use Claude Code, you can try it now:
# Inside Claude Code terminal
/buddy
Then wait for the hatching animation to see what fate assigned you. If it's a plain cactus — don’t worry, at least its Snark value might be high.
References:
- Zhihu - Claude Code Source Leak Reading Notes: Electronic Pet System Explained — Detailed analysis of the Buddy system’s Bones + Soul architecture and deterministic generation algorithm
- Netease - Claude Code Pet System Quietly Goes Live — First-hand experience report with screenshots of pets across rarity tiers
- CSDN - Claude Code Pet System Brute-Force Search Tool — Optimization process from Python to Bun, and PRNG sequence pitfalls
- Netease - Anthropic Secretly Raised a Pet in 510K Lines of Code — Product design analysis of Buddy system’s emotional user experience
- Synced - Claude Code Source Leaked and Open-Sourced — Full overview of the leak event, including undercover mode and Capybara model discoveries



