agentleFS
wedabrowedabro/bro-skills/.agents/skills/speckit.game-embedded/SKILL.md

speckit.game-embedded

Skill3 starsChanged 3 months agoMITView on GitHub

Embedded Game & WASM Bridge Specialist - Unity WebGL, Godot 4 Web/WASM, PlayCanvas, 2-Way JS Bridge, COOP/COEP Headers, Brotli Streaming, and Shell UI Integration.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read .agents/specs/[feature]/spec.md, plan.md, tasks.md, target engine export artifacts, bridge event schemas, and platform SDK …

    line 10

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mission

Architect, optimize, and integrate embedded game engines (Unity WebGL, Godot 4 HTML5/WASM, PlayCanvas, Defold, or Iframe sandboxes) into modern Web Platforms (React, Next.js, Vue, Vanilla TS). Ensure seamless 2-way communication, optimal WASM loading performance, proper security headers for multi-threading, and responsive container scaling.

Inputs and Outputs

  • Read .agents/specs/[feature]/spec.md, plan.md, tasks.md, target engine export artifacts, bridge event schemas, and platform SDK specifications.
  • Produce typed bridge dispatcher (GameBridge.ts), responsive shell container component (GameContainer.tsx/vue), loading screen with lifecycle hooks, server headers (COOP/COEP, Brotli), and platform connectors.

Protocol

1. Two-Way Bridge Architecture (Web ⇋ Engine)

  • Type-Safe Dispatcher: Define strict TypeScript interfaces for all outbound actions and inbound events.
  • Web ➔ Engine (Call into Game):
    • Unity: Use unityInstance.SendMessage(gameObjectName, methodName, jsonPayload).
    • Godot: Use JavaScriptBridge.eval() or trigger registered callback handlers.
    • Iframe / Web Worker: Use window.postMessage with strict targetOrigin verification (never use * in production).
  • Engine ➔ Web (Game Events to Shell):
    • Unity: Implement C# .jslib plugins calling global bridge functions: window.dispatchGameEvent(eventName, data).
    • Godot: Use JavaScriptBridge.get_interface("window").dispatchGameEvent(eventName, data).
  • Validation: Validate all incoming event payloads using schemas (e.g. Zod) before updating Web state.

2. Web Shell & Responsive Container Management

  • Aspect Ratio Locking: Wrap game canvas in a responsive container with aspect-ratio preservation (16:9, 4:3, 9:16 for mobile vertical) using CSS Letterbox / Pillarbox.
  • Orientation & Fullscreen:
    • Implement Fullscreen API handler with fallback for iOS Safari.
    • Listen to ScreenOrientation change events; show rotate device overlay when orientation is incompatible.
  • Focus & Input Trapping:
    • Automatically manage Canvas focus/blur to capture keyboard game inputs (Arrow keys, Spacebar) while preventing unwanted page scrolling.
    • Release focus when user interacts with Web DOM overlays (modals, chat inputs).

3. Loading, Preloading & Asset Streaming

  • Granular Loading Screen: Parse engine loading lifecycle hooks:
    1. Engine Runtime Fetching (.wasm, .framework.js)
    2. Asset Data Downloading (.data, .pck)
    3. WASM Compilation & Instantiation
    4. Game Scene Ready
  • Persistent Caching: Configure Service Worker or IndexedDB caching for large WASM blobs and asset packages to enable instant subsequent loads and offline play.

4. Server & DevOps Infrastructure

  • SharedArrayBuffer & Multi-Threading (COOP / COEP): For Godot 4 / Unity multi-threaded builds, enforce HTTP response headers in Nginx/Caddy/Vite:
    Cross-Origin-Opener-Policy: same-origin
    Cross-Origin-Embedder-Policy: require-corp
  • Compression: Pre-compress build outputs (.wasm, .data, .pck) using Brotli (.br) and Gzip (.gz), serving with proper Content-Encoding and Content-Type: application/wasm.

5. Platform SDKs & Monetization Hooks

  • Platform Integrations:
    • Telegram Mini Apps: Integrate @twa-dev/sdk (BackButton, MainButton, CloudStorage, HapticFeedback).
    • Discord Activities: Integrate @discord/embedded-app-sdk.
  • Monetization & Ads: Implement interstitial / rewarded video ad lifecycle (pause game loop & audio during ad, resume on completion).

Completion Gate

Two-way bridge messages typed and validated, loading screen lifecycle verified with error fallback, COOP/COEP headers configured for multi-threaded WASM, and audio suspends on document visibility change.

Guard Rails

  • FORBIDDEN: Using postMessage('*') without origin validation.
  • FORBIDDEN: Hardcoding asset paths or API endpoints inside game exports (must be injected via bridge or ENV query params).
  • FORBIDDEN: Omitting COOP/COEP headers when the engine requires SharedArrayBuffer (causes silent black screens or crashes).
  • FORBIDDEN: Leaving audio playing in background when user navigates away or tab is hidden (document.hidden).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.