implement-save-persistence

Installation
SKILL.md

Implement Save Persistence

Architect and implement fault-tolerant game save and persistence systems with monotonic schema versioning, atomic disk writes, cryptographic integrity verification, and cross-platform cloud synchronization.

Core Rules

  • Atomic Write-and-Swap Operations: Never overwrite an existing save file directly in place. Always serialize to a temporary .tmp file, flush to disk (fsync), keep a rolling .bak backup of the previous valid save, and perform an atomic rename to the target save slot.
  • Monotonic Schema Versioning: Embed an explicit integer schema_version in every save header. Maintain deterministic step-by-step migration functions (v1 -> v2 -> v3) so legacy player saves upgrade cleanly after patches.
  • Cryptographic Checksum Validation: Compute and store a SHA-256 or HMAC-SHA256 digest of the serialized payload in the save envelope to detect corrupted writes, disk bit-rot, or malformed structures before deserialization.
  • Contract Adherence: Emit contracts/schemas/implementation-result.json upon completing save persistence implementations.

Suggested Process

1. Envelope & Monotonic Schema Design

Define a strict save envelope separating header metadata from game payload:

  • Header: magic_bytes, schema_version, timestamp_utc, playtime_seconds, payload_sha256
  • Payload: structured player progression, inventory state, world flags, and deterministic RNG seeds Support human-readable JSON for debug builds and compact binary serialization (MessagePack, FlatBuffers, or binary streams) for production releases.
Installs
4
GitHub Stars
5
First Seen
Oct 26, 2026