How the Claude Code Buddy System Works
A technical deep dive into how Claude Code deterministically generates your buddy companion.
Overview
Every Claude Code user gets a unique buddy companion generated from their user ID. The generation is deterministic — the same ID always produces the same buddy. The system uses a seeded pseudo-random number generator (PRNG) to roll all attributes.
The Algorithm
The generation pipeline has three stages:
userId + "friend-2026-401" ← salt appended
↓
wyhash ← string → 32-bit integer
↓
Mulberry32 PRNG ← seeded with hash
↓
roll() ← sequential random picksHash Function: wyhash
Claude Code runs on Bun and uses Bun.hash() (wyhash) to convert the salted user ID string into a 32-bit seed. This site loads an identical wyhash WASM implementation so results match exactly.
// Primary: wyhash (matches Bun.hash / Claude Code)
// Loaded as WASM at runtime
import { wyhash } from './wyhash'
function hashString(s: string): number {
return wyhash(s) // unsigned 32-bit
}PRNG: Mulberry32
A compact 32-bit PRNG that produces uniform random floats in [0, 1):
function mulberry32(seed: number): () => number {
let a = seed >>> 0
return function () {
a |= 0
a = (a + 0x6D2B79F5) | 0
let t = Math.imul(a ^ (a >>> 15), 1 | a)
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
}
}Roll Sequence
The PRNG is called in a specific order. Each call consumes one random number:
- Rarity — weighted roll across 5 tiers
- Species — uniform pick from 18 species
- Eye — uniform pick from 6 styles
- Hat — uniform pick from 8 types (forced to "none" for common)
- Shiny — 1% chance (rng < 0.01)
- Stats — 5 stats with peak/dump distribution (consumes multiple RNG calls)
Rarity Weights
| Rarity | Probability | Stat Floor |
|---|---|---|
| Common | 60% | 5 |
| Uncommon | 25% | 15 |
| Rare | 10% | 25 |
| Epic | 4% | 35 |
| Legendary | 1% | 50 |
Stat Distribution
Each buddy has 5 stats:
- DEBUGGING
- PATIENCE
- CHAOS
- WISDOM
- SNARK
Stats are rolled with a peak/dump system:
- Peak stat: floor + 50 + random(0-29) → capped at 100
- Dump stat: max(1, floor - 10 + random(0-14))
- Other stats: floor + random(0-39)
User ID Priority
Claude Code resolves the buddy seed from ~/.claude.json in this order:
oauthAccount.accountUuid → userID → "anon"
If accountUuid is present, it always wins. Remove it to use a custom userID. See the reroll guide for details.
Species
Name & Personality
Unlike visual traits, the buddy's name and personality are notdeterministic from the user ID. They are generated by Claude (the AI model) on first hatch using the buddy's traits as inspiration, then stored in the config as companion.
The name prompt asks for "ONE word, max 12 characters, memorable, slightly absurd" — examples: Pith, Dusker, Crumb, Brogue, Sprocket.