ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 nnixaa

code-race

一個 Claude Code 外掛,讓你在提示列正上方和其他使用者進行打字競賽,支援好友房、排行榜與機器人備援,後端由 Cloudflare Worker 伺服器提供。

nnixaa@nnixaa

nnixaa/claude-code-race/tree/main/plugins/code-race

已翻譯

關於這個 mod

Code Race 新增 /race 指令(以及 Claude 思考時顯示的 Race 按鈕),讓最多四名玩家在提示列上方輸入同一行程式碼或開發者備註。它支援公開競賽、含邀請碼的好友房、暱稱、獎牌,以及以 /race top 開啟的排行榜;排行榜依最快競賽、參賽次數與勝場為玩家排名。競賽者會在終端機中顯示為 Claude Code 的吉祥物 Clawd。透過外掛市集安裝(/plugin marketplace add nnixaa/claude-code-race,接著 /plugin install code-race@claude-code-race),需要 Claude Code 2.1.284 或更新版本。外掛的 hooks 會連線到競賽伺服器(使用 Durable Objects 與 D1 的 Cloudflare Worker),只傳送隨機玩家 id、暱稱,以及每場競賽的進度/錯誤次數;無法連線伺服器時支援離線和機器人對戰。後端可以從 server/ 目錄自行代管。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add nnixaa/claude-code-race
claude plugin install code-race
原文 / README

Code Race for Claude Code

Typing races against other Claude Code users, right above your prompt. Waiting on Claude? Race.

<img src="docs/race.png" width="640" alt="A race in progress above the prompt: four lanes with Claude's mascot in each, the line to type with the next character highlighted, and the same line half typed in the message box">

Play

| Command | | | --- | --- | | /race | Race whoever is around. The room waits 10 seconds for players, and bots take the seats nobody took, so there is always a race. | | /race friend | Make a room for your friends. It gets a five-letter code. | | /race join <code> | Join a friend's room. | | /race top | Show the leaderboard. | | /race nick <name> | Race under a name. It starts a race too. |

While Claude is thinking, the Race button beside the spinner starts a race too.

A race

  • Up to four people race the same line. Half the lines are code (TypeScript, Python, Go, SQL, shell, CSS) and half are short notes in the style of developer docs.
  • The line shows above the prompt in a monospace face and opens a little at a time. Type it in your message box. A mistake turns red until you delete it, and Enter sends nothing while a race runs.
  • Whatever you had in the message box before the race is put back after it.
  • At the end: medals at the finish line, a crown for the winner, your place, words per minute and accuracy, and Rerace.
  • In the terminal every racer is a small Clawd, Claude Code's mascot, swinging its arms as it runs and raising them at the finish.

Racing friends

  • /race friend makes a room and shows its code. Copy invite puts /race join <code> on your clipboard to send.
  • Anyone in the room presses Start. There are no bots: only the people in the room race.
  • Rerace takes everyone into the room's next race, under the same code.

Leaderboard and names

<img src="docs/leaderboard.png" width="640" alt="The leaderboard above the prompt: medals for the top three, each player's mascot, their fastest race, races and wins, and your row lit">
  • /race top ranks everyone by their fastest finished race, with how many races they ran and won. Your row is lit, and shown under the top ten when you are not in it.
  • A name is one player's. Whoever first races under it keeps it, /race nick refuses a name that is taken, and anyone else under it races as anon-….

Install

Requires Claude Code 2.1.284 or later. The terminal and the desktop app both work.

/plugin marketplace add nnixaa/claude-code-race
/plugin install code-race@claude-code-race

Then start a new session.

Code race is a mod: a plugin of function hooks, which Claude Code offers as an early-access surface, so a release may change how it looks or behaves.

What it sends

To the race server: a random player id the plugin makes (with desktop or terminal, so the two apps are two players), your nickname, and during a race how far along the line you are and how many mistakes you made. A friends' room adds its code. What you type stays on your machine; only the count of matching characters is sent. Nothing from your sessions, prompts, code or account is sent.

The server keeps every race and result (the id, nickname, times, words per minute, accuracy) and who holds each name, for the leaderboard. Other racers see your nickname, never your id.

Without the server the plugin races bots offline.

Server

server/ is the backend: a Cloudflare Worker with Durable Objects for the lobby, each race and each friends' room, and D1 for races, results and names. It runs on Cloudflare's free plan, with a daily cap on joins and a smaller one per address (JOIN_CAP_PER_DAY in wrangler.toml, PER_ADDRESS_PER_DAY in src/index.ts). How fast the bots type is BOT_WPM_MIN and BOT_WPM_MAX. To run your own:

cd server
npm install
npx wrangler d1 create code-race   # put its id in wrangler.toml
npx wrangler d1 migrations apply code-race --remote
npx wrangler deploy

Then point SERVER in plugins/code-race/hooks/register.tsx at your Worker. For local work, npm run dev serves it on port 8787, npm run smoke races two scripted players against it, and node scripts/opponent.mjs [name] [wpm] [minutes] [server] waits in the lobby and races whoever comes.

Working on the plugin

claude --plugin-dir plugins/code-race loads it from this folder and reloads it on save. claude plugin validate plugins/code-race checks it the way Claude Code will. The engine writes the API's TypeScript declarations into plugins/code-race/.claude-plugin/types when it loads the plugin (or run /plugin-types there), and tsconfig.json uses them.

Limitations

  • On the desktop app the Race button shows while Claude is thinking, not while a tool runs, and the other racers move once a second.
  • In a very short terminal window the lanes sit right against each other; from about 26 rows there is a gap between them.

License

MIT

更多類似作品