共享状态分离原则
principle-separate-before-serializing-shared-state
当并发参与者可能写入同一文件、分支、键或状态对象时应用。先消除共享;只有当'单一共享写入者'是真正必须成立的不变量时,才在结构上采用序列化。
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- principle-separate-before-serializing-shared-state
- description
- 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.
- disable-model-invocation
- true
02 资源文件 1
- 参考文档repos/metamask-mobile.md8.0 KB
03 SKILL.md 正文
Separate Before Serializing Shared State
When 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.
Why: Concurrent writes to shared state create race conditions that are intermittent, hard to reproduce, and expensive to debug.
Pattern:
- Identify shared mutable state (files both read and write, branches both push to, APIs both define and consume).
- 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/reporting boundary. Two workers writing their own
lastXfield into onestate.jsonis still shared mutation.indexer-state.json+metrics-state.jsonis not. - 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.
04 同仓库更多 Skills
Claude 技能创建指南
skill-creator
创建有效技能的指南。当用户想要创建新技能(或更新现有技能),以通过专业知识、工作流或工具集成来扩展 Claude 的能力时,应使用此技能。
素材成文逐段撰写
writing-shape
写作,利用(exploit):将原始素材逐段塑造成一篇文章。
Playwright 网页应用测试
webapp-testing
使用 Playwright 测试本地 Web 应用。适用于验证前端功能、调试 UI 行为、截取浏览器截图或查看浏览器日志。
消息重述
wait-what
停。上一条消息没有被理解(没说清楚):换一种方式重新表述。
快速原型构建
prototype
构建一个一次性原型来回答设计问题。当用户想要验证某个状态模型或逻辑是否合理,或探索 UI 应该是什么样子时使用。
代码库架构优化分析
improve-codebase-architecture
扫描代码库以发现可深化改进的机会,将其以可视化 HTML 报告的形式呈现,然后对你选中的某一项进行深入质询。