I kept hearing stories about what people around me had built with Claude Code. After trying some of the websites and chrome plugins that they created I was really impressed. However they were all very static, and I was curious to see how claude would do with something more complex. At first I tried making a discord clone (blog post on this coming soon) which worked out better than I expected. Then I thought to really put it to the test. How about a multiplayer browser game?
The Stack
- SpacetimeDB: A database that runs your backend logic directly inside it, no separate server needed
- Claude Code: Anthropic's CLI tool for AI-assisted coding
- Phaser: A popular 2D game framework for the browser
Starting Point: The Quickstart Template
I started by installing spacetimedb and logging in on the cli:
spacetime login Then I initialized my project with SpacetimeDB's TypeScript quickstart template, which gives you a simple chat application out of the box:
spacetime init --template quickstart-chat-typescript This template includes:
- A SpacetimeDB module with basic tables and reducers
- A React frontend with SpacetimeDB client bindings
- All the boilerplate for connecting and subscribing to data
The chat app was functional but far from a game. Time to bring in Claude.
The Initial Prompt
I gave Claude Code one detailed prompt describing the game I wanted:
Note
I initialized the current folder with a spacetimedb project. It has a very basic chat app built with react. Using this template as a starting point and using the spacetimedb documentation build a basic 2d web game using phaser. The game is called blackholio. The gameplay is similar to agar.io. Players control a colored circle using arrows or wasd keys. The circle color is different for every player. Players speed is inversely proportional to their size. The bigger the circle the slower they move. Player play inside a 2D square bounding box from which they can't leave. Player start all with the same size circle and the same speed. The bounding box is filled with randomly placed asteroids (drawn as small circles, approximately 10% the size of a player starting circle) that players can eat by overlapping their circle with them. Whenever a player eats a circle they grow in area by the amount of area they ate. Players can eat other players if their circle is bigger and they overlap by more than 50% area.
That's it. One prompt.
What Claude Built
Within minutes, Claude had:
Replaced the chat backend with game tables:
Playertable with position, mass, direction, and colorFoodtable for the asteroidsGameTickscheduled table for the server-side game loop
Implemented all the game logic:
- Movement with speed inversely proportional to size
- Collision detection between players and food
- Player-vs-player eating with the 50% overlap rule
- World boundary constraints
Created a Phaser frontend:
- Rendered all players and food as circles
- Camera that follows your player
- Keyboard input (WASD + arrow keys)
- Real-time sync with SpacetimeDB subscriptions
Wired everything together:
- SpacetimeDB connection handling
- Subscription setup for players and food tables
- Reducer calls for movement input
The game worked on the first try.
Refinement Prompts
The initial version was playable, but I wanted to polish it. Here are the follow-up prompts I used:
Prompt 2: Tuning the Feel
Note
I tried it, it mostly works, but the starting circle size is too small, while the food size is reasonable. I would make the starting player size 3 times as large. Also add some small inertia to the movement so that it doesn't feel so rigid. The last thing is that every time I eat food the camera zoom jumps up by too much. It should zoom a lot less each time and the zoom should also have some small inertia.
Claude added:
- Increased starting mass (9x for 3x radius)
- Server-side movement inertia using direction lerping
- Smooth camera zoom with configurable lerp factor
Prompt 3: Player Names
Note
Now add the ability to name the circle when spawning in as a new player and then show the name on top of the circle. Limit usernames to 10 characters
Claude added:
- A spawn screen with name input
- Name field in the Player table
- Names rendered above each player circle
- Name persistence in localStorage
Prompt 4: More Content
Note
The density of food is a little low I think there should be about 3x the amount of asteroids
A one-line constant change, deployed in seconds.
The Final Result
After about 30 minutes of prompting and iteration, I had:
- A fully multiplayer agar.io-style game
- Server-authoritative game logic (no cheating!)
- Smooth movement with inertia
- Dynamic camera zoom
- Player names
- Respawn system
- 1500 food entities spawning and respawning
All running on SpacetimeDB's cloud infrastructure with zero server management.
What Made This Work
SpacetimeDB's Architecture
SpacetimeDB collapses the traditional backend stack. Instead of:
- Database + ORM + API server + WebSocket server
You just write:
- Tables (persisted data) + Reducers (transactional functions that modify tables)
The database handles real-time sync automatically. When a reducer updates a row, all subscribed clients get the update instantly. This made the multiplayer aspect almost trivial.
Claude Code's Context Understanding
Claude Code read the existing chat template, understood the SpacetimeDB patterns, and correctly applied them to a completely different use case. It knew:
- How to define tables with the right column types
- How to write reducers that modify state
- How to use scheduled tables for game loops
- How to set up client subscriptions
Hosting
SpacetimeDB
Because I was using the spacetimedb hosted cloud service maincloud, hosting the backend was trivial, I just had to run:
spacetime publish --server maincloud alessandro-blackholio-test Additionally having the backend hosted on maincloud gave me access to the database dashboard where I could see all realtime updates as players moved in the game as well as CCU, logs and other really cool performance metrics.
I made this dashboard public so you can check it out it as well. Try playing the game and take a look at the player table to see positions updating in real time!
Hosting The Frontend
There are many ways, and many better guides, on how to host the frontend files. I chose Cloudflare Pages because it was very easy and free. I just had to make a project on the cloudflare dashboard, then after building the frontend files with
pnpm build I uploaded the build output folder (dist in my setup) as a new deployment and within seconds I had a public url I could share where the game was running.
Try It Yourself
The game is live at https://blackholio.pages.dev try it out!
Takeaways
AI + good infrastructure = rapid prototyping: The combination of Claude Code and SpacetimeDB eliminated most of the boilerplate that usually slows down game development.
Start with a template: Having a working example in the same tech stack gave Claude the patterns it needed to succeed.
Iterate in small steps: Rather than trying to describe everything upfront, I refined the game with focused follow-up prompts.
Server-authoritative multiplayer is now easy: SpacetimeDB's model makes it straightforward to keep game logic on the server where it belongs.
The barrier to building multiplayer games just got a lot lower, I am looking forward to seeing what the generation of game developers growing up with these new technologies will build.
Built with Claude Code and SpacetimeDB
