[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79NA52PQ14HEFXTTHH5SPAA":3,"skill-same:01M79NA52PQ14HEFXTTHH5SPAA":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":5,"forksCount":14,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M79NA52PQ14HEFXTTHH5SPAA","save-systems",null,"Design save\u002Fload 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\u002Fload, game state persistence, save slots, autosave, save file corruption, or migrating old saves to a new version.","mistervaibhav\u002Fskills","mistervaibhav","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F41189028?v=4","01M79KACH05EG9FMM6DQVHAVK9","Vaibhav Singh","01M79KACJB3431Y8CFJQ02MTTM",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fsave-systems\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: save-systems\ndescription: >\n  Design save\u002Fload for game state — choosing what to serialize, file formats,\n  save slots, atomic crash-safe writes, schema versioning and migration, and\n  autosave. Engine-neutral. Use when the user mentions save system, save\u002Fload,\n  game state persistence, save slots, autosave, save file corruption, or\n  migrating old saves to a new version.\nlicense: Apache-2.0\ncompatibility: Engine-agnostic. Snippets in GDScript-like \u002F Python pseudocode; pairs with Godot FileAccess\u002FResourceSaver, Unity serialization, or roblox-datastores.\nmetadata:\n  engine: none\n  category: disciplines\n  difficulty: intermediate\n---\n\n# Save systems\n\nA save file is a **serialized snapshot of game state** that survives restarts.\nThe hard parts aren't writing bytes — they're choosing *what* to save, writing it\nso a crash mid-save can't corrupt it, and reading *old* saves after you ship a\npatch. Get those three right and the rest is plumbing.\n\n## When to use\n\n- Use to persist progress: player stats, inventory, world flags, settings,\n  positions — across sessions and game updates.\n- Use to design save slots, quicksave\u002Fautosave, and crash-safe writes.\n- Use when old save files break after a content\u002Fcode change (versioning &\n  migration).\n\n**When *not* to use:** for Roblox cloud persistence specifics, use\n`roblox-datastores`. For the data model the save serializes (resources\u002FSOs), use\n`godot-resources` \u002F `unity-scriptableobjects`. For Godot's `FileAccess`\u002F\n`ResourceSaver` and `user:\u002F\u002F` paths, defer to the Godot engine skill while\napplying the patterns here.\n\n## Core workflow\n\n1. **Decide what state is authoritative.** Save the *data* (hp, position, seed,\n   unlocked flags), not engine objects or scene nodes. You will reconstruct\n   objects from data on load — never serialize live node references.\n2. **Define a versioned schema.** Every save embeds a `version` integer. This is\n   the single most important field for a game you intend to patch.\n3. **Pick a format.** JSON\u002Ftext for readability and debuggability; a binary\n   format for size\u002Fspeed or mild tamper-resistance. Start with JSON.\n4. **Write atomically.** Serialize to a temp file, flush, then rename over the\n   real file. A crash leaves either the old save or the new one — never a\n   half-written one.\n5. **Load defensively.** Read version → migrate up to current → validate →\n   instantiate. Keep a backup of the last good save and fall back on parse error.\n6. **Autosave on safe boundaries** (level change, checkpoint), throttled, and to a\n   separate slot so it can't clobber a manual save.\n7. **Verify**: save, fully quit, relaunch, load — and confirm by inspection that\n   state matches. Test loading a save from the previous version.\n\n## Patterns\n\n### 1. Serialize state as plain data (not engine objects)\n\n```gdscript\n# Build a dictionary of pure data. Each savable object reports its own state.\nfunc capture_state() -> Dictionary:\n    return {\n        \"version\": SAVE_VERSION,                 # ALWAYS stamp the schema version\n        \"player\": { \"hp\": player.hp, \"pos\": [player.position.x, player.position.y] },\n        \"inventory\": player.inventory.to_array(),  # ids + counts, not Item nodes\n        \"flags\": world.flags,                    # e.g. {\"met_guard\": true}\n        \"seed\": world.seed,                      # regenerate procedural content\n    }\n\n# On load, RECONSTRUCT objects from the data — do not expect live references back.\nfunc apply_state(data: Dictionary) -> void:\n    player.hp = data[\"player\"][\"hp\"]\n    player.position = Vector2(data[\"player\"][\"pos\"][0], data[\"player\"][\"pos\"][1])\n    player.inventory.from_array(data[\"inventory\"])\n    world.flags = data[\"flags\"]\n```\n\n### 2. Atomic, crash-safe write (temp + rename)\n\n```gdscript\n# RIGHT: write to a temp file, then atomically rename over the target.\nfunc save_atomic(path: String, data: Dictionary) -> void:\n    var tmp := path + \".tmp\"\n    var f := FileAccess.open(tmp, FileAccess.WRITE)\n    f.store_string(JSON.stringify(data))\n    f.flush()                                    # ensure bytes hit disk\n    f.close()\n    DirAccess.rename_absolute(tmp, path)         # replaces the target; atomic on POSIX\n# WRONG: opening `path` directly and writing in place — a crash mid-write leaves a\n# truncated, unloadable save and destroys the player's progress.\n```\n\nRename-over-target is atomic on POSIX (same volume); on Windows a replace-by-rename\nisn't guaranteed atomic, so keep the previous file as `path + \".bak\"` before the\nrename — that backup is what actually guarantees you can recover from a bad write.\n\n### 3. Versioned load with migration\n\n```python\nSAVE_VERSION = 3\n\ndef load_save(raw_bytes):\n    data = parse(raw_bytes)                  # JSON\u002Fbinary -> dict\n    v = data.get(\"version\", 0)\n    if v > SAVE_VERSION:\n        raise NewerSaveError(v)              # save is from a newer build; refuse\n    while v \u003C SAVE_VERSION:                   # apply migrations in order, v -> v+1\n        data = MIGRATIONS[v](data)\n        v += 1\n        data[\"version\"] = v\n    validate(data)                            # check required keys \u002F ranges\n    return data\n\n# Each migration is a pure function from one version's shape to the next.\ndef migrate_1_to_2(d):\n    d[\"flags\"] = {k: True for k in d.pop(\"completed_quests\", [])}  # list -> set-map\n    return d\nMIGRATIONS = {1: migrate_1_to_2, 2: migrate_2_to_3}\n```\n\n### 4. Save slots + throttled autosave\n\n```gdscript\nconst SLOT_PATH := \"user:\u002F\u002Fsave_%d.json\"      # manual slots 0..N\nconst AUTOSAVE_PATH := \"user:\u002F\u002Fautosave.json\"  # separate file: never clobbers a slot\nvar _autosave_cooldown := 0.0\n\nfunc autosave_if_due(dt: float) -> void:\n    _autosave_cooldown -= dt\n    if _autosave_cooldown \u003C= 0.0:\n        save_atomic(AUTOSAVE_PATH, capture_state())\n        _autosave_cooldown = 60.0             # throttle: at most once a minute\n# Trigger an immediate autosave on checkpoints\u002Flevel transitions, not mid-combat.\n```\n\n## Pitfalls\n\n- **Serializing engine objects\u002Fnode paths** ties saves to scene structure;\n  renaming a node breaks every old save. Save data, rebuild objects on load.\n- **No version field.** The day you ship a patch, every existing save is a\n  guessing game. Stamp `version` from version 1.\n- **In-place writes** corrupt saves on crash\u002Fpower loss. Always temp-write then\n  rename; keep a `.bak`.\n- **Trusting the file blindly.** Saves get truncated, hand-edited, or\n  cloud-synced stale. Validate on load and fall back to backup on failure.\n- **Floats and locale.** Text serializers can drop precision or use comma\n  decimal separators in some locales. Use a locale-invariant serializer.\n- **Autosave clobbering manual saves**, or firing mid-action and saving an\n  inconsistent state. Use a dedicated autosave slot and save on safe boundaries.\n- **Storing secrets or trusting client saves in multiplayer.** A local save is\n  player-controlled; never treat it as authoritative for online state. For cloud,\n  handle the device's data limits and conflicts (`roblox-datastores`).\n\n## References\n\n- `references\u002Fversioning-and-migration.md` — schema evolution strategies, the\n  migration chain, backups\u002Frollback, format trade-offs (JSON vs binary), and a\n  load-time validation checklist.\n\n## Related skills\n\n- `roblox-datastores` — cloud persistence, request limits, session locking.\n- `godot-resources`, `unity-scriptableobjects` — the data model you serialize.\n- `procedural-gen` — store the seed to regenerate worlds instead of saving them.\n- `rpg`, `survival-crafting`, `visual-novel` — genres that compose this skill.\n","# Save systems\n\nA save file is a **serialized snapshot of game state** that survives restarts.\nThe hard parts aren't writing bytes — they're choosing *what* to save, writing it\nso a crash mid-save can't corrupt it, and reading *old* saves after you ship a\npatch. Get those three right and the rest is plumbing.\n\n## When to use\n\n- Use to persist progress: player stats, inventory, world flags, settings,\n  positions — across sessions and game updates.\n- Use to design save slots, quicksave\u002Fautosave, and crash-safe writes.\n- Use when old save files break after a content\u002Fcode change (versioning &\n  migration).\n\n**When *not* to use:** for Roblox cloud persistence specifics, use\n`roblox-datastores`. For the data model the save serializes (resources\u002FSOs), use\n`godot-resources` \u002F `unity-scriptableobjects`. For Godot's `FileAccess`\u002F\n`ResourceSaver` and `user:\u002F\u002F` paths, defer to the Godot engine skill while\napplying the patterns here.\n\n## Core workflow\n\n1. **Decide what state is authoritative.** Save the *data* (hp, position, seed,\n   unlocked flags), not engine objects or scene nodes. You will reconstruct\n   objects from data on load — never serialize live node references.\n2. **Define a versioned schema.** Every save embeds a `version` integer. This is\n   the single most important field for a game you intend to patch.\n3. **Pick a format.** JSON\u002Ftext for readability and debuggability; a binary\n   format for size\u002Fspeed or mild tamper-resistance. Start with JSON.\n4. **Write atomically.** Serialize to a temp file, flush, then rename over the\n   real file. A crash leaves either the old save or the new one — never a\n   half-written one.\n5. **Load defensively.** Read version → migrate up to current → validate →\n   instantiate. Keep a backup of the last good save and fall back on parse error.\n6. **Autosave on safe boundaries** (level change, checkpoint), throttled, and to a\n   separate slot so it can't clobber a manual save.\n7. **Verify**: save, fully quit, relaunch, load — and confirm by inspection that\n   state matches. Test loading a save from the previous version.\n\n## Patterns\n\n### 1. Serialize state as plain data (not engine objects)\n\n```gdscript\n# Build a dictionary of pure data. Each savable object reports its own state.\nfunc capture_state() -> Dictionary:\n    return {\n        \"version\": SAVE_VERSION,                 # ALWAYS stamp the schema version\n        \"player\": { \"hp\": player.hp, \"pos\": [player.position.x, player.position.y] },\n        \"inventory\": player.inventory.to_array(),  # ids + counts, not Item nodes\n        \"flags\": world.flags,                    # e.g. {\"met_guard\": true}\n        \"seed\": world.seed,                      # regenerate procedural content\n    }\n\n# On load, RECONSTRUCT objects from the data — do not expect live references back.\nfunc apply_state(data: Dictionary) -> void:\n    player.hp = data[\"player\"][\"hp\"]\n    player.position = Vector2(data[\"player\"][\"pos\"][0], data[\"player\"][\"pos\"][1])\n    player.inventory.from_array(data[\"inventory\"])\n    world.flags = data[\"flags\"]\n```\n\n### 2. Atomic, crash-safe write (temp + rename)\n\n```gdscript\n# RIGHT: write to a temp file, then atomically rename over the target.\nfunc save_atomic(path: String, data: Dictionary) -> void:\n    var tmp := path + \".tmp\"\n    var f := FileAccess.open(tmp, FileAccess.WRITE)\n    f.store_string(JSON.stringify(data))\n    f.flush()                                    # ensure bytes hit disk\n    f.close()\n    DirAccess.rename_absolute(tmp, path)         # replaces the target; atomic on POSIX\n# WRONG: opening `path` directly and writing in place — a crash mid-write leaves a\n# truncated, unloadable save and destroys the player's progress.\n```\n\nRename-over-target is atomic on POSIX (same volume); on Windows a replace-by-rename\nisn't guaranteed atomic, so keep the previous file as `path + \".bak\"` before the\nrename — that backup is what actually guarantees you can recover from a bad write.\n\n### 3. Versioned load with migration\n\n```python\nSAVE_VERSION = 3\n\ndef load_save(raw_bytes):\n    data = parse(raw_bytes)                  # JSON\u002Fbinary -> dict\n    v = data.get(\"version\", 0)\n    if v > SAVE_VERSION:\n        raise NewerSaveError(v)              # save is from a newer build; refuse\n    while v \u003C SAVE_VERSION:                   # apply migrations in order, v -> v+1\n        data = MIGRATIONS[v](data)\n        v += 1\n        data[\"version\"] = v\n    validate(data)                            # check required keys \u002F ranges\n    return data\n\n# Each migration is a pure function from one version's shape to the next.\ndef migrate_1_to_2(d):\n    d[\"flags\"] = {k: True for k in d.pop(\"completed_quests\", [])}  # list -> set-map\n    return d\nMIGRATIONS = {1: migrate_1_to_2, 2: migrate_2_to_3}\n```\n\n### 4. Save slots + throttled autosave\n\n```gdscript\nconst SLOT_PATH := \"user:\u002F\u002Fsave_%d.json\"      # manual slots 0..N\nconst AUTOSAVE_PATH := \"user:\u002F\u002Fautosave.json\"  # separate file: never clobbers a slot\nvar _autosave_cooldown := 0.0\n\nfunc autosave_if_due(dt: float) -> void:\n    _autosave_cooldown -= dt\n    if _autosave_cooldown \u003C= 0.0:\n        save_atomic(AUTOSAVE_PATH, capture_state())\n        _autosave_cooldown = 60.0             # throttle: at most once a minute\n# Trigger an immediate autosave on checkpoints\u002Flevel transitions, not mid-combat.\n```\n\n## Pitfalls\n\n- **Serializing engine objects\u002Fnode paths** ties saves to scene structure;\n  renaming a node breaks every old save. Save data, rebuild objects on load.\n- **No version field.** The day you ship a patch, every existing save is a\n  guessing game. Stamp `version` from version 1.\n- **In-place writes** corrupt saves on crash\u002Fpower loss. Always temp-write then\n  rename; keep a `.bak`.\n- **Trusting the file blindly.** Saves get truncated, hand-edited, or\n  cloud-synced stale. Validate on load and fall back to backup on failure.\n- **Floats and locale.** Text serializers can drop precision or use comma\n  decimal separators in some locales. Use a locale-invariant serializer.\n- **Autosave clobbering manual saves**, or firing mid-action and saving an\n  inconsistent state. Use a dedicated autosave slot and save on safe boundaries.\n- **Storing secrets or trusting client saves in multiplayer.** A local save is\n  player-controlled; never treat it as authoritative for online state. For cloud,\n  handle the device's data limits and conflicts (`roblox-datastores`).\n\n## References\n\n- `references\u002Fversioning-and-migration.md` — schema evolution strategies, the\n  migration chain, backups\u002Frollback, format trade-offs (JSON vs binary), and a\n  load-time validation checklist.\n\n## Related skills\n\n- `roblox-datastores` — cloud persistence, request limits, session locking.\n- `godot-resources`, `unity-scriptableobjects` — the data model you serialize.\n- `procedural-gen` — store the seed to regenerate worlds instead of saving them.\n- `rpg`, `survival-crafting`, `visual-novel` — genres that compose this skill.\n",{"name":5,"license":15,"metadata":24,"description":28,"compatibility":29},{"engine":25,"category":26,"difficulty":27},"none","disciplines","intermediate","Design save\u002Fload 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\u002Fload, game state persistence, save slots, autosave, save file corruption, or migrating old saves to a new version.\n","Engine-agnostic. Snippets in GDScript-like \u002F Python pseudocode; pairs with Godot FileAccess\u002FResourceSaver, Unity serialization, or roblox-datastores.","main","6d4e3296d58b2720c5b1026197cd069b1dde4789","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills","https:\u002F\u002Fgithub.com\u002Fmistervaibhav","Software Engineer","2026-07-24 17:16:42",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add mistervaibhav\u002Fskills --skill save-systems",{"tool":42,"command":43},"bunx","bunx skills add mistervaibhav\u002Fskills --skill save-systems",{"tool":45,"command":46},"pnpm","pnpm dlx skills add mistervaibhav\u002Fskills --skill save-systems","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fsave-systems\u002FSKILL.md",true,[50],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Fversioning-and-migration.md","REFERENCE","参考文档",4068,"https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fsave-systems\u002Freferences\u002Fversioning-and-migration.md",[57,65,73,81,88,95],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":61,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M79NZDV5781GA6SJMN1QPXB4","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M79NZ8SEVWT4WYD49BV980YW","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", or \"type hierarchy\". Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","MIT","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M79NYVQS5NYHH36NXF2AHP8B","web-haptics","Add haptic feedback to web apps using the web-haptics library. Use when building mobile-facing UIs that need tactile feedback on buttons, toggles, forms, pickers, and other interactive elements.","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fweb-haptics\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fweb-haptics\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M79NY8AMC62DDRSH21WKXJVE","visual-novel","Build a visual novel: a branching script, character and background display, a text box with choices, save\u002Fload, backlog, and skip\u002Fauto. Use for a VN, dating sim, or branching story game.","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fvisual-novel\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":69,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M79NWFM5R9QC9Y2AT40EHF44","ux-heuristics","Evaluate and improve interface usability using heuristic analysis. Use when the user mentions \"usability audit\", \"UX review\", \"users are confused\", \"heuristic evaluation\", \"form usability\", or \"navigation problems\". Covers Nielsen's 10 heuristics, severity ratings, and information architecture. For visual design fixes, see refactoring-ui. For conversion-focused audits, see cro-methodology.","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Fux-heuristics\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M79NVSG7AB3MSFT8Y6EEHG1B","unreal-packaging","Package and ship an Unreal Engine 5 project: the Platforms menu Package Project flow, build configurations (Development vs Shipping), cooking content, packaging settings and the Game Default Map, and command-line builds with RunUAT BuildCookRun. Use when packaging a build, making a shipping build, cooking content, configuring packaging settings, or when the user mentions package Unreal, cook content, shipping build, or BuildCookRun.","https:\u002F\u002Fgithub.com\u002Fmistervaibhav\u002Fskills\u002Fblob\u002Fmain\u002Funreal-packaging\u002FSKILL.md",[],[]]