본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)15k · #10987

principle-separate-before-serializing-shared-state

하는 일

같은 파일, 브랜치, 상태에 동시에 쓸 수 있는 작업을 다루는 규칙을 에이전트에 제공합니다. 여러 작업자나 에이전트를 동시에 돌리는 엔지니어를 위한 스킬입니다.

사용하는 경우

  • ✓여러 에이전트나 프로세스가 같은 파일이나 상태 객체에 쓸 수 있을 때.
  • ✓두 브랜치나 작업자가 같은 대상으로 푸시하려는 경우.
  • ✓간헐적인 경합 상태를 고치려고 락을 추가하고 싶을 때.

스킬 링크

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-separate-before-serializing-shared-state/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“에이전트 세 개가 공유 상태 파일 하나에 씁니다. 그런데 계속 손상됩니다. 설계를 고쳐 주세요.”

매주 새 스킬 5개. 읽는 데 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.
자주 묻는 질문

지침만으로 충돌을 막을 수 있나요?

아니요. 이 스킬은 지침과 관례는 동시성 제어가 아니라고 말합니다.

락이 기본 해결책인가요?

아닙니다. 락이 필요하다는 생각은 먼저 점검해야 할 설계 신호로 봅니다.

좋은 분리 방식은 무엇인가요?

여러 작업자가 한 파일에 쓰는 대신, 각 주체가 소유하는 상태 파일을 따로 두는 것입니다.

상세 정보

작성자의 원본 설명

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

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬