Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Design save/load for game state — choosing what to serialize, file formats, save slots, atomic crash-safe writes, schema versioning and migration, and autosave. Engine-neutral. Use when the user mentions save system, save/load, game state persistence, save slots, autosave, save file corruption, or migrating old saves to a new version.
.claude/skills/gamedev-skills-save-systems/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 99% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 24% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 95% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 18% | 0% |
A save file is a serialized snapshot of game state that survives restarts. The hard parts aren't writing bytes — they're choosing what to save, writing it so a crash mid-save can't corrupt it, and reading old saves after you ship a patch. Get those three right and the rest is plumbing.
positions — across sessions and game updates.
migration).
When not to use: for Roblox cloud persistence specifics, use roblox-datastores. For the data model the save serializes (resources/SOs), use godot-resources / unity-scriptableobjects. For Godot's FileAccess/ ResourceSaver and user:// paths, defer to the Godot engine skill while applying the patterns here.
unlocked flags), not engine objects or scene nodes. You will reconstruct objects from data on load — never serialize live node references.
version integer. This isthe single most important field for a game you intend to patch.
format for size/speed or mild tamper-resistance. Start with JSON.
real file. A crash leaves either the old save or the new one — never a half-written one.
instantiate. Keep a backup of the last good save and fall back on parse error.
separate slot so it can't clobber a manual save.
state matches. Test loading a save from the previous version.
gdscript# Build a dictionary of pure data. Each savable object reports its own state. func capture_state() -> Dictionary: return { "version": SAVE_VERSION, # ALWAYS stamp the schema version "player": { "hp": player.hp, "pos": [player.position.x, player.position.y] }, "inventory": player.inventory.to_array(), # ids + counts, not Item nodes "flags": world.flags, # e.g. {"met_guard": true} "seed": world.seed, # regenerate procedural content } # On load, RECONSTRUCT objects from the data — do not expect live references back. func apply_state(data: Dictionary) -> void: player.hp = data["player"]["hp"] player.position = Vector2(data["player"]["pos"][0], data["player"]["pos"][1]) player.inventory.from_array(data["inventory"]) world.flags = data["flags"]
gdscript# RIGHT: write to a temp file, then atomically rename over the target. func save_atomic(path: String, data: Dictionary) -> void: var tmp := path + ".tmp" var f := FileAccess.open(tmp, FileAccess.WRITE) f.store_string(JSON.stringify(data)) f.flush() # ensure bytes hit disk f.close() DirAccess.rename_absolute(tmp, path) # replaces the target; atomic on POSIX # WRONG: opening `path` directly and writing in place — a crash mid-write leaves a # truncated, unloadable save and destroys the player's progress.
Rename-over-target is atomic on POSIX (same volume); on Windows a replace-by-rename isn't guaranteed atomic, so keep the previous file as path + ".bak" before the rename — that backup is what actually guarantees you can recover from a bad write.
pythonSAVE_VERSION = 3 def load_save(raw_bytes): data = parse(raw_bytes) # JSON/binary -> dict v = data.get("version", 0) if v > SAVE_VERSION: raise NewerSaveError(v) # save is from a newer build; refuse while v < SAVE_VERSION: # apply migrations in order, v -> v+1 data = MIGRATIONS[v](data) v += 1 data["version"] = v validate(data) # check required keys / ranges return data # Each migration is a pure function from one version's shape to the next. def migrate_1_to_2(d): d["flags"] = {k: True for k in d.pop("completed_quests", [])} # list -> set-map return d MIGRATIONS = {1: migrate_1_to_2, 2: migrate_2_to_3}
gdscriptconst SLOT_PATH := "user://save_%d.json" # manual slots 0..N const AUTOSAVE_PATH := "user://autosave.json" # separate file: never clobbers a slot var _autosave_cooldown := 0.0 func autosave_if_due(dt: float) -> void: _autosave_cooldown -= dt if _autosave_cooldown <= 0.0: save_atomic(AUTOSAVE_PATH, capture_state()) _autosave_cooldown = 60.0 # throttle: at most once a minute # Trigger an immediate autosave on checkpoints/level transitions, not mid-combat.
renaming a node breaks every old save. Save data, rebuild objects on load.
guessing game. Stamp version from version 1.
rename; keep a .bak.
cloud-synced stale. Validate on load and fall back to backup on failure.
decimal separators in some locales. Use a locale-invariant serializer.
inconsistent state. Use a dedicated autosave slot and save on safe boundaries.
player-controlled; never treat it as authoritative for online state. For cloud, handle the device's data limits and conflicts (roblox-datastores).
references/versioning-and-migration.md — schema evolution strategies, themigration chain, backups/rollback, format trade-offs (JSON vs binary), and a load-time validation checklist.
roblox-datastores — cloud persistence, request limits, session locking.godot-resources, unity-scriptableobjects — the data model you serialize.procedural-gen — store the seed to regenerate worlds instead of saving them.rpg, survival-crafting, visual-novel — genres that compose this skill.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 17,080 | 18,944 | +11% | 1 | 1 | 0% | 3,456 | 5,967 | +73% | 0 | 0 | — |
case-02 | pass→pass | 20,189 | 16,085 | -20% | 1 | 1 | 0% | 3,918 | 4,877 | +24% | 0 | 0 | — |
case-03 | pass→pass | 9,069 | 9,739 | +7% | 1 | 1 | 0% | 1,891 | 3,687 | +95% | 0 | 0 | — |
case-04 | pass→pass | 17,597 | 10,730 | -39% | 1 | 1 | 0% | 3,205 | 3,786 | +18% | 0 | 0 | — |
case-05 | pass→pass | 14,220 | 7,510 | -47% | 1 | 1 | 0% | 3,059 | 3,292 | +8% | 0 | 0 | — |
case-17 | pass→pass | 13,212 | 13,534 | +2% | 1 | 1 | 0% | 2,275 | 3,915 | +72% | 0 | 0 | — |
case-16 | pass→pass | 18,753 | 15,508 | -17% | 1 | 1 | 0% | 3,264 | 4,417 | +35% | 0 | 0 | — |
case-06 | pass→pass | 14,322 | 11,695 | -18% | 1 | 1 | 0% | 2,425 | 3,741 | +54% | 0 | 0 | — |
case-07 | pass→pass | 12,696 | 13,468 | +6% | 1 | 1 | 0% | 2,617 | 4,738 | +81% | 0 | 0 | — |
case-08 | pass→pass | 15,208 | 9,875 | -35% | 1 | 1 | 0% | 2,922 | 3,723 | +27% | 0 | 0 | — |
case-09 | pass→pass | 11,735 | 7,757 | -34% | 1 | 1 | 0% | 2,273 | 3,363 | +48% | 0 | 0 | — |
case-10 | pass→pass | 13,646 | 14,395 | +5% | 1 | 1 | 0% | 2,736 | 4,096 | +50% | 0 | 0 | — |
case-11 | pass→pass | 15,766 | 11,099 | -30% | 1 | 1 | 0% | 2,828 | 3,812 | +35% | 0 | 0 | — |
case-12 | pass→pass | 14,462 | 10,459 | -28% | 1 | 1 | 0% | 2,048 | 3,540 | +73% | 0 | 0 | — |
case-13 | pass→pass | 16,979 | 12,262 | -28% | 1 | 1 | 0% | 3,226 | 4,481 | +39% | 0 | 0 | — |
case-14 | pass→pass | 12,720 | 10,925 | -14% | 1 | 1 | 0% | 2,242 | 3,526 | +57% | 0 | 0 | — |
case-15 | pass→pass | 16,427 | 10,571 | -36% | 1 | 1 | 0% | 2,802 | 3,509 | +25% | 0 | 0 | — |
case-18 | pass→pass | 16,761 | 12,698 | -24% | 1 | 1 | 0% | 2,771 | 3,712 | +34% | 0 | 0 | — |
case-19 | pass→pass | 11,201 | 6,964 | -38% | 1 | 1 | 0% | 2,044 | 3,070 | +50% | 0 | 0 | — |
case-20 | pass→pass | 12,317 | 5,387 | -56% | 1 | 1 | 0% | 2,187 | 2,702 | +24% | 0 | 0 | — |
case-21 | pass→pass | 5,826 | 6,789 | +17% | 1 | 1 | 0% | 1,197 | 3,001 | +151% | 0 | 0 | — |
case-22 | fail→pass | 7,482 | 4,233 | -43% | 1 | 1 | 0% | 1,302 | 2,595 | +99% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.