Skip to content
Back to skills

Principle Separate Before Serializing Shared State

ASecurity

Separate before serializing shared state. Apply when concurrent actors might write to the same file, branch, key or state object.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
ai-agentsgitapi

Works with

  • cursor
  • api

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add erickb336/sage-stack --skill principle-separate-before-serializing-shared-state --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Principle Separate Before Serializing Shared State?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Principle Separate Before Serializing Shared State
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/erickb336-principle-separate-before-serializing-shared-state/badge)](https://www.skillsdirectory.com/skills/erickb336-principle-separate-before-serializing-shared-state)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: principle-separate-before-serializing-shared-state
description: "Separate before serializing shared state. Apply when concurrent actors might write to the same file, branch, key or state object."
license: MIT
metadata:
  source: "pstack principle-separate-before-serializing-shared-state, MIT, Copyright (c) 2026 Lauren Tan, github.com/cursor/plugins, adapted; checked against pstack 0.15.36 at commit 0bb6f37"
---

<!-- Generated by scripts/build.mjs from the sources; edit the source, then run npm run build. -->

# Separate before serializing shared state

When concurrent actors might share state that changes, first ask whether they need the same object. If not, remove the sharing. When the sharing is real, enforce one writer at a time by structure: lock files, sequential phases or exclusive ownership. Instructions and conventions are not concurrency control.

**Why.** Concurrent writes to shared state cause race conditions. They are intermittent, hard to reproduce and expensive to debug.

**What to do.**
1. **Find the shared state that changes:** files that both read and write, branches that both push to, APIs that both define and consume.
2. **By default, remove the shared write target.** Ask: do these actors need one canonical object, or do they publish independent facts? Give each actor its own file, key, branch or state folder. Merge the results only where they are read or reported. Two actors that each write their own `lastX` field into one `state.json` still share it; `indexer-state.json` and `metrics-state.json` do not.
3. **Only when one shared write target is a real invariant, serialise access by structure:** lock files, sequential phases, a single writer or an atomic compare-and-swap. Treat "we need a lock" as a design smell to check, not as the default answer.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.