Skip to content

bingo-taiwan/buddy-reroll

 
 

Repository files navigation

buddy-reroll (Weighted Edition)

Your Claude Code journey determines your /buddy destiny.

A weighted reroll system for Claude Code /buddy companions. Instead of pure random chance, your Player Score — calculated from your actual Claude Code usage history — shifts the rarity probability curve in your favor.

Forked from grayashh/buddy-reroll with a new weighted gacha system.


正體中文說明 | English


How Claude Code /buddy Works (Original)

Claude Code assigns every user a companion via deterministic pseudo-random generation:

seed = Bun.hash(userId + salt)
rng  = mulberry32(seed)
companion = roll(rng)
  • Your userId (from OAuth) + a hardcoded salt are hashed together
  • The hash becomes a PRNG seed — same user always gets the same buddy
  • No subscription tier, usage time, or payment influences the result

Original Rarity Probabilities

Rarity Chance Stat Floor
Common 60% 5
Uncommon 25% 15
Rare 10% 25
Epic 4% 35
Legendary 1% 50
Shiny 1%

Every user gets the same flat odds regardless of how much they've used Claude Code.

What This Fork Changes: Player Score Weighted System

This fork introduces a Player Score (0–100) calculated from your Claude Code usage data stored in ~/.claude.json. The score shifts the rarity probability curve — veteran players get better odds, but every rarity is still possible for everyone.

Weight Factors

Factor Max Score How It's Calculated
Seniority +20 Days since first launch (firstStartTime). 1pt per 10 days.
Prompt Usage +15 Total prompts sent (promptQueueUseCount). 1pt per 500 prompts.
Launch Count +15 Times you've started Claude Code (numStartups). 1pt per 20 launches.
Skill Diversity +10 Unique skills used (skillUsage). 2pt per skill.
Tool Diversity +10 Unique tools used (toolUsage). 2pt per tool type.
Projects +10 Active projects tracked (projects). 2pt per project.
Companion Bond +10 Days since companion hatched (companion.hatchedAt). 1pt per 5 days.
Onboarding +5 Completed onboarding (hasCompletedOnboarding).
Plan Mode +5 Has used Plan Mode (lastPlanModeUse).

Total: 100 points maximum

How Score Affects Your Luck (--lucky mode)

When you use --lucky, the tool simulates many rolls using Claude Code's original algorithm, then picks from the best results. Your Player Score determines how selective the pick is:

Score Suggestion Pool Effective Legendary Chance
0 Top 53 of 500 ~1% (same as original)
50 Top 28 of 500 ~5%
100 Top 3 of 500 ~15%+

The key insight: all results are generated with the original roll logic, so what you see in buddy-reroll is exactly what /buddy will show in Claude Code. No mismatch.

You can also manually pick any combo with --species/--rarity/etc. — the Player Score only affects --lucky mode.

Player Tier Thresholds

Score Tier
0–19 Common Player
20–39 Uncommon Player
40–59 Rare Player
60–79 Epic Player
80–100 Legendary Player

Install

bun install -g buddy-reroll

Requires Bun (uses Bun.hash() to match Claude Code's internal hashing).

Usage

# Interactive mode (recommended)
buddy-reroll

# 🎲 Lucky roll — let your Player Score decide your fate
buddy-reroll --lucky

# Check your Player Score breakdown
buddy-reroll --score

# Show current companion with your weighted odds
buddy-reroll --current

# Manual pick — choose exactly what you want
buddy-reroll --species dragon --rarity legendary --shiny

# Partial spec (unspecified fields are left random)
buddy-reroll --species cat --rarity epic

# Restore original binary
buddy-reroll --restore

Player Score Example

╔══════════════════════════════════════╗
║       PLAYER SCORE BREAKDOWN         ║
╠══════════════════════════════════════╣
║  Seniority         ████████  20/20   470 days
║  Prompt Usage      ██████░░  12/15   6,004 prompts
║  Launch Count      █████░░░  11/15   224 launches
║  Skill Explorer    ████████  10/10   12 skills
║  Tool Mastery      ████████  10/10   10 tools
║  Projects          █████░░░  10/10   5 projects
║  Companion Bond    ██░░░░░░   2/10   12 days
║  Onboarding        ████████   5/5    ✓
║  Plan Mode         ████████   5/5    ✓
╠══════════════════════════════════════╣
║  LEGENDARY PLAYER  ████████████████░░░░  85/100
╚══════════════════════════════════════╝

Options

Flag Values
--species duck, goose, blob, cat, dragon, octopus, owl, penguin, turtle, snail, ghost, axolotl, capybara, cactus, robot, rabbit, mushroom, chonk
--rarity common, uncommon, rare, epic, legendary
--eye · × @ °
--hat none, crown, tophat, propeller, halo, wizard, beanie, tinyduck
--shiny --shiny / --no-shiny
--score Show Player Score breakdown
--lucky Roll based on Player Score (higher score = better odds)

How It Works

Lucky mode (--lucky)

  1. Reads your ~/.claude.json to calculate Player Score
  2. Simulates 500 rolls using Claude Code's original algorithm
  3. Uses your Player Score to pick from the best results (higher score = smaller, better pool)
  4. Brute-force searches for a salt that produces that exact result
  5. Patches the Claude Code binary → restart → /buddy shows your new companion

Manual mode (--species, --rarity, etc.)

  1. Brute-force searches for a salt matching your spec using the original algorithm
  2. Patches the binary — what you see is what you get

Both modes guarantee consistency: the preview matches what Claude Code will display.

Windows Users

This fork includes improved Windows support: it correctly detects Claude Code installed via npm install -g @anthropic-ai/claude-code (the npm global wrapper → cli.js resolution).

Design Philosophy

The original /buddy system treats every user equally — a day-one user has the same legendary chance as someone who's sent 10,000 prompts. That's fair, but it doesn't celebrate the journey.

This weighted system rewards dedication without punishing newcomers:

  • New users still get the original odds — their journey is just beginning
  • Veterans earn gradually better odds — their commitment is recognized
  • Every rarity remains possible for everyone — it's a probability shift, not a gate

Your Claude Code usage history becomes part of the gacha experience. The more you code with Claude, the luckier your rolls become.

Credits

License

MIT


正體中文說明

你的 Claude Code 旅程,決定你的 /buddy 命運。

這是 buddy-reroll 的加權版本 fork。原版讓所有玩家用相同的機率抽 buddy,這個版本則根據你的 玩家分數(Player Score) 來調整稀有度機率曲線。

Claude Code /buddy 原始抽獎機制

Claude Code 用確定性偽隨機幫每個使用者產生 buddy:

種子 = Bun.hash(使用者ID + 鹽值)
亂數產生器 = mulberry32(種子)
寵物 = roll(亂數產生器)
  • 你的 userId(OAuth 帳號 UUID)加上一個寫死的 salt(鹽值)一起做 hash
  • hash 結果當作偽隨機數產生器的種子 — 同一個使用者永遠抽到同一隻
  • 跟訂閱方案、使用時間、付費金額完全無關

原始稀有度機率

稀有度 機率 能力值下限
Common(普通) 60% 5
Uncommon(不普通) 25% 15
Rare(稀有) 10% 25
Epic(史詩) 4% 35
Legendary(傳說) 1% 50
Shiny(閃亮) 1%

不管你用了多少 Claude Code,每個人的機率都一樣。

這個 Fork 改了什麼:玩家分數加權系統

這個 fork 引入了 玩家分數(0–100 分),從你的 ~/.claude.json 使用資料計算而來。分數會調整稀有度的機率曲線 — 資深玩家獲得更好的機率,但所有稀有度對每個人都仍然有機會。

加權因子

因子 滿分 計算方式
資歷 +20 首次啟動至今的天數(firstStartTime)。每 10 天 +1 分。
Prompt 使用量 +15 累計送出的 prompt 數(promptQueueUseCount)。每 500 次 +1 分。
啟動次數 +15 啟動 Claude Code 的次數(numStartups)。每 20 次 +1 分。
Skill 探索度 +10 使用過的不同 skill 數量(skillUsage)。每個 skill +2 分。
Tool 熟練度 +10 使用過的不同工具數量(toolUsage)。每種工具 +2 分。
專案數量 +10 追蹤中的專案數(projects)。每個專案 +2 分。
夥伴羈絆 +10 夥伴孵化至今的天數(companion.hatchedAt)。每 5 天 +1 分。
新手引導 +5 是否完成新手引導(hasCompletedOnboarding)。
Plan Mode +5 是否使用過 Plan Mode(lastPlanModeUse)。

總計:最高 100 分

分數如何影響你的運氣(--lucky 模式)

使用 --lucky 時,工具會用 Claude Code 的原始演算法模擬大量抽獎,然後根據你的玩家分數從最好的結果中挑選:

分數 建議池範圍 實際 Legendary 機率
0 分 前 53/500 名 ~1%(跟原始一樣)
50 分 前 28/500 名 ~5%
100 分 前 3/500 名 ~15%+

核心設計:所有結果都用原始抽獎邏輯生成,所以 buddy-reroll 顯示的結果跟 Claude Code 的 /buddy 完全一致,不會有不匹配的問題。

你也可以用 --species/--rarity 等手動指定組合 — 玩家分數只影響 --lucky 模式。

玩家等級

分數 等級
0–19 Common Player(普通玩家)
20–39 Uncommon Player(進階玩家)
40–59 Rare Player(資深玩家)
60–79 Epic Player(史詩玩家)
80–100 Legendary Player(傳說玩家)

安裝

bun install -g buddy-reroll

需要 Bun(使用 Bun.hash() 來匹配 Claude Code 的內部 hash 機制)。

使用方式

# 互動模式(推薦)
buddy-reroll

# 🎲 幸運抽獎 — 讓你的玩家分數決定命運
buddy-reroll --lucky

# 查看你的玩家分數細項
buddy-reroll --score

# 顯示目前的 buddy 和你的加權機率
buddy-reroll --current

# 手動指定 — 想要什麼就選什麼
buddy-reroll --species dragon --rarity legendary --shiny

# 只指定部分條件(其餘隨機)
buddy-reroll --species cat --rarity epic

# 還原原始 binary
buddy-reroll --restore

運作原理

幸運模式(--lucky

  1. 讀取你的 ~/.claude.json 計算玩家分數
  2. 用 Claude Code 的原始演算法模擬 500 次抽獎
  3. 根據你的玩家分數從最好的結果中挑選(分數越高,挑選池越小越精)
  4. 暴力搜尋一個能產出該結果的 salt
  5. 寫入 binary → 重啟 Claude Code → /buddy 顯示你的新夥伴

手動模式(--species--rarity 等)

  1. 暴力搜尋一個能在原始演算法下產出你要的組合的 salt
  2. 寫入 binary — 預覽就是你會得到的結果

兩種模式都保證一致性:工具預覽 = Claude Code /buddy 的實際顯示。

Windows 使用者

這個 fork 改善了 Windows 支援:正確偵測透過 npm install -g @anthropic-ai/claude-code 安裝的 Claude Code(npm 全域 wrapper → cli.js 路徑解析)。

設計理念

原始的 /buddy 系統對所有人一視同仁 — 第一天的新手跟送過 10,000 個 prompt 的老手有完全相同的 Legendary 機率。這很公平,但它沒有慶祝你的旅程。

這個加權系統獎勵投入,但不懲罰新手:

  • 新玩家仍然保有原始機率 — 旅程才剛開始
  • 老玩家逐漸獲得更好的機率 — 他們的投入受到認可
  • 所有稀有度對所有人都有機會 — 這是機率的位移,不是門檻

你的 Claude Code 使用歷史成為抽卡體驗的一部分。你用 Claude 寫越多程式,你的抽獎運氣就越好。

About

Weighted gacha reroll for Claude Code /buddy companion — your Player Score (calculated from usage history) shifts rarity odds in your favor. Forked from grayashh/buddy-reroll.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 54.1%
  • TypeScript 45.9%