Claude Code Buddy Modification Guide: How to Obtain Shiny Legendary Pets

4/2/2026
6 min read

Claude Code Buddy Modification Guide: How to Obtain Shiny Legendary Pets

On April 1, 2026, Anthropic quietly launched an Easter egg feature in Claude Code version 2.1.89 - /buddy pet system. By entering /buddy in the terminal, an ASCII-style little animal will "hatch" next to your input box, accompanying you in coding and commenting on bugs.

Each Buddy is generated by the account ID through a deterministic algorithm, meaning the same account will always receive the same pet. However, by modifying the userID in the configuration file, we can "re-roll" to get our desired pet. This article will detail the algorithm principles and provide the complete modification script.

1. Overview of the Buddy System

18 Species

The system currently includes 18 adorable species:

  • duck - Duck (classic Rubber Duck Debugging)

  • goose - Goose (mischievous)

  • blob - Jelly (soft and amorphous)

  • cat - Cat (aloof and proud)

  • dragon - Dragon (powerful guardian)

  • octopus - Octopus (multi-threaded thinking)

  • owl - Owl (wise mentor)

  • penguin - Penguin (dressed formally)

  • turtle - Turtle (steady and reliable)

  • snail - Snail (slow and meticulous)

  • ghost - Ghost (elusive)

  • axolotl - Axolotl (cute and healing)

  • capybara - Capybara (laid-back master)

  • cactus - Cactus (heartwarming plant)

  • robot - Robot (rational above all)

  • rabbit - Rabbit (lively)

  • mushroom - Mushroom (quiet observer)

  • chonk - Chonk (round and plump)

5 Levels of Rarity

  • Common - 60% probability, no hat decoration

  • Uncommon - 25% probability, unlocks hats

  • Rare - 10% probability, more decorations

  • Epic - 4% probability, exclusive decorations

  • Legendary - 1% probability, top-level decorations
Additionally, there is a separate 1% Shiny probability, shiny pets have a rainbow-colored shimmering animation! The probability of a shiny legendary is 1% × 1% = 0.01%, about one in ten thousand.

2. In-Depth Analysis of Algorithm Principles

The generation of Buddy uses a deterministic random algorithm, with the core process as follows:

1. Seed String Concatenation

const SALT = "friend-2026-401"; // April 1st April Fool's Day Easter egg const key = userId + SALT;

The salt value friend-2026-401 contains 401, representing April 1st - a carefully designed April Fool's Day Easter egg.

2. FNV-1a 32-bit Hash

Convert the seed string into a 32-bit integer:

function hashString(s) { let h = 2166136261; // FNV offset basis for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); // FNV prime } return h >>> 0; }

3. Mulberry32 PRNG

Initialize the pseudo-random number generator with the hash value: function mulberry32(seed) { 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; }; }

Mulberry32 is a commonly used lightweight PRNG in game development, suitable for procedural generation and loot drop tables.

4. Rarity Extraction (Key!)

const RARITIES = ["common", "uncommon", "rare", "epic", "legendary"]; const RARITYWEIGHTS = { common: 60, uncommon: 25, rare: 10, epic: 4, legendary: 1 };

function rollRarity(rng) { const total = 60 + 25 + 10 + 4 + 1; // = 100 let roll = rng() total; for (const rarity of RARITIES) { roll -= RARITYWEIGHTS[rarity]; if (roll < 0) return rarity; } return "common"; }

重要:RARITIES 数组的顺序必须是从低到高,这是加权随机选择的标准实现。

三、完整 Reroll 脚本

以下脚本可以搜索并生成闪光传说级 Buddy 的 userID:

// Claude Code Buddy Reroll 脚本 // 基于 Claude Code 源码逆向分析

// FNV-1a 32-bit hash function hashString(s) { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; }

// Mulberry32 PRNG function mulberry32(seed) { 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; }; }

const SPECIES = [ "duck", "goose", "blob", "cat", "dragon", "octopus", "owl", "penguin", "turtle", "snail", "ghost", "axolotl", "capybara", "cactus", "robot", "rabbit", "mushroom", "chonk" ];const RARITIES = ["common", "uncommon", "rare", "epic", "legendary"]; const RARITYWEIGHTS = { common: 60, uncommon: 25, rare: 10, epic: 4, legendary: 1 }; const SALT = "friend-2026-401"; function pick(rng, arr) { return arr[Math.floor(rng() arr.length)]; } function rollRarity(rng) { const total = Object.values(RARITYWEIGHTS).reduce((a, b) => a + b, 0); let roll = rng() total; for (const rarity of RARITIES) { roll -= RARITY_WEIGHTS[rarity]; if (roll < 0) return rarity; } return "common"; } function testUserId(userId) { const key = userId + SALT; const seed = hashString(key); const rng = mulberry32(seed); const rarity = rollRarity(rng); const species = pick(rng, SPECIES); const shiny = rng() < 0.01; return { rarity, species, shiny }; } function randomUserId() { let id = ""; for (let i = 0; i < 64; i++) { id += Math.floor(Math.random() 16).toString(16); } return id; } // Search for shiny legendary console.log("Searching for shiny legendary Buddy...\n"); const targetSpecies = process.argv[2] || null; while (true) { const userId = randomUserId(); const result = testUserId(userId); if (result.rarity === "legendary" && result.shiny) { if (!targetSpecies || result.species === targetSpecies) { console.log("Found!"); console.log("Species:", result.species); console.log("Rarity: Legendary"); console.log("Shiny: Yes!"); console.log("userID:", userId); break; } } } // Step 4 - Usage Instructions - Save the script: Save the above code as buddy-reroll.js - Run the script: node buddy-reroll.js (you can specify species: node buddy-reroll.js dragon) - Copy userID: The script will output a userID for a shiny legendary Buddy.- Modify Configuration# Edit ~/.claude.json cat ~/.claude.json | jq '.userID = "your new userID" | del(.companion)' > /tmp/claude-new.json && mv /tmp/claude-new.json ~/.claude.json

  • Restart Claude Code, enter /buddy to see your new pet!

5. Anti-Cheat Design Principles

The design of Claude Code is very clever, using a separation of Bones and Soul architecture:

  • Bones: Species, rarity, appearance, attributes — recalculated from userID each time, never persisted

  • Soul: Name, personality description — persisted to local config
This means that even if you directly edit the rarity field in the config file, the system will overwrite it with the result of roll(userID) when reading. The comment is very straightforward: editing config.companion can't fake a rarity.

However, the userID itself can be modified, which is the principle behind this method.

6. Summary

Claude Code Buddy is a well-designed Easter egg feature that combines:

  • Deterministic Randomness: The classic combination of FNV-1a + Mulberry32

  • Gacha Mechanism: 5 levels of rarity + 1% shiny, the essence of Gacha games

  • Anti-Cheat Design: Separation of bones and soul, ensuring fairness

  • April Fool's Easter Egg: The salt value hides a timestamp from April 1st
Go try it out now! I wish you luck in getting your desired shiny legendary Buddy!

References:

  • Claude Code 2.1.89 source code leak (npm source map incident)

  • Juejin: "In-depth Analysis of Claude Code Buddy Mode: The Deterministic Random Algorithm Behind a Cactus"- DEV.to: I Analyzed the Claude Code Source Code
Published in Technology

You Might Also Like