{"data":{"slug":"discovered-34808a3fb3ae1cc18cefe15dfd5b7a4ef251b0c4d0bb3d67","title":"Principle: Separate Before Serializing Shared State","summary":"Ensure that parallel actors writing to the same target are separated first, and only serialize access when a shared write target is an invariant.","url":"https:\/\/skillshunter.net\/skills\/discovered-34808a3fb3ae1cc18cefe15dfd5b7a4ef251b0c4d0bb3d67","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-34808a3fb3ae1cc18cefe15dfd5b7a4ef251b0c4d0bb3d67","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-34808a3fb3ae1cc18cefe15dfd5b7a4ef251b0c4d0bb3d67.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-34808a3fb3ae1cc18cefe15dfd5b7a4ef251b0c4d0bb3d67\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before implementing shared state serialization, confirm whether actors require a single shared object or can operate independently. If independent, assign each actor its own file, key, or directory, and merge only during reads.","instructions":"---\nname: principle-separate-before-serializing-shared-state\ndescription: When parallel actors share a write target, separate them first.\ndisable-model-invocation: true\n---\n\n# Separate Before Serializing Shared State\n\nWhen concurrent actors might write the same file, branch, key, or object, first ask whether they need one shared object or are publishing independent facts. Default to giving each actor its own file, key, branch, or state directory, and merge only where the state is read. Two workers writing their own field into one `state.json` is still shared mutation.\n\nOnly when one shared write target is a real invariant, serialize access structurally (a lockfile, a single writer, sequential phases, compare-and-swap). Instructions are not concurrency control, and \"we need a lock\" is a smell to check first.\n","use_cases":["Managing concurrent writes to shared files in distributed systems","Avoiding race conditions in multi-threaded applications","Designing state management in parallel processing pipelines"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/jueyi6\/empstack\/blob\/74181e31d2f00313f8683ba157966efcabbe109e\/skills\/principle-separate-before-serializing-shared-state\/SKILL.md","source_commit":"74181e31d2f00313f8683ba157966efcabbe109e","license":null,"version":null,"listing_approved_at":"2026-12-02","created_at":"2026-11-30T08:56:29.000000Z","updated_at":"2026-12-02T09:15:14.000000Z","seo_title":"Principle: Separate Before Serializing Shared State","seo_description":"A guide on managing shared state in concurrent systems by separating actors first and only serializing when necessary.","seo_keywords":["concurrent writing","shared state management","concurrency control","distributed systems","parallel processing"]}}