Claude Code recently shipped /buddy — a companion that lives in your terminal and reacts to your code. You get one companion, seeded from your identity. No rerolls. No trades.
I got an Epic Cactus named "Thornquake". I wanted a Legendary Cat. So I dug into the source code, figured out exactly how it works, and got my Legendary Cat.
The Algorithm
Your buddy is 100% deterministic. Same identity = same buddy, every single time. There's no RNG at hatch time. Here's what happens under the hood:
identity + "friend-2026-401" → FNV-1a hash → Mulberry32 PRNG seed
The PRNG is then consumed in order:
- Rarity — weighted roll (common 60%, uncommon 25%, rare 10%, epic 4%, legendary 1%)
- Species — uniform pick from 18 options (duck, cat, dragon, axolotl, chonk, etc.)
- Eye style, hat, shiny (1% chance), stats (DEBUGGING, PATIENCE, CHAOS, WISDOM, SNARK)
The identity that seeds everything comes from:
oauthAccount?.accountUuid ?? userID ?? "anon"
This one line is where most people get stuck.
The Trap: accountUuid Overrides userID
A script floating around tells you to brute-force a userID and write it to ~/.claude.json. I tried it. Got a perfect Legendary Cat ID. Set it. Restarted. Got... the same Epic Cactus.
Why? If you're on a Team or Pro plan, you have an oauthAccount.accountUuid in your config. It takes priority over userID. The buddy system never even looks at userID.
The Fix
Delete only the accountUuid field from oauthAccount. Keep everything else:
{
"oauthAccount": {
"emailAddress": "you@company.com",
"organizationName": "Your Team Plan"
},
"userID": "your-brute-forced-legendary-id"
}
The nullish coalescing (??) falls through to userID. Team Plan still works because auth uses OAuth tokens, not the UUID.
Then delete the companion field from the config (forces a fresh hatch), restart Claude Code, and run /buddy.
What's Stored vs. What's Regenerated
This surprised me the most. The config only stores:
-
name(AI-generated at hatch) -
personality(AI-generated at hatch) -
hatchedAt(timestamp)
Everything else — rarity, species, eye, hat, shiny, stats — is regenerated from your identity hash on every read. The source code comment says:
"Bones are regenerated from hash(userId) on every read so species renames don't break stored companions and users can't edit their way to a legendary."
This means:
- No evolution. No XP, no leveling, no progression
- Stats are fixed. Deterministic from your identity
- You can't just edit the rarity in the config. It gets overwritten on the next read
- But you can control which identity seeds the generation. That's the exploit
The One Caveat
If Anthropic forces a re-login (token expiry, update), the server writes back your real accountUuid. Your buddy reverts. Just delete accountUuid again and re-hatch — same userID = same legendary buddy comes back (new AI-generated name, but same species and rarity).
Scripts
I put together a repo with everything you need:
ithiria894/claude-code-buddy-reroll
-
reroll.js— brute-force for any target species + rarity -
verify.js— check what buddy any ID produces (or auto-read your config) -
fix.sh— one-command recovery after a forced re-login
# Find a legendary dragon
node reroll.js dragon 2000000
# Check what your current config produces
node verify.js auto
# Fix after re-login
bash fix.sh
Happy rerolling. 🎲

Top comments (0)