[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E7GWPZ89CEFBTDKTDE5VAF":3,"skill-same:01M7E7GWPZ89CEFBTDKTDE5VAF":47},{"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":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":46},"01M7E7GWPZ89CEFBTDKTDE5VAF","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.","giuseppecrj\u002Fpi-herdr-pstack","giuseppecrj","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F5714678?v=4","01M7E7A7DZHS53J4N29EW0XYZX","Giuseppe Rodriguez","01M7E7A7EHHKRDDBPPFPKNHFDY",3,"MIT","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\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.\"\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":24},true,"main","43aca90238855614654b0222294818ec6ad2e846","skills\u002Fpstack\u002Fprinciple-separate-before-serializing-shared-state",0,"https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj","giuseppecrj.com","Building agent infrastructure, protocol systems, and real-time product software.","2026-11-13 09:05:00",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":24},[36,39,42],{"tool":37,"command":38},"npx","npx skills add giuseppecrj\u002Fpi-herdr-pstack --skill principle-separate-before-serializing-shared-state",{"tool":40,"command":41},"bunx","bunx skills add giuseppecrj\u002Fpi-herdr-pstack --skill principle-separate-before-serializing-shared-state",{"tool":43,"command":44},"pnpm","pnpm dlx skills add giuseppecrj\u002Fpi-herdr-pstack --skill principle-separate-before-serializing-shared-state","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\u002Fprinciple-separate-before-serializing-shared-state\u002FSKILL.md",[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7E7JPTA02FFGS96SQYQ678W","poteto-mode","Test fixture. A different skill that reuses the poteto-mode name, to check shadowing diagnostics.","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fshadow-skills\u002Fpoteto-mode\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7E7JGE95NH51A731ZTRWECS","why","Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior.","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\u002Fwhy\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7E7JEEJ2303D2M1897CCR8N","unslop","Cut AI tells from any writing. Must always apply.","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\u002Funslop\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7E7JCM06BKK08YM1HZ7MW67","typescript-best-practices","TypeScript best practices. Use when reading or editing any .ts or .tsx file.","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\u002Ftypescript-best-practices\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7E7J7SHT7XMV128283BE35W","technical-writing","Layered technical-writing standard: Diátaxis structure, Google developer style sentences, STE instruction rules, Global English syntax. Use for \u002Fskill:technical-writing or when writing or reviewing docs, RFCs, readmes, PR descriptions, or commit messages.","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\u002Ftechnical-writing\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":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7E7J525CXJN2FKSN7HTW2X0","swarm","Fan out N parallel workers, drain them, and return one report. Use for \u002Fswarm, 'swarm this', or parallel coverage, races, gauntlets, and exploration.","https:\u002F\u002Fgithub.com\u002Fgiuseppecrj\u002Fpi-herdr-pstack\u002Fblob\u002Fmain\u002Fskills\u002Fpstack\u002Fswarm\u002FSKILL.md",[],[]]