[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B17RXDDAEC852A5024KTHB":3,"skill-same:01M7B17RXDDAEC852A5024KTHB":50},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7B17RXDDAEC852A5024KTHB","principle-separate-before-serializing-shared-state",null,"Apply when concurrent actors might write to the same file, branch, key, or state object. Eliminate the sharing first; serialize structurally only when one shared writer is a real invariant.","saphitv\u002Fskills","saphitv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F54666981?v=4","01M7B13YDD32AHNCZS9HJP9MBD","Simon Maggini","01M7B13YE0E1SZKRC4S7WWTAT7",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fpoteto\u002Fskills\u002Factive\u002Fprinciple-separate-before-serializing-shared-state\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fpoteto\u002Fskills\u002Factive\u002Fprinciple-separate-before-serializing-shared-state\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: principle-separate-before-serializing-shared-state\ndescription: \"Apply when concurrent actors might write to the same file, branch, key, or state object. Eliminate the sharing first; serialize structurally only when one shared writer is a real invariant.\"\n---\n\n# Separate Before Serializing Shared State\n\nWhen concurrent actors might share mutable state, first ask whether they need the same mutable object. If not, eliminate the sharing. When sharing is real, enforce serialization structurally: lockfiles, sequential phases, exclusive ownership. Instructions and conventions are not concurrency control.\n\n**Why:** Concurrent writes to shared state create race conditions that are intermittent, hard to reproduce, and expensive to debug.\n\n**Pattern:**\n1. **Identify shared mutable state** (files both read and write, branches both push to, APIs both define and consume).\n2. **Default: eliminate the shared write target.** Ask: do these actors need one canonical object, or are they publishing independent facts? Give each actor its own owned file, key, branch, or state directory, and merge only at the read\u002Freporting boundary. Two workers writing their own `lastX` field into one `state.json` is still shared mutation. `indexer-state.json` + `metrics-state.json` is not.\n3. **Only when one shared write target is a real invariant, serialize access structurally** (lockfiles, sequential phases, single-writer actor, or atomic compare-and-swap). Treat \"we need a lock\" as a design smell to check, not as the default answer.\n","# Separate Before Serializing Shared State\n\nWhen concurrent actors might share mutable state, first ask whether they need the same mutable object. If not, eliminate the sharing. When sharing is real, enforce serialization structurally: lockfiles, sequential phases, exclusive ownership. Instructions and conventions are not concurrency control.\n\n**Why:** Concurrent writes to shared state create race conditions that are intermittent, hard to reproduce, and expensive to debug.\n\n**Pattern:**\n1. **Identify shared mutable state** (files both read and write, branches both push to, APIs both define and consume).\n2. **Default: eliminate the shared write target.** Ask: do these actors need one canonical object, or are they publishing independent facts? Give each actor its own owned file, key, branch, or state directory, and merge only at the read\u002Freporting boundary. Two workers writing their own `lastX` field into one `state.json` is still shared mutation. `indexer-state.json` + `metrics-state.json` is not.\n3. **Only when one shared write target is a real invariant, serialize access structurally** (lockfiles, sequential phases, single-writer actor, or atomic compare-and-swap). Treat \"we need a lock\" as a design smell to check, not as the default answer.\n",{"name":5,"description":7},"main","e140a936f9f29c17f35164b21aae448f41b87cbb","poteto\u002Fskills\u002Factive\u002Fprinciple-separate-before-serializing-shared-state","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills","https:\u002F\u002Fgithub.com\u002Fsaphitv","Working at Easyprog, attending school at Supsi, passionate about web development.","2026-11-12 16:56:25",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add saphitv\u002Fskills --skill principle-separate-before-serializing-shared-state",{"tool":38,"command":39},"bunx","bunx skills add saphitv\u002Fskills --skill principle-separate-before-serializing-shared-state",{"tool":41,"command":42},"pnpm","pnpm dlx skills add saphitv\u002Fskills --skill principle-separate-before-serializing-shared-state","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fpoteto\u002Fskills\u002Factive\u002Fprinciple-separate-before-serializing-shared-state\u002FSKILL.md",true,[46],{"path":47,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":16},"LICENSE","许可证",1067,[51,59,67,75,83,91],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":55,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":20},"01M7B1FHX908WSXXJENZ8RV88N","takeover","Take over existing work. Use when the user asks to take over a PR, branch, or agent thread, or requests a takeover.","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Ftakeover\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Ftakeover\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":63,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":20},"01M7B1FAZW3D5D8Q2QSTBX4BZQ","statechart","Check a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for \u002Fstatechart, or to show a bug as a path through states.","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fstatechart\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fstatechart\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":20},"01M7B1F96A7KZSGDPR59MVQCTB","sol-loop","Use when the user says \"sol loop\".","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fsol-loop\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fsol-loop\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":20},"01M7B1F3TB4MVFFKB16HZG9NCX","security-audit-testing","Experimental Cloudflare security-audit trial for security questions, focused vulnerability reviews, codebase audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full\u002Fcomprehensive\u002Fend-to-end reviews, or requested report artifacts.","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fsecurity-audit-testing\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fsecurity-audit-testing\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":20},"01M7B1EZ0530A1BB1SND8NTDSV","retro","Conduct a retrospective on a coding session.","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fretro\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fretro\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M7B1EWKNQPSW37CS533BHAVW","modernize","For getting old prs up to date. Use when asked to rebase a pr or \"modernize\".","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fmodernize\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsaphitv\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Factive\u002Fmodernize\u002FSKILL.md",[],[]]