# Principle separate before serializing shared state

> Principle separate before serializing shared state is an open-source agent skill for developer tools. Guides agents to avoid write conflicts by splitting shared state before adding locks. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michael-denyer/pstack-claude/tree/main/plugins/pstack/skills/principle-separate-before-serializing-shared-state
- **Repository:** https://github.com/michael-denyer/pstack-claude
- **GitHub stars:** 5,057
- **License:** MIT
- **Skill name:** principle-separate-before-serializing-shared-state
- **Collection:** https://github.com/michael-denyer/pstack-claude
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill gives the agent a design rule for situations where several concurrent actors could write to the same file, git branch, key or state object. Before reaching for coordination machinery, the agent is asked whether the actors truly need one shared target or are really publishing independent facts. The default answer is to give each actor its own file, key, branch or state directory, and to combine results only at the point where they are read.

The skill also explains when serialization is justified. If a single shared write target is a genuine invariant, the agent should pick a structural mechanism such as a lockfile, a single writer, sequential phases or compare-and-swap. It warns that written instructions do not count as concurrency control, and that a proposal to add a lock should be checked against the separation option first.

The skill is a short prose guideline with no scripts. It is written for Claude Code plugin use and needs no external tools or languages beyond the agent's own workflow.

## When your agent uses it

> 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.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-separate-before-serializing-shared-state)
- [License: MIT](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-separate-before-serializing-shared-state)

## Features

- **Separation first default:** Prompts the agent to give each concurrent actor its own file, key, branch or state directory before anything else.
- **Merge at read time:** Directs combining of separately written state only where it is actually read, not where it is written.
- **Justified serialization:** Describes when a single shared writer is a real invariant and which structural mechanisms fit.
- **Lock skepticism check:** Flags the impulse to add a lock as a smell to examine before implementing it.
- **Instructions are not locks:** Reminds the agent that asking workers to behave is not a substitute for concurrency control.

## Good for

- Plan parallel agent workers that write results without clobbering each other
- Review a multi-agent workflow for shared state writes that could conflict
- Decide whether a shared JSON status file needs a lock or separate per-worker files
- Design branch or directory layout for concurrent code generation tasks

## Install

### Claude Code

This skill ships in the `pstack` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add michael-denyer/pstack-claude
/plugin install pstack@pstack-claude
```

Or copy only this skill to `~/.claude/skills/principle-separate-before-serializing-shared-state`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/principle-separate-before-serializing-shared-state &&
cp -R "$tmp/plugins/pstack/skills/principle-separate-before-serializing-shared-state" ~/.claude/skills/principle-separate-before-serializing-shared-state &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/principle-separate-before-serializing-shared-state` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/principle-separate-before-serializing-shared-state` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/principle-separate-before-serializing-shared-state &&
cp -R "$tmp/plugins/pstack/skills/principle-separate-before-serializing-shared-state" ~/.agents/skills/principle-separate-before-serializing-shared-state &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/principle-separate-before-serializing-shared-state` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/principle-separate-before-serializing-shared-state` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/principle-separate-before-serializing-shared-state &&
cp -R "$tmp/plugins/pstack/skills/principle-separate-before-serializing-shared-state" ~/.cursor/skills/principle-separate-before-serializing-shared-state &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/principle-separate-before-serializing-shared-state` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/michael-denyer/pstack-claude.git --path plugins/pstack/skills/principle-separate-before-serializing-shared-state
```

Or copy the folder to `~/.gemini/skills/principle-separate-before-serializing-shared-state` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/principle-separate-before-serializing-shared-state`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/principle-separate-before-serializing-shared-state &&
cp -R "$tmp/plugins/pstack/skills/principle-separate-before-serializing-shared-state" ~/.copilot/skills/principle-separate-before-serializing-shared-state &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/principle-separate-before-serializing-shared-state` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git
```

Then copy `pstack-claude/plugins/pstack/skills/principle-separate-before-serializing-shared-state` into your agent's skills folder as `principle-separate-before-serializing-shared-state`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Principle separate before serializing shared state trigger?

It applies when concurrent actors might write to the same file, branch, key or state object, as stated in its description.

### Does Principle separate before serializing shared state add scripts or tools to my project?

No. The skill has no scripts and its allowed tools are not set; it is a guideline the agent follows.

### What does Principle separate before serializing shared state recommend when a lock is needed?

It says to serialize structurally, for example with a lockfile, a single writer, sequential phases or compare-and-swap, but only when one shared write target is a real invariant.

### How do I install Principle separate before serializing shared state in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/principle-separate-before-serializing-shared-state to use it in all your projects, or to .claude/skills/principle-separate-before-serializing-shared-state in one project. Or install the pstack plugin, which includes it: /plugin marketplace add michael-denyer/pstack-claude, then /plugin install pstack@pstack-claude.

### Does Principle separate before serializing shared state run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Principle separate before serializing shared state?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Principle separate before serializing shared state?

The closest alternatives to Principle separate before serializing shared state are Principle foundational thinking, Principle make operations idempotent, Principle never block on the human, Principle minimize reader load and Orchestration.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Principle foundational thinking](https://ai-powered.com/skills/principle-foundational-thinking): Principle foundational thinking is an open-source agent skill for developer tools.
- [Principle make operations idempotent](https://ai-powered.com/skills/principle-make-operations-idempotent): Principle make operations idempotent is an open-source agent skill for developer tools.
- [Principle never block on the human](https://ai-powered.com/skills/principle-never-block-on-the-human): Principle never block on the human is an open-source agent skill for developer tools.
- [Principle minimize reader load](https://ai-powered.com/skills/principle-minimize-reader-load): Principle minimize reader load is an open-source agent skill for developer tools.
- [Orchestration](https://ai-powered.com/skills/orchestration-xiaolai): Orchestration is an open-source agent skill for developer tools.
- [Dispatching parallel agents](https://ai-powered.com/skills/dispatching-parallel-agents): Dispatching parallel agents is an open-source agent skill for developer tools.
- [Principle sequence verifiable units](https://ai-powered.com/skills/principle-sequence-verifiable-units): Principle sequence verifiable units is an open-source agent skill for developer tools.
- [Writing rules](https://ai-powered.com/skills/writing-rules-xiaolai): Writing rules is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/principle-separate-before-serializing-shared-state
