principle-separate-before-serializing-shared-state

Eliminates shared mutable state between concurrent actors before applying structural serialization.

1|Updated Aug 26, 2026
One-click install
npx skills add https://github.com/edivad1999/stuc-stack --skill principle-separate-before-serializing-shared-state-edivad1999
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: principle-separate-before-serializing-shared-state
Source: https://github.com/edivad1999/stuc-stack/tree/main/skills/principle-separate-before-serializing-shared-state
Command: npx skills add https://github.com/edivad1999/stuc-stack --skill principle-separate-before-serializing-shared-state-edivad1999

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Concurrent agents or processes writing to the same file, branch, key, or state object create race conditions that are intermittent, hard to reproduce, and expensive to debug. This Skill provides a decision pattern for removing shared write targets first and only serializing access when a single shared writer is a genuine invariant. ## Core Features & Use Cases - Shared State Identification: Detects files, branches, keys, or state objects that multiple actors both read and write. - Separation-First Pattern: Guides splitting one shared target into per-actor owned files or keys (for example, indexer-state.json plus metrics-state.json instead of one shared state.json), merging only at the read boundary. - Structural Serialization Fallback: When one shared writer is unavoidable, enforces lockfiles, sequential phases, single-writer actors, or atomic compare-and-swap instead of conventions. - Use Case: Two agents must not share one Android emulator without a lock; this Skill enforces one serial device per android-verify run and refuses double-driving, since android-cli has --device but no lease mechanism. ## Quick Start Apply the separate-before-serializing principle to review my concurrent workflow where two agents write to the same state file.

Frequently Asked Questions about principle-separate-before-serializing-shared-state

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent race conditions when multiple agents write to the same file?▼

Race conditions are prevented by first eliminating the shared write target: give each actor its own owned file, key, or state directory and merge only at the read boundary. Serialize access with lockfiles or sequential phases only when one shared writer is a real invariant.

What is the separate-before-serializing pattern for shared state?▼

It is a three-step pattern: identify shared mutable state, default to eliminating the shared write target by giving each actor its own object, and only serialize access structurally when a single shared writer is unavoidable. Instructions and conventions are not concurrency control.

Can two agents share one Android emulator for verification?▼

Two agents must not share one emulator without a lock. The rule is one serial device per android-verify run, and double-driving is refused because android-cli provides a --device flag but no lease mechanism.

Why does telling concurrent workers to take turns not work?▼

Verbal or documented conventions are not concurrency control; they produce intermittent, hard-to-reproduce race conditions. Only structural mechanisms like lockfiles, sequential phases, single-writer actors, or atomic compare-and-swap actually enforce serialization.

When should I use a lock instead of splitting shared state?▼

Use a lock only when one shared write target is a real invariant that cannot be split. Treat needing a lock as a design smell to check first, since per-actor owned state merged at the read boundary is the default answer.