[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71RWYXM1KKVMVPS6AFB4FRP":3,"skill-same:01M71RWYXM1KKVMVPS6AFB4FRP":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":54,"install":55,"resources":67},"01M71RWYXM1KKVMVPS6AFB4FRP","pstack-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.","dmae97\u002Fomk","dmae97","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F146327957?v=4","01M71RJRBWDNKEJ1A2DZVES8X1","01M71RJRCYHNT7E83M0Q42V6SJ",152,"MIT","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Fresources\u002Fpstack\u002Fskills\u002Fprinciple-separate-before-serializing-shared-state\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"shared","pstack principle separate before serializing shared state","pstack","state","principle separate before serializing shared state","branch","write","only","writer","first","sharing","true","object","serialize","apply","when","one","same","file","2026-11-10 13:02:02",false,"---\nname: pstack-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.\"\ndisable-model-invocation: true\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,"disable-model-invocation":47},true,"main","ea03fcf76b438f12f0cebcd6b255d24d4cb52741","packages\u002Fcoding-agent\u002Fresources\u002Fpstack\u002Fskills\u002Fprinciple-separate-before-serializing-shared-state",29,"https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk","https:\u002F\u002Fgithub.com\u002Fdmae97","2026-11-11 10:48:59",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":47},[57,60,63],{"tool":58,"command":59},"npx","npx skills add dmae97\u002Fomk --skill pstack-principle-separate-before-serializing-shared-state",{"tool":61,"command":62},"bunx","bunx skills add dmae97\u002Fomk --skill pstack-principle-separate-before-serializing-shared-state",{"tool":64,"command":65},"pnpm","pnpm dlx skills add dmae97\u002Fomk --skill pstack-principle-separate-before-serializing-shared-state","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Fresources\u002Fpstack\u002Fskills\u002Fprinciple-separate-before-serializing-shared-state\u002FSKILL.md",[],[69,81,95,108,119,127],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":76,"publishedAt":42},"01M71RZKQCQ4G7MP08TE3QQ0PD","valid-skill","A valid skill for testing purposes.","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Ftest\u002Ffixtures\u002Fskills\u002Fvalid-skill\u002FSKILL.md",[75],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[77,78,79,80],"valid skill","valid","testing","for",{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":88,"publishedAt":42},"01M71RZJ8YHH8GKADPTSZBCJ1T","unknown-field","A skill with an unknown frontmatter field.","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Ftest\u002Ffixtures\u002Fskills\u002Funknown-field\u002FSKILL.md",[87],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[89,90,91,92,93,94],"unknown","unknown field","a skill","frontmatter","with","unknown frontmatter field",{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":102,"publishedAt":42},"01M71RZH4FVEENABTV8WTQ5HTS","nested-child","Nested skill should be ignored.","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Ftest\u002Ffixtures\u002Fskills\u002Froot-skill-preferred\u002Fnested-child\u002FSKILL.md",[101],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[103,104,105,106,107],"nested child","child","nested","ignored","nested skill",{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":115,"publishedAt":42},"01M71RZFZYSXRRVY5M8HP05NJV","root-skill-preferred","Root skill should win.","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Ftest\u002Ffixtures\u002Fskills\u002Froot-skill-preferred\u002FSKILL.md",[114],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[116,117,118],"root","root skill preferred","root skill",{"skillNo":120,"name":121,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":125,"publishedAt":42},"01M71RZEQDH7RZ1PH36G7GPN9N","no-frontmatter","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Ftest\u002Ffixtures\u002Fskills\u002Fno-frontmatter\u002FSKILL.md",[124],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[92,126],"no frontmatter",{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":134,"publishedAt":42},"01M71RZDC0QR3ZJQ549N3H94Y4","child-skill","A nested skill in a subdirectory.","https:\u002F\u002Fgithub.com\u002Fdmae97\u002Fomk\u002Fblob\u002Fmain\u002Fpackages\u002Fcoding-agent\u002Ftest\u002Ffixtures\u002Fskills\u002Fnested\u002Fchild-skill\u002FSKILL.md",[133],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[135,104,107,105],"child skill"]