Agent skill

Sync State Invariants

by openchamber in openchamber/openchamber

A skill your agent uses when changing session synchronization, bootstrap or reconnect state, event reducers, polling, optimistic updates, message queues, live activity, ordering/reconciliation…

MITAuto-check passedBusiness, Finance & HR

Install Sync State Invariants

skills CLI
$ npx skills add openchamber/openchamber --skill sync-state-invariants -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install openchamber/openchamber sync-state-invariants --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/openchamber/openchamber.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/sync-state-invariants .claude/skills/sync-state-invariants && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
sync-state-invariants
GitHub stars
11k
Token cost
~2.7k tokens
SKILL.md length
1,401 words
Files
1
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when changing session synchronization, bootstrap or reconnect state, event reducers, polling, optimistic updates, message queues, live activity, ordering/reconciliation…

  • Changing session synchronization
  • SKILL.md covers Required Context, Sources Of Truth, Failure Is Not Empty and Live And Historical State, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Reconnect state

What it does

Sync State Invariants is an agent skill from openchamber/openchamber. Use when changing session synchronization, bootstrap or reconnect state, event reducers, polling, optimistic updates, message queues, live activity, ordering/reconciliation, runtime-scoped caches, or directory-dependent session behavior.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Business, Finance & HR, covering State management, Accounting and bookkeeping and Event-driven systems. The repository describes itself as: Agentic Development Environment based on OpenCode AI agent. The licence is MIT.

When your agent uses it

  • Changing session synchronization
  • Reconnect state
  • Optimistic updates
  • Ordering/reconciliation

Example prompts

  • “/sync-state-invariants”

What it can do on your machine

Read from SKILL.md and the folder at commit 74b79d4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Sync State Invariants loads about 2.7k tokens when it runs. Until then it costs about 65 tokens; SKILL.md has 1,401 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~65
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from openchamber/openchamber at commit 74b79d4, republished under its MIT licence (© openchamber). 1,401 words, ~2,694 tokens.

Download SKILL.mdSave it as .claude/skills/sync-state-invariants/SKILL.md (or your agent's skills folder).
name
sync-state-invariants
description
Use when changing session synchronization, bootstrap or reconnect state, event reducers, polling, optimistic updates, message queues, live activity, ordering/reconciliation, runtime-scoped caches, or directory-dependent session behavior.

Sync State Invariants

Required Context

Read packages/ui/src/sync/DOCUMENTATION.md and the nearest owning module documentation before editing. Context gathering is complete when every changed state has an identified owner, authority, scope, and lifecycle.

Before editing behavior a user can reach, write the surface list from ui-api-decoupling, Name The Surfaces Before Editing: one line per runtime, including the ones this change appears to leave alone. State that reconciles differently per runtime is a parity decision, not an implementation detail.

Sources Of Truth

Classify every input before deriving state:

InputValid use
Directory child storeLive per-directory session/message/status/permission state
Global sessions storeComplete global active/archived cache and retention/sidebar coverage
Persisted history/cacheStartup continuity and context restoration, never proof of current activity
Optimistic shadow stateTemporary UI continuity until authoritative reconciliation

Prefer deterministic authoritative records over heuristics. Derive live behavior from live channels, not historical anomalies.

Give each state and its invariants one owner. Callers request domain transitions from that owner; they do not inspect one field, mutate another collection, and repair status externally. Split ownership only when the states have genuinely independent lifecycles.

Represent mutually exclusive lifecycle states with discriminated unions or equally precise contracts. Avoid boolean/nullable field combinations that permit impossible states. Reject invalid transitions at the owning boundary so downstream reducers and effects receive trusted state.

Failure Is Not Empty

Any authoritative loader whose result can replace, delete, or clear state must distinguish failure from successful empty data.

Use an existing pattern:

  • Throw when an outer logical block can catch and preserve prior state.
  • Return T | null when follow-up work must continue and null exclusively means fetch failure.

Never swallow an SDK/API error into [], {}, or another valid empty success. Verify that callers skip destructive replacement after failure.

Track completeness at the smallest entity/scope. One failed project or directory blocks destructive work for itself, not for unrelated complete scopes.

Inferring destructive cleanup from disappearance between snapshots requires an established authoritative baseline. This is separate from applying a complete snapshot whose contract explicitly authorizes first-load replacement.

  • Never infer a disappearance event from the first snapshot, startup-empty state, filtered/visible subsets, or partially loaded scopes.
  • Compare two complete authoritative snapshots from the same runtime and logical scope before treating disappearance as removal.
  • Key disappearance by stable entity identity. Owner, directory, grouping, category, or presentation moves are not deletion unless the authoritative contract says so.
  • Reset the baseline when runtime identity or authoritative scope changes.
  • Prefer explicit deletion events; snapshot-difference cleanup is a fallback that requires completeness guarantees.

Live And Historical State

  • Use historical state to restore context, not to infer ongoing execution.
  • Scope delayed-live fallbacks to the active entity and clear them when authoritative state arrives.
  • Do not let stale persisted data keep a fallback active indefinitely.
  • Define field precedence when global and local/live snapshots feed the same view.
  • Use one ordering/rank source for all views of the same entities.

Event Reducers

  • Make the valid transition path explicit and flat. Return early for irrelevant entities and semantic no-ops; assert or reject transitions that violate an established invariant.
  • Clone only fields the event mutates; preserve every unrelated reference.
  • Return no change for semantically identical events.
  • Gate scans behind cheap event/entity checks.
  • Coalesce repeated same-entity events without violating ordering.
  • Reject stale async/event completions using generation or authoritative timestamps.
  • Do not widen a narrow fallback to arbitrary historical records.

For streaming-frequency work, also load performance-engineering.

Polling And Bootstrap

  • Preserve rich fields when lightweight polling omits them.
  • Use cheap change detection before heavy per-directory fetches.
  • Refresh only directories already running: the selected one and those an event names. Every OpenCode read of a directory starts it with its MCP servers (opencode-v2), so a refresh over every store is a fan-out.
  • Treat startup 502/503 as transient with bounded retry/recovery.
  • A retry loop requires a real failure signal; swallowed errors disable retries.
  • Preserve previous authoritative state during transient bootstrap/reconnect failures.
  • Distinguish stale-scope rejection from same-scope mutation reconciliation. A generation token rejects obsolete owners but does not protect mutations made while a still-valid request is in flight.
  • Capture a mutation revision when an authoritative load starts. At commit time, read current state and preserve or overlay entity mutations newer than that revision.
  • Record removals as mutations even when the entity is already absent, so an in-flight response cannot resurrect it.
  • Return committed reconciled state, not the raw fetched snapshot, when callers depend on the result.

Optimistic Updates

  • Keep optimistic promotion, reconciliation, and rollback behavior behind the store/module that owns both visible and shadow state; do not expose collections for callers to mutate independently.
  • Insert optimistic data into the visible store and a separate shadow tracker.
  • Use client-generated IDs accepted and echoed by the server to reconcile in place.
  • Remove optimistic data from both visible and shadow state on failure.
  • Reconcile deterministically on authoritative fetch/event; do not guess from unrelated events.
  • Stabilize callbacks stored in module-level refs to avoid effect loops.

Session And Queue Consistency

  • Capture provider, model, agent, variant, and other send configuration when queueing.
  • Do not re-resolve queued configuration from mutable current state at send time.
  • Preserve server-backed attachments and convert paths at the transport boundary.
  • Pass a directory hint when a newly created session is not indexed yet.
  • Read mutable current directory at call time; never cache it in a long-lived closure.
Show full SKILL.md (530 more words)Show less

Cache And Lifecycle

  • Match session-store limits to loaded data before events can trigger trimming.
  • Invalidate message/prefetch/file caches on mutation and session eviction.
  • Key runtime-scoped caches by runtime identity when IDs or paths can collide.
  • Clean optimistic and local cache state after partial failures.
Never Evict What Is In Use

An entry acquired during render but protected only after commit is unprotected for the whole render pass. Eviction that runs on acquisition therefore disposes entries that are actively mounting; the next render recreates them in a loading state, which issues another fetch, which repeats forever. The symptom is an endless request loop and sawtoothing listeners, heap, and CPU, and it appears only once live entries outnumber the limit, so it never reproduces on a small workspace.

  • Define what protects an entry from eviction, and prove that protection is in place before eviction can observe the entry, not one commit later.
  • Treat capacity as a soft target. Overflowing briefly is always cheaper than evict/recreate cycles; bound the cache with idle-time eviction instead.
  • Never run an eviction scan on the acquisition path. Coalesce it into one deferred pass so a render mounting many entries scans once, not once per entry.
  • Keep explicit lifecycle edges, such as the last consumer releasing an entry, synchronous. Deferring those changes an observable contract.
  • Raising a limit is a workaround, not a fix. It relocates the cliff and hides the loop from everyone whose workload is smaller than the new number.

Persisted Snapshot Ordering

When state exists in memory and one or more persistent stores, define an explicit authority and ordering protocol:

  • Distinguish a missing snapshot from authoritative empty data, malformed data, and read failure.
  • Preserve mutation order independently per owner by serializing writes or attaching monotonic revisions and rejecting stale writes. Do not rely on uncontrolled wall-clock timestamps.
  • Capture runtime/owner identity with every debounced or asynchronous operation and verify it again before commit.
  • Pending writes must complete against their captured owner, drain before an owner switch, or be canceled only under an explicit durability/data-loss contract. Apply the strongest available guarantee at page hide/freeze and shutdown boundaries.
  • During hydration, capture the local mutation revision and do not replace state after newer local mutations.
  • Validate persisted payload shape before granting authority. Malformed data is failure, not empty success.
  • Define retention explicitly; never silently evict older owner namespaces unless bounded retention and resulting data loss are intentional contracts.

Verification

Cover every applicable lifecycle branch, not only static state. Verification is complete when failure cannot masquerade as empty success, stale or partial data cannot cause destructive replacement, and each transition remains with its owner:

  • fresh bootstrap and successful empty result;
  • fetch failure preserving prior state;
  • reconnect/retry and stale completion;
  • repeated/no-op/out-of-order events;
  • optimistic success, reconciliation, and rollback;
  • create, stream, abort, permission, archive/delete, and revisit when session behavior changes;
  • partial multi-directory/project failure;
  • runtime or worktree switch with dynamic directory resolution.
  • snapshot-difference cleanup establishing its first authoritative baseline without deletion, then cleaning a later authoritative disappearance exactly once;
  • identity-preserving moves/category changes and runtime/scope changes resetting cleanup baselines;
  • create, update, move, archive, and delete mutations surviving responses started before those mutations;
  • missing versus empty persistence, malformed payloads, out-of-order writes, hydration races, and lifecycle durability behavior.

© openchamber, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/sync-state-invariants of openchamber/openchamber.

Open the folder on GitHubat commit 74b79d4

Compare with similar skills

Sync State Invariants next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Sync State Invariants compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Sync State Invariants this skillopenchamber/openchamber11k—~2.7kAutomated safety check: PassMIT
Event ModelObneyAI/grain123—~536Automated safety check: PassMIT
Persona Performance Tuningjeremylongshore/tons-of-skills-marketplace2.8k—~1.2kAutomated safety check: PassMIT
Longbridge Intelhelsome/folio2701 repos~1.7kAutomated safety check: PassMIT
Configure Authdotnet/skills5.6k1 repos~1.8kAutomated safety check: PassMIT
Page Langsadobe/skills197—~1.1kAutomated safety check: PassApache-2.0

Similar skills

  • Event Model

    ObneyAI/grain

    Read, write, and validate Grain's service-area-first Event Model topology.

    123 GitHub stars~536 tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Persona Performance Tuning

    jeremylongshore/tons-of-skills-marketplace

    Improve Persona integration latency and throughput with event-driven processing, bounded reconciliation, and evidence-based measurement.

    2.8k GitHub stars~1.2k tokensUpdated today
    Backend & APIsAuto-check passed
  • Longbridge Intel

    helsome/folio

    Market intelligence: strategy screener, popularity rankings, top movers with news correlation, quote anomalies, index/ETF constituent stocks, morning briefings, catalyst monitoring for watchlist…

    270 GitHub starsUsed in 1 repo~1.7k tokens
    Business, Finance & HRAuto-check passed
  • Configure Auth

    dotnet/skills

    Official

    Add authentication and authorization to a Blazor Web App, accounting for the app's render mode.

    5.6k GitHub starsUsed in 1 repo~1.8k tokens
    Business, Finance & HRAuto-check passed
  • Page Langs

    adobe/skills

    Detect all languages used on a webpage — both declared (html@lang, hreflang alternate links, nested lang= attributes, meta content-language) and actually present in the body text (Google CLD3 via…

    197 GitHub stars~1.1k tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Alternatives

    JoelLewis/finance_skills

    Analyze alternative investments including hedge funds, private equity, and venture capital.

    205 GitHub stars~2.1k tokensUpdated 2 mo ago
    Business, Finance & HRAuto-check passed

More from openchamber/openchamber

All 21 skills in this repo
  • Theme System

    openchamber/openchamber

    A skill your agent uses when creating or modifying OpenChamber UI components, styling, colors, buttons, visual states, themes, or icons.

    11k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • UI API Decoupling

    openchamber/openchamber

    A skill your agent uses when creating or modifying OpenChamber shared UI data access, OpenCode SDK calls, RuntimeAPIs, runtime fetch/auth/URLs, authenticated browser assets, bridges/proxies, runtime…

    11k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Drag To Reorder

    openchamber/openchamber

    A skill your agent uses when implementing or modifying OpenChamber sortable or drag-to-reorder behavior, especially @dnd-kit, touch/mobile interactions, variable-width items, or wrapping layouts.

    11k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Locale UI Patterns

    openchamber/openchamber

    A skill your agent uses when creating or modifying OpenChamber UI text, labels, buttons, placeholders, aria labels, empty states, toasts, dialogs, settings copy, navigation labels, or any…

    11k GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Performance Engineering

    openchamber/openchamber

    A skill your agent uses when implementing or reviewing code on interaction, render, event, polling, synchronization, list-processing, store-selector, cache, indexing, or high-volume data paths; when…

    11k GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Serve Sim

    openchamber/openchamber

    A skill your agent uses when working with the OpenChamber iOS Simulator app without opening Xcode - boot/install/launch the Capacitor iOS app, start a browser stream, tap/type/gesture/rotate…

    11k GitHub stars~619 tokensUpdated today
    Auto-check passed

Questions about Sync State Invariants

What does Sync State Invariants do?

A skill your agent uses when changing session synchronization, bootstrap or reconnect state, event reducers, polling, optimistic updates, message queues, live activity, ordering/reconciliation…. Sync State Invariants is an agent skill from openchamber/openchamber. Use when changing session synchronization, bootstrap or reconnect state, event reducers, polling, optimistic updates, message queues, live activity, ordering/reconciliation, runtime-scoped caches, or directory-dependent session behavior.

When should I use Sync State Invariants?

Sync State Invariants fits situations like: changing session synchronization; reconnect state; optimistic updates; ordering/reconciliation.

How do I install Sync State Invariants in Claude Code?

Run `npx skills add openchamber/openchamber --skill sync-state-invariants -a claude-code`. Or copy the skill folder (.agents/skills/sync-state-invariants in openchamber/openchamber) into .claude/skills/sync-state-invariants in your project. Claude Code loads it when a task matches its description.

How do I install Sync State Invariants in Codex?

Run `npx skills add openchamber/openchamber --skill sync-state-invariants -a codex`. Or copy the skill folder (.agents/skills/sync-state-invariants in openchamber/openchamber) into .agents/skills/sync-state-invariants in your project. Codex loads it when a task matches its description.

Can I use Sync State Invariants in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add openchamber/openchamber --skill sync-state-invariants -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sync-state-invariants, .gemini/skills/sync-state-invariants, .github/skills/sync-state-invariants and .opencode/skills/sync-state-invariants in your project.

What does Sync State Invariants need to run?

SKILL.md names no scripts, command-line tools or credentials: Sync State Invariants is instructions for the agent only.

Does Sync State Invariants access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Sync State Invariants safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Sync State Invariants use?

Sync State Invariants is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Sync State Invariants use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Sync State Invariants?

Skills that share tags, products or a category with Sync State Invariants: Event Model (ObneyAI/grain, 123 stars), Persona Performance Tuning (jeremylongshore/tons-of-skills-marketplace, 2.8k stars), Longbridge Intel (helsome/folio, 270 stars) and Configure Auth (dotnet/skills, 5.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Sync State Invariants?

openchamber (a GitHub organization) maintains it in openchamber/openchamber, which has 11,308 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 8, 2026.

Source: openchamber/openchamber on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.