Command Palette

Search for a command to run...

Back to skills
skill № 07869

game-client

Builds the browser client of a game in TypeScript under Bun, on plain Canvas/WebGL, Phaser, PixiJS, or Three.js and React Three Fiber: choosing the stack, the…

FreeRuns bundled scripts
fcsouzaby fcsouza★ 29 GitHub stars

Install game-client in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Game Client

The client draws the world and collects input. In a multiplayer game the server owns the state (game-backend-architecture) and game-state-sync owns prediction, reconciliation and interpolation. This skill owns everything between those and the screen.

Checked against phaser 4.2.1, pixi.js 8.23.0, three 0.187.0 and @react-three/fiber 9.8.2 (bun pm view <pkg> version, 2026-11-14). An agent trained on an older major writes code that no longer runs; each stack's reference file lists those traps.

Choose the stack

The "what it is" column uses each project's own words. The "fits" and "avoid" columns are this skill's rule.

Stack What it is Fits when Avoid when
Plain web (Canvas 2D, WebGL2, WebGPU) Browser APIs; you write the loop, input, loader and batcher Few sprites, a custom renderer, a tool, a tight bundle You find yourself writing a sprite batcher or scene graph
Phaser 4 "A fast, free, and fun open source HTML5 game framework" with scenes, a loader, Arcade and Matter physics, input, cameras, tilemaps, tweens A 2D game where you want the engine to own scenes, input and physics You need 3D (v4 removed Mesh and Plane), or only a renderer under your own loop
PixiJS 8 "Just a rendering engine" for 2D; sound, UI and layout are add-ons A 2D game where you own the structure and want a fast batched renderer You want scenes, physics and gamepad input built in
Three.js "An easy-to-use, lightweight, cross-browser, general-purpose 3D library" 3D with many server entities updated every snapshot A 2D game
React Three Fiber "A React renderer for three.js" 3D inside an existing React app, mostly long-lived objects Entities that spawn and despawn every snapshot (mounting compiles materials)

Load one reference file for the chosen stack and skip the others.

Set up with Bun and TypeScript

  • Plain web: bun ./index.html serves and bundles the page with hot reloading; bun build ./index.html --outdir=dist builds it. Details in references/web.md.
  • Phaser and PixiJS: scaffold with bun create @phaserjs/game@latest or bun create pixi.js my-app --template bundler-vite. Their templates bundle with Vite; keep Vite and use Bun as package manager and runtime. No vendor source covers Bun's own bundler, so this is this skill's rule.
  • Three.js: install three and @types/three at the same version. R3F: add @react-three/fiber and match React's major (fiber 9 needs React 19).
  • TypeScript: browser code needs "DOM" in lib. Bun's recommended tsconfig lists only "ESNext". Give the client its own tsconfig so server code does not see DOM globals (this skill's rule).

Loop and timing

  • The simulation runs on a fixed step. ClientGameLoop in game-state-sync owns it: an accumulator over requestAnimationFrame, a 250 ms cap per frame, prediction on each tick, and an alpha between the last two ticks. Do not write a second fixed-step loop.
  • requestAnimationFrame follows the display rate, so a 120 Hz screen calls it twice as often as a 60 Hz one. Anything moved per frame moves by elapsed time, never a fixed amount.
  • Which loop owns the frame (this skill's rule):
    • Plain web: ClientGameLoop does. Set its onRender(state, alpha) and draw there.
    • Phaser, PixiJS, Three.js, R3F: the engine runs the only frame loop. Never call ClientGameLoop.start() and leave onRender unset. In the engine's per-frame hook, before it renders, call loop.step(now): it runs the due fixed ticks and returns the alpha. Then read loop.getRenderState() (previous and current state by reference, no copy) and the snapshot bracket from game-state-sync, and write transforms onto display objects. Each reference file names the hook.
  • The renderer reads state and never writes it. The WebSocket handler writes server state into the loop (handleServerUpdate) and never touches display objects.

Pause and resync when the tab is hidden

Most browsers stop requestAnimationFrame in a background tab, while the server keeps simulating. Simulating the whole gap on return "can be a problem for long drops" (MDN). This skill's rule:

  1. On visibilitychange to hidden: stop the client loop, clear held input, suspend audio.
  2. On visible: do not replay the gap. Drop stale interpolation snapshots, request a full snapshot, then restart the loop. When the snapshot carrying the server tick arrives, align the tick with syncTick; handleServerUpdate already adopts the server's tick when the client is behind. ClientGameLoop.start() resets the frame clock and the accumulator, so the first frame back runs no burst of ticks.

boilerplate/visibility-resync.ts does this for any loop with start() and stop(). In engine-driven mode, pass it gate = engineDrivenLoop(loop) from the same file and write the engine callback as if (!gate.paused) loop.step(now). The gate pauses stepping while the tab is hidden and during the resync, and res

Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • boilerplate/audio-unlock.ts
  • boilerplate/canvas-size.ts
  • boilerplate/input-manager.ts
  • boilerplate/visibility-resync.ts
  • references/phaser.md
  • references/pixijs.md
  • references/sources.md
  • references/three.md
  • references/web.md

FAQ

What does the game-client skill do?

Builds the browser client of a game in TypeScript under Bun, on plain Canvas/WebGL, Phaser, PixiJS, or Three.js and React Three Fiber: choosing the stack, the frame loop, hidden-tab pause and resync, keyboard, pointer, touch and gamepad input, audio unlock, canvas sizing, context loss, asset cleanup and performance budgets. Use when starting or fixing the part of a web game that runs in the player's browser: picking a rendering stack, wiring input or the render loop, a blurry or stretched canvas, silent audio, a game that jumps or leaks after switching tabs or scenes, or code written for Phaser 3, PixiJS 7 or an older three.js.

How do I install the game-client skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the game-client skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare game-client with