LLM Integration Guide

How to get ChatGPT, Claude, Gemini, and other AI to generate valid .raku games every time

Two Formats, One Engine

The Raku engine supports two .raku file formats. Pick the one that matches your needs.

Standard Format

Recommended

Declarative config — describe what you want, the engine figures out how.

Version key: "schema_version": "1.0"

Top-level: game, ai, entities, scenes, rendering, audio, xr, ai_disclosure

Schema: rakuai.com/schema.json

Examples: All standard samples →

Best for: quick game creation, beginners, most LLM tasks

Runtime Format

Advanced

Explicit API call sequences — every engine function call is specified in order.

Version key: "raku_format": "1.0.0"

Top-level: metadata, assets, initialization, setup, game_loop, ai_pipeline, shutdown

Reference: Runtime format reference card →

Example: void-wyrm.raku (290 lines) →

Best for: complex games, custom behavior trees, granular AI pipeline control

The rest of this page covers the Standard Format. For the runtime format, see the LLM Runtime Reference Card on GitHub.

The Problem

LLMs will hallucinate a schema if you don't give them the real one. They'll invent fields like settings, gameplay, controls, and analytics that don't exist in the Raku spec. The file will look like valid JSON, but it won't run.

What happens without the schema

We tested this: we asked ChatGPT to "create a .raku game file for a zombie survival game." It generated 150 lines of valid JSON with a completely made-up structure. The validator caught 2 errors and 2 warnings including wrong version format ("1.0.0" instead of "1.0"), missing game object, 6 hallucinated fields, and wrong ai_disclosure format.

The fix is simple

Always point the AI at the schema URL: https://rakuai.com/schema.json. When LLMs can read the actual spec, they generate valid files on the first try. Always validate with the validator tool before playing.

Copy-Paste Prompts

Use these tested prompts in any AI assistant. They include the schema URL so the AI reads the real spec.

Basic Prompt (any game)

Using the Raku game engine schema at https://rakuai.com/schema.json — read that schema first, then create a .raku game file for: [describe your game here]. Include the ai_disclosure section. Output only the raw JSON, no markdown code fences.

Detailed Prompt (survival game example)

Using the Raku game engine schema at https://rakuai.com/schema.json — read that schema first, then create a .raku game file for: A zombie survival game with day/night cycles, crafting, and base building. Zombies should get more aggressive at night. The AI should track emotional state and back off if the player is frustrated. Use the "survival" template and genre. Include the ai_disclosure section with appropriate systems. Output only the raw JSON, no markdown code fences.

Strict Prompt (for stubborn LLMs)

Read the JSON schema at https://rakuai.com/schema.json before generating anything. Create a .raku file for: [describe your game here].

RULES:
- schema_version must be "1.0" (not "1.0.0")
- Top-level must have: schema_version, game, ai, entities, scenes, rendering, audio, xr, ai_disclosure
- The "game" object must contain: title, genre, template
- Do NOT invent fields like settings, gameplay, controls, ui, analytics, assets, or levels
- ai_disclosure must have: live_generated, pre_generated, description, systems
- Output raw JSON only, no markdown fences, no explanation

Iteration Prompt (fix a bad file)

The .raku file you generated has validation errors. Read the correct schema at https://rakuai.com/schema.json and fix these issues:

[paste your validator output here]

Output only the corrected raw JSON, no markdown code fences.

Step-by-Step Workflow

1. Generate with AI

Copy one of the prompts above into ChatGPT, Claude, Gemini, or any LLM. Fill in your game description. The AI will output JSON.

2. Save as .raku file

Save the JSON output as a .raku file. Important: save as UTF-8 without BOM. If using Windows Notepad, choose "Save As" → Encoding: "UTF-8" (not "UTF-8 with BOM"). If the AI wrapped it in ```json fences, remove those lines first.

3. Validate

Clone raku-public and run the validator:

# Validate your file
python tools/validate-raku.py my-game.raku

# Auto-fix common LLM mistakes (BOM, fences, wrong version)
python tools/validate-raku.py my-game.raku --fix

# Validate all files in a folder
python tools/validate-raku.py *.raku

4. Fix remaining errors

If the validator reports errors, copy the output back into the AI using the "Iteration Prompt" above. Or use --fix mode to auto-repair the most common issues.

5. Play

Once you see PASS - Valid .raku file, double-click the file to play. Download the runtime →

Platform-Specific Notes

ChatGPT

Accuracy: Good

GPT-4 and GPT-4o read the schema URL reliably. Watch out for: markdown code fences in output (strip ```json lines), and occasionally inventing extra fields. Always include "output only raw JSON" in your prompt.

Claude

Accuracy: Excellent

Claude Opus and Sonnet follow the schema precisely when given the URL. Supports MCP server integration for direct validation. Rarely adds markdown fences when told not to.

Gemini

Accuracy: Good

Gemini Pro reads schemas well. Best for iterative design across multi-turn conversations. May sometimes use "1.0.0" instead of "1.0" for schema_version.

GitHub Copilot

Accuracy: Good

Works well in VS Code with the schema as a reference file. Open schema.json in an adjacent tab and Copilot will use it for autocomplete in .raku files.

Troubleshooting

Common validator errors and how to fix them. Most can be auto-fixed with --fix.

Invalid JSON: Expecting value: line 1 column 1

The file is empty, has a BOM, or starts with markdown fences (```json).

Fix: Run python tools/validate-raku.py my-game.raku --fix to strip BOM and fences automatically.

Unsupported schema version: '1.0.0'. Expected '1.0'

LLMs love adding extra digits to version numbers.

Fix: Change "schema_version": "1.0.0" to "schema_version": "1.0". The --fix flag does this automatically.

Missing required field 'game'

The AI put title, genre, and template at the top level instead of inside a "game" object.

Fix: Wrap them in "game": { "title": "...", "genre": "...", "template": "..." }. The --fix flag does this automatically.

AI-hallucinated fields detected

The AI invented fields like settings, gameplay, controls, ui, analytics, assets, or levels.

Fix: Delete these fields. The only valid top-level fields are: schema_version, game, ai, entities, scenes, rendering, audio, xr, ai_disclosure. The --fix flag removes them automatically.

Wrong ai_disclosure format

The AI used fields like compliance, uses_player_data, data_tracked instead of the correct schema.

Fix: Replace the ai_disclosure section with: live_generated (bool), pre_generated (bool), description (string), systems (array). See the schema for valid system names.

File starts with UTF-8 BOM

Windows Notepad and PowerShell's Set-Content -Encoding UTF8 add invisible BOM bytes.

Fix: Use --fix or in PowerShell: [IO.File]::WriteAllText("$PWD\file.raku", (Get-Content file.raku -Raw), [Text.UTF8Encoding]::new($false))

Schema Quick Reference

The complete structure of a valid .raku file. Full schema →

{
  "schema_version": "1.0",
  "game": {
    "title": "string (1-128 chars)",
    "genre": "shooter|platformer|puzzle|rpg|racing|tower-defense|arena-combat|survival|music-rhythm|custom",
    "template": "space-shooter|tower-defense|puzzle|platformer|arena-combat|custom-advanced|racing|rpg-adventure|survival|music-rhythm",
    "description": "optional",
    "max_players": 1 // 1-16, multiplayer requires Pro
  },
  "ai": {
    "dda_enabled": true,
    "target_flow_state": 0.7, // 0.0-1.0
    "profiler_mode": "adaptive|fixed|learning",
    "emotional_tracking": true,
    "npc_personality": false
  },
  "entities": [
    { "type": "player", "health": 100, "speed": 1.0, "properties": { } }
  ],
  "scenes": [
    { "name": "Main Menu", "type": "menu" },
    { "name": "Gameplay", "type": "gameplay", "entities": ["player"] }
  ],
  "rendering": { "resolution": "auto", "fps_target": 60, "vrs_enabled": true },
  "audio": { "spatial_audio": true, "adaptive_music": true },
  "xr": { "openxr_enabled": false },
  "ai_disclosure": {
    "live_generated": true,
    "pre_generated": false,
    "description": "What AI does in your game",
    "systems": ["dda", "emotional-tracking"],
    "guardrails": "optional safety bounds"
  }
}

Browse 6 complete sample .raku files on GitHub →