作者分享了利用 Claude Code 开发并上线浏览器游戏的完整工作流,提供了可复用的项目模板与工程规范。
How to build a browser game with Claude Code:
a practical guide
I recently built my first browser game with Claude Code and submitted it to CrazyGames.
Along the way I turned everything I learned into a reusable template for my next games.
Here's the approach, step by step.
1. Write the rules before writing code
The most important file in your project is CLAUDE.md. Claude Code reads it at the start of every session.
Put your working rules in it, for example:
-Plan first, build second.
No game code without an approved plan.
-For open decisions, present options with a recommendation.
I decide.
-After every milestone, report what was built, what was tested (with numbers) and what was NOT tested.
-Only commit when I say so.
That last point about untested things is underrated.
It builds trust and saves you from surprises later.
2. Keep project knowledge in docs, not in the chat
Chats end, context runs out.
Files stay.
I keep a few short documents:
-Game design: idea, rules, decisions
-Plan: milestones with acceptance criteria
-Project status: a short note for the next session
-Platform notes: a summary of the portal's requirements and SDK
-Lessons learned: everything that cost time
At the start of each session, Claude Code reads the status and asks how to continue.
It's like a handover between colleagues.
3. Start with the idea, not the tech
Describe your game idea and let Claude Code ask questions, a few at a time, each with a recommendation.
Clarify early:
-Does it fit the platform? Age rating, controls, landscape or portrait, download size.
-Why would players come back tomorrow? Daily challenges, progress, unlocks.
-What does the first minute feel like? Tutorial or straight into the game?
4. Choose the tech that fits the game
-Action, physics, particles → a game engine like Phaser
-Turn-based, board, card or puzzle games → plain TypeScript with SVG and DOM
For my turn-based game, SVG + DOM was the right call: sharp at every size, easy keyboard support, and a tiny download.
My base stack:
TypeScript + Vite, Vitest for unit tests, Playwright for browser tests.
5. Build in milestones
Something like this:
-M0 Project setup and builds
-M1 Game logic with tests
-M2 Playable core, then playtest with real people
-M3 Content, opponents, levels
-M4 Onboarding, progress, reasons to return
-M5 Platform SDK, languages, saving
-M6 QA, upload package, cover art, trailer
After each milestone:
review, play it yourself, give feedback, approve.
6. Architecture rules that pay off
-Keep game logic separate from rendering.
Then it's easy to test and to simulate.
-Put all platform-specific code (SDK, storage) behind one interface. Your game never talks to the SDK directly, so you can also build a version for your own website.
-Run heavy computations like AI in a Web Worker, so the UI never freezes.
-Make animations and timers independent of the frame rate.
-Keep all text in language files from day one.
7. Test like you mean it
-Unit tests for the rules
-AI vs. AI simulations with thousands of games.
They found balance problems before any human played.
-Browser tests at different screen sizes and in different browsers
-Performance checks on a throttled CPU, because not everyone has a gaming PC
And the most important test:
play it yourself and watch others play.
My own first play session produced more improvements than any automated test.
8. Pitfalls I ran into
-Upload showed a white screen: the portal took the files without their subfolder. The fix was a flat build with all files next to index.html.
-Double-clicking index.html shows a blank page. That's normal. Always test through a local server.
-Cover images and videos belong in their own upload fields, not with the game files.
-Let Claude Code generate cover art and trailer videos with scripts. When the design changes, you just regenerate them.
9. "It works" is not "it's ready"
My first submission was rejected because the overall quality didn't meet the platform's expectations.
Fair point:
the game worked, but it looked like a prototype.
So I invested in presentation:
a modern color design, juicy animations, opponents with personality, music, a simpler menu, and a guided first move.
Players decide in seconds, and polish is part of the game.
10. Turn it into a template
After the first game, I packed everything into a template:
rules, docs, a tested starter project and my lessons learned.
The next game starts with "Read the setup and follow the instructions" instead of a blank folder.
My takeaway:
Claude Code is strongest when you treat it like a teammate.
Give it clear rules, a good plan and honest feedback. You make the decisions, it does the heavy lifting.
Questions?
Ask below.
来源:Dominik Feltes · x.com