Files
posthog.com/contents/tutorials/deskhog-claude-tutorial.md
Joe Martin a5d9edd58f DeskHog tutorial - Claude version (#12142)
* Claude Tutorial

* Update index.tsx

* Update contents/tutorials/deskhog-cursor-tutorial.md
2025-07-11 08:56:58 +00:00

9.0 KiB
Raw Permalink Blame History

title, date, author, showTitle, sidebar, tags
title date author showTitle sidebar tags
How to vibe-code a game with DeskHog using Claude Code 2025-07-10
joe-martin
true Docs
AI
DeskHog

DeskHog is an open-source developer toy for building your own apps and games from scratch. Its not just for experienced developers either — AI coding agents like Claude Code enable anyone to start building apps using natural language.

This tutorial shows you how to build a simple game for DeskHog using Claude Code, PlatformIO, GitHub, and some example prompts. Well start from the basics (no prior C++ experience needed) and quickly work towards a basic Flappy Bird-style game running on DeskHog.

Getting started with GitHub, Claude Code, and PlatformIO

First, gather the tools youll need for this tutorial. Grab a USB-C data cable to connect your DeskHog to a computer and plug it in to charge. If you havent connected DeskHog to WiFi before, scan the DeskHogs QR code with your phone and do that now.

Next, download GitHub Desktop. This will be useful for managing code versions locally and syncing with the GitHub repository.

What is a GitHub repository?
GitHub is a platform for hosting and collaborating on code. Code (like the DeskHog software) lives in repositories (“repos”). DeskHogs repo is open-source (meaning it is public and free to use). When you clone the repo to your computer, you'll get a local copy of the code. You can then create your own branches of the codebase to make changes, and eventually commit and merge those changes back (via a pull request) for others to see.

Once GitHub Desktop is installed, use it to clone the DeskHog repository. The quickest way is to visit the the DeskHog repo in your browser and open it in GitHub Desktop.

Cloning the DeskHog repo

Now that you have a local copy of the DeskHog code, you need a way a code editor and AI assistant to help.

If you dont already have a code editor, install Visual Studio Code and set it as your preferred code editor in GitHub Desktops settings (Settings > Integrations).

Next, set up Claude Code, Anthropics AI coding assistant for vibe-coding. Claude Code works in your terminal. Youll need Node.js 18+ installed. If you dont have it, download and install Node.js from the official website. Then open a terminal and install the Claude Code CLI globally with this command:

npm install -g @anthropic-ai/claude-code

This command downloads and sets up Claude Code. Once installed, start Claude Code in any project by opening a terminal in the project folder and running:

claude

The first time you run it, you may be asked to log in or provide an API key for Anthropic just follow the on-screen steps. After that, youll see a welcome message in the terminal indicating Claude Code is ready for vibe-coding.

What is vibe-coding?
Vibe-coding means interacting with the codebase through an AI agent without necessarily knowing how everything works. You describe what you want in natural language, and the AI (Claude Code) writes or modifies the code to make it happen. This approach isnt without risks — the AI might misunderstand or produce imperfect code — but if you have limited coding experience, its an effective shortcut to get things working.

Finally, lets install PlatformIO, which will allow us to build and deploy code to DeskHog.

What is building and deploying? When you create code, DeskHog wont understand it on its own. Instead, you need to use PlatformIO to build the code and then deploy it to the device. Building is the process of translating your code into something the device can understand, while deploying is the process of moving it onto the device. Think of it like youre cooking a meal. First, you create a recipe (writing the code), then you follow the recipe (building the code), then you serve the meal (deploying the code). Claude helps us with the first step, while PlatformIO handles the last two.

Install the PlatformIO IDE extension in your code editor. In VS Code, open Extensions and search for “PlatformIO IDE” and install it. Once installed, youll see new icons or toolbar buttons for build and upload tasks. Youll use these shortly.

Creating a branch and adding some code

Your tool stack is ready — now its time to put it to work. First, create a new branch so youre not editing the main code directly. In GitHub Desktop, click the current branch name (“main” by default) and select "New branch". Give your branch a descriptive name, such as flappy-bird-game.

With the new branch created, open the project in your editor by clicking "Open in Visual Studio Code" from GitHub Desktop.

Now its time to vibe-code using Claude Code. In VS Code, open a terminal and run this command:

claude

Claude Code will initialize by reading your project files. You can help it out by running this command to create a CLAUDE.md file that helps Claude learn faster:

``bash /init


When Claude Code is ready, it will prompt you for input. Heres a good first prompt:

```prompt
Create a Flappy Bird-style game. Use only simple rectangles and circles for graphics. The player controls a character that jumps when the CENTER button is pressed (one of three physical buttons on the DeskHog device). Make the game loop responsive and keep the visuals minimal.

Hit Enter and let Claude think. Claude will analyze your project, then draft the necessary code. It will ask you to approve changes before applying them, so keep approving them.

Claude asks for a lot of approvals

Once accepted, Claude applies the edits to your files. Youll likely see new files for your game logic (like FlappyGameCard.cpp and a header file) and edits to the UI or card registry so your game shows up on the DeskHog menu.

Deploying and testing your code

With the new code in place, its time to build and deploy it to your DeskHog. This is where PlatformIO comes in. In your editor, click the PlatformIO “Build” (✔️) button, or run the “PlatformIO: Build” task from the command palette.

Building with PlatformIO

PlatformIO will compile the code and you can watch the output in the PlatformIO console. The first build may take longer. If successful, youll see a “SUCCESS” message.

Next, with your DeskHog connected to the computer by a USB data cable, click the “Upload” (arrow) button to deploy the compiled code to DeskHog. PlatformIO will upload the firmware and reboot your DeskHog automatically.

If everything goes smoothly, you should be able to navigate to your new game on the DeskHog and play it - though you may need to enable the card in your stack. You can do this by navigating to the IP address of your DeskHog device, which is shown on the main screen when it connects to the WiFi. Your Flappy Bird-style game should show basic shapes for graphics, with the CENTER button controlling the jump.

Iterating, bug-fixing, and committing

Its common to hit a bug or see unexpected behavior. Vibe-coding is an iterative process: prompt Claude, build and test, fix issues, and repeat.

For example: if your game compiled and uploaded, but you dont see it on the DeskHog card menu then you could tell Claude Code the following:

The Flappy game doesnt show up in the menu. The UI uses `CardController`. Please fix it so the game appears.

Claude will check the relevant files (like CardController.cpp) and suggest a fix — for example, attaching the games card properly to the UI navigation stack. Approve the fix, rebuild with PlatformIO, redeploy, and test again. This is the vibe-coding loop.

If you get compiler errors, copy the error into Claude and ask it to fix it. If youre stuck, ask Claude to explain whats wrong so you can investigate further. Claude Code can usually resolve most C++ issues step by step.

Once you have a working version, it's time to commit your changes. Save all the modified files in VS Code, then switch to GitHub Desktop. Youll see your changes listed. Add a descriptive commit message like “Add Flappy Bird game,” then click Commit.

Committing only saves your changes locally. When youre ready to share your work, click Publish branch in GitHub Desktop to push your branch to GitHub, then Create Pull Request to open GitHub in your browser. Add a title and description, then submit the PR. Other DeskHog developers can then review and merge it so everyone can enjoy your game.

Congratulations — you just vibe-coded a game from scratch using Claude Code and can officially add "Game developer" to your LinkedIn profile.