Phaser Build logo

Phaser Build

Organization
Yakoub-ai
phaser-build

This skill should be used when the user asks to "build my game", "run my Phaser game", "start dev server", "deploy my game", "fix build errors", "configure Vite for Phaser", "game won't build", "TypeScript errors in Phaser", "publish to itch.io", or needs to compile, run, troubleshoot, or deploy a Phaser 4 project.

Overview

PublisherYakoub-ai
Repositoryphaser4-gamedev
Skill namephaser-build
Stars
29
Forks
3
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Yakoub-ai on GitHub. Read the source before you install it.

Installation

Install the Phaser Build AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Yakoub-ai/phaser4-gamedev/tree/main/skills/phaser-build
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Yakoub-ai/phaser4-gamedev.git /tmp/phaser4-gamedev
mkdir -p .claude/skills
cp -r /tmp/phaser4-gamedev/skills/phaser-build .claude/skills/phaser-build
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Phaser Build in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Phaser Build on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Phaser Build is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Phaser 4 Build and Deployment

Development Server

Start the dev server with hot reload:

bash
npm run dev

Opens at http://localhost:5173 (Vite default). Changes auto-reload in the browser.

Production Build

bash
npm run build     # Compiles TypeScript + bundles with Vite → dist/
npm run preview   # Serve the dist/ folder locally to test production build

Output in dist/ — static files ready for any web host.

Diagnose the Project

Run the validation script before building:

bash
bash scripts/validate-project.sh

The script checks for common issues automatically.

TypeScript Type Checking

bash
npx tsc --noEmit

Fix all type errors before shipping. Common Phaser 4 TypeScript issues:

Missing Phaser types:

json
// tsconfig.json — Phaser 4 resolves its own types via its exports map
{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "bundler",
    "skipLibCheck": true
  }
}

Then import it explicitly in each file: import Phaser from 'phaser';

If you see TS2688: Cannot find type definition file for 'Phaser', the project is carrying the v3-era typeRoots + types: ["Phaser"] pair. Delete both keys — Phaser 4 ships a single types/phaser.d.ts, which is not a valid type-root package.

this.input.keyboard nullable:

typescript
// Wrong:
const cursors = this.input.keyboard.createCursorKeys();
// Correct:
const cursors = this.input.keyboard!.createCursorKeys();

sprite.body nullable:

typescript
// Wrong:
sprite.body.velocity.x
// Correct:
(sprite.body as Phaser.Physics.Arcade.Body).velocity.x
// Or:
sprite.body?.velocity.x

this.scene.get() returns base Scene type:

typescript
// Cast to specific scene class:
const game = this.scene.get('GameScene') as GameScene;

Common Build Errors

"Cannot find module 'phaser'"

bash
npm install phaser   # installs Phaser 4 (latest stable). Do NOT use phaser — that tag still points at 4.2.1

Asset 404 Errors (game loads but assets missing)

In Vite, assets must be in the public/ directory. They are served as-is at the root.

✅ public/assets/images/sky.png  → loads as 'assets/images/sky.png'
❌ src/assets/images/sky.png     → won't work with this.load.image()

Never import assets via ES imports for Phaser. Just reference the path string:

typescript
this.load.image('sky', 'assets/images/sky.png');  // ✅

"Phaser.Geom.Point is not a constructor"

v3 → v4 breaking change. Replace with Vector2:

typescript
// Old (v3):
const pt = new Phaser.Geom.Point(x, y);
// New (v4):
const pt = new Phaser.Math.Vector2(x, y);

"Math.PI2 is undefined"

v3 → v4 breaking change:

typescript
// Old (v3):
const angle = Math.PI2;        // was π (wrong!) in v3
// New (v4):
const angle = Math.TAU;        // π×2
const half = Math.PI_OVER_2;   // π/2

Black Screen on Launch

  1. Check browser console for errors (F12)
  2. Check for 404s in Network tab (missing assets)
  3. Verify scene is in GameConfig's scene: [] array
  4. Verify HTML has <div id="game-container"> if using parent: 'game-container'
  5. Try removing parent config to append to document.body directly

WebGL Context Lost

typescript
// Try Canvas renderer as fallback
const config = {
  type: Phaser.CANVAS,   // instead of Phaser.AUTO or Phaser.WEBGL
  // ...
};

Or add WebGL context loss recovery listener:

typescript
this.game.renderer.on('contextlost', () => {
  console.warn('WebGL context lost — attempting recovery');
});

Vite Configuration

typescript
// vite.config.ts
import { defineConfig } from 'vite';

export default defineConfig({
  base: './',             // IMPORTANT for itch.io and subdirectory deployment
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    minify: 'terser',
    rollupOptions: {
      output: {
        manualChunks: {
          phaser: ['phaser'],  // Bundle Phaser separately for caching
        },
      },
    },
  },
  server: {
    port: 5173,
  },
});

base: './' is critical for itch.io, GitHub Pages, and any subdirectory deployment. Without it, assets load from / (root) which breaks on subdirectory hosts.

Deployment Targets

This section covers the mechanics of getting a build onto a host. For deciding whether the game is ready — the readiness gate, versioning, store presence, launch day — see skills/phaser-release/.

itch.io

  1. npm run build
  2. Zip the dist/ folder contents (not the folder itself — zip what's inside)
  3. Upload the zip to itch.io → "Upload files" → HTML game
  4. Set "This file will be played in the browser"
  5. Check "SharedArrayBuffer support" if needed

GitHub Pages

yaml
# .github/workflows/deploy.yml
name: Deploy to GitHub Pages
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with: { node-version: '18' }
      - run: npm ci
      - run: npm run build
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./dist

Set base: '/repo-name/' in vite.config.ts for GitHub Pages (subdirectory).

Netlify / Vercel

Connect the git repo. Set:

  • Build command: npm run build
  • Output directory: dist

Both auto-deploy on push to main.

Capacitor (iOS/Android)

bash
npm install @capacitor/core @capacitor/cli @capacitor/ios @capacitor/android
npx cap init
npx cap add ios
npx cap add android
npm run build
npx cap sync
npx cap open ios    # Opens Xcode
npx cap open android  # Opens Android Studio

Performance Checklist Before Shipping

  • arcade: { debug: false } in GameConfig
  • Assets in texture atlases (not individual images)
  • Audio compressed (128kbps MP3 for BGM, 96kbps for SFX)
  • Object pooling for bullets/particles/enemies
  • maxParticles set on all particle emitters
  • npx tsc --noEmit passes with 0 errors
  • Tested in Chrome, Firefox, and Safari
  • Mobile tested (if targeting mobile)

For a detailed performance playbook (measurement-first prompting, per-frame allocation elimination, spatial grid, audio lazy-load, atlas packing, tween leak fixes), see skills/phaser-analyze/references/performance-playbook.md. Use /phaser-analyze for a full project audit before shipping if FPS is a concern.

Scripts

Run the project validator:

bash
bash scripts/validate-project.sh

The validator checks: Phaser version, tsconfig fields, presence of scene files, deprecated v3 API usage.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Phaser Build AI skill do?

This skill should be used when the user asks to "build my game", "run my Phaser game", "start dev server", "deploy my game", "fix build errors", "configure Vite for Phaser", "game won't build", "TypeScript errors in Phaser", "publish to itch.io", or needs to compile, run, troubleshoot, or deploy a Phaser 4 project.

Why use Phaser Build on TypingMind?

Because you install it once and use it with any model. Phaser Build is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Phaser Build in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Yakoub-ai/phaser4-gamedev/tree/main/skills/phaser-build. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Phaser Build?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Phaser Build?

As many as you like. As long as a model supports skills, you can use Phaser Build with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Phaser Build AI skill free?

It is published on GitHub by Yakoub-ai. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇