Zum Inhalt springen
Gist

Claude Buddy — A Patch for Perfection

April 4, 2026·2 min read
AIClaudeClaude CodeHacking

Claude Code has had a fun feature for a while: every user gets a small companion (internally called "Buddy") — a fantasy creature that sits next to the input box and occasionally comments. Species, rarity and stats are determined deterministically from the user ID.

But what if you want to choose your own buddy?

How It Works

Claude Code calculates the companion via hash(userId + salt). The salt is hardcoded into the binary. This means: if you change the salt, you change your buddy.

This gist contains two scripts:

  1. find-perfect-salt-bun.mjs — Brute-forces salts until the desired companion is found
  2. patch-claude-buddy.sh — Patches the Claude binary with the found salt

Step 1: Find the Perfect Salt

The Bun script reads the account ID from ~/.claude.json and tries salts until the desired combination of species and rarity is found:

# Find a legendary dragon
bun find-perfect-salt-bun.mjs --species dragon --rarity legendary
 
# Find a rare phoenix
bun find-perfect-salt-bun.mjs --species phoenix --rarity rare

There are 18 species (Dragon, Phoenix, Griffin, Unicorn, Kraken, ...) and 5 rarity tiers (Common, Uncommon, Rare, Epic, Legendary). The probabilities are weighted — Legendary is accordingly rare and takes more attempts.

The script outputs the best salt found, including the 5 companion stats:

  • Debugging — How well does the buddy help with debugging?
  • Patience — How patient is it during long tasks?
  • Chaos — How unpredictable are its comments?
  • Wisdom — How wise is its advice?
  • Snark — How sarcastic is it?

Step 2: Apply the Patch

bash patch-claude-buddy.sh "YOUR_FOUND_SALT"

The script:

  • Copies the original binary as backup
  • Replaces the salt via sed (same byte length — important!)
  • Re-signs the binary with codesign --force --sign -
  • Removes the stored companion from ~/.claude.json so it gets recalculated on next startup

Reverting

bash patch-claude-buddy.sh --revert

Restores the original binary.

Requirements

  • macOS (because of codesign)
  • Bun (for the salt-finding script)
  • Claude Code must be installed locally

Why This Is Interesting

This gist nicely demonstrates how Claude Code works internally: deterministic hashing for personalisation, a compiled binary with embedded constants, and the fact that the companion state lives in ~/.claude.json under the companion key. Deleting this key triggers a re-hatch on the next startup — which you can leverage even without patching the binary.