# Create and build a game with @spawnkit/cli

Create a standalone game project with @spawnkit/cli, install dependencies, run the game, and build browser files for publishing.

Start in a parent folder, generate your game, then run every development command inside the new game folder.

<a id="prerequisites"></a>

## Before you start

You need Node.js 24 or newer and pnpm 12. Local game creation needs no SpawnKit account. Run the published `@spawnkit/cli` package with pnpm or npm. You can also start from a [downloadable starter kit](https://spawnkit.cloud/docs/getting-started).

**Check the game development tools**

```sh
node --version
pnpm --version
```

You work in your own game project. Keep all work inside your own game folder. See [tool installation and version checks](https://spawnkit.cloud/docs/getting-started#before-you-start) if either command is missing.

<a id="generate"></a>

## 1. Generate a new game

Open a terminal in the folder where you keep your projects. Choose a new directory name: the CLI refuses to overwrite an existing folder. These tabs launch the same CLI package.

**pnpm**

```sh
pnpm dlx @spawnkit/cli init my-game --add phaser,vitest --dry-run
pnpm dlx @spawnkit/cli init my-game --add phaser,vitest
```

**npm / npx**

```sh
npx @spawnkit/cli init my-game --add phaser,vitest --dry-run
npx @spawnkit/cli init my-game --add phaser,vitest
```

The dry run shows the proposed files and selected components. The second command asks for confirmation; review and accept it to create the files. In a noninteractive agent session, use `--yes` only after reviewing the dry-run plan. Phaser supplies the renderer and Vitest supplies tests. For other choices, run `pnpm dlx @spawnkit/cli addons --json`; use `pnpm dlx @spawnkit/cli init` for interactive setup.

<a id="run"></a>

## 2. Install and run your game

**Enter the generated game folder**

```sh
cd my-game
pnpm install
pnpm dev
```

Open the HTTPS address printed in the terminal. The starter scene should appear; use the arrow keys to collect gold. Follow the certificate setup if prompted. Run `pnpm exec dev-domains doctor` if the local address does not open. Leave the server running while editing. Open a second terminal in `my-game` for the checks below, or stop the server with Ctrl+C first.

Open this same `my-game` folder in your editor or AI agent. `package.json`, `src/`, and `AGENTS.md` are at its root. See the [Codex](https://spawnkit.cloud/docs/codex), [Claude Code](https://spawnkit.cloud/docs/claude-code), and [Cursor](https://spawnkit.cloud/docs/cursor) guides.

<a id="build"></a>

## 3. Test and create a production build

**Inside my-game; Vitest was selected above**

```sh
pnpm lint
pnpm test
pnpm build
pnpm preview
```

The build checks TypeScript and writes browser files to `dist/`. Preview serves that build locally and keeps running until you stop it with Ctrl+C. Play through the scene and check the browser console before publishing. If you chose a kit without tests, use only the scripts present in its `package.json`.

A successful local build does not upload anything. Follow [Publish your game](https://spawnkit.cloud/docs/publishing) to ZIP the contents of `dist/` and upload them, or use the [CLI deployment reference](https://spawnkit.cloud/docs/cli#deployments) to deploy source.
