本文へスキップ
Skillpedia
APIとサーバー(バックエンド)15k · #10987

principle-separate-before-serializing-shared-state

できること

このスキルは、同じファイル、ブランチ、状態に同時に書き込むかもしれない並行作業を扱うための規則を、アシスタントに与えます。複数のワーカーやエージェントを同時に動かすエンジニア向けです。

使う場面

  • ✓複数のエージェントやプロセスが、同じファイルや状態に書き込むかもしれないとき。
  • ✓2つのブランチやワーカーが、同じ対象にプッシュしてしまうとき。
  • ✓断続的なレースコンディションを直すために、ロックを追加したくなるとき。

スキルのリンク

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-separate-before-serializing-shared-state/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-separate-before-serializing-shared-state/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“3つのエージェントが1つの共有のステータスファイルに書き込み、それが壊れ続けています。設計を直してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

アシスタントは、ワーカーが本当に1つの共有のオブジェクトを必要とするかを問います。必要なければ、各ワーカーに独自のファイルやキーを与え、報告の段階でだけ統合します。1人の共有の書き手が本当に必要な場合にのみ、ロックのような構造的な直列化を追加します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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:

  1. Identify shared mutable state (files both read and write, branches both push to, APIs both define and consume).
  2. 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 lastX field into one state.json is still shared mutation. indexer-state.json + metrics-state.json is not.
  3. 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.
よくある質問

指示だけで衝突を防げますか?

いいえ。スキルは、指示や慣習は並行性の制御ではないと述べています。

ロックは既定の解決策ですか?

いいえ。ロックが必要だという考えは、まず確認すべき設計の匂いとして扱われます。

良い分け方とは?

複数のワーカーが1つの共有ファイルに書き込むのではなく、各アクターが所有する別々の状態ファイルです。

詳細

作者による元の説明

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.

repo: cursor/plugins

人気

GitHubのスター
15k
ランキング
#10987
ライセンス
—
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル