enforce-rules-for-pinia-synced
moeru-ai/airi/.agents/skills/enforce-rules-for-pinia-synced/SKILL.md
Enforce AIRI's rules for Pinia stores that use pinia-plugin-synced for cross-window synchronization. Use when adding `synced` to a Pinia store, changing a synced store's state or actions, or writing watchers, persistence, or tests for synchronized state in AIRI renderers.
Skill50k starsChanged 3 days ago
What's in it
- Enforce AIRI Pinia Synchronization Rules
- Synchronization Model
- Watchers and Invariants
- Actions
- Persistence and Leadership
- Tests
--- name: enforce-rules-for-pinia-synced description: Enforce AIRI's rules for Pinia stores that use pinia-plugin-synced for cross-window synchronization. Use when adding `synced` to a Pinia store, changing a synced store's state or actions, or writing watchers, persistence, or tests for synchronized state in AIRI renderers. --- # Enforce AIRI Pinia Synchronization Rules Apply these rules to every Pinia store that uses `pinia-plugin-synced`. ## Synchronization Model - Treat `pinia-plugin-synced` as snapshot replication and leader-routed RPC. It does not share Vue refs between renderers. - Add `synced` only to stores that need cross-window ownership. Synchronize the smallest serializable source-of-truth state. - `state: true` sends a full-store proposal after each local mutation. Keep transient and high-frequency state in an unsynchronized store. - State, action arguments, and action results must support `structuredClone`. - Keep computed values, query status, runtime clients, controllers, pending promises, and component state outside synchronized state. ## Watchers and Invariants - Remote snapshots run local Vue watchers. A watcher on synchronized state must not write synchronized state directly. - A watcher can call a synchronized action to enforce a leader-owned invariant. The watcher must await the action. The action must be idempotent because each renderer can observe the same snapshot. - Enforce cross-field invariants inside explicit actions before the state commit. Do not repair replicated state with a watcher. ## Actions - Every returned function in a setup store is a Pinia action. Use computed values or pure helpers for read-only projections. - List only leader-owned side-effecting actions under `synced.actions`. These actions must be asynchronous, and callers must await them. - Unlisted actions run in the caller renderer. Their mutations become full-state proposals when `state: true`. ## Persistence and Leadership - Keep synchronization and persistence as separate boundaries. Give persisted synchronized state one explicit persistence owner. - Do not add bidirectional persistence composables or storage-event listeners to synchronized state. Use explicit persistence commands. - Set the leadership mode explicitly for every Electron renderer. Utility and minimal windows must use `follower-only`. ## Tests - Add a multi-window regression test for synchronization changes. A remote snapshot must not produce a local synchronized-state proposal. - If a watcher calls a synchronized action, verify that repeated calls converge without repeated side effects.
More agent context in moeru-ai/airi
36 other files this repository gives its agents.
AGENTS.md
CLAUDE.md
Copilot instructions
Skill
- agent-browser-electron.agents/skills/agent-browser-electron/SKILL.md
- agent-browser.agents/skills/agent-browser/SKILL.md
- analyze-io-traces.agents/skills/analyze-io-traces/SKILL.md
- create-pr.agents/skills/create-pr/SKILL.md
- enforce-rules-for-i18n.agents/skills/enforce-rules-for-i18n/SKILL.md
- enforce-rules-for-typescript.agents/skills/enforce-rules-for-typescript/SKILL.md
- enforce-rules-for-unocss.agents/skills/enforce-rules-for-unocss/SKILL.md
- enforce-rules-for-vitest.agents/skills/enforce-rules-for-vitest/SKILL.md
- eventa.agents/skills/eventa/SKILL.md
- pinia.agents/skills/pinia/SKILL.md
- pnpm.agents/skills/pnpm/SKILL.md
- release-note-writer.agents/skills/release-note-writer/SKILL.md
- simple-english.agents/skills/simple-english/SKILL.md
- stage-tamagotchi-godot-csharp.agents/skills/stage-tamagotchi-godot-csharp/SKILL.md
- tsdown.agents/skills/tsdown/SKILL.md
- unocss.agents/skills/unocss/SKILL.md
- upload-github-attachment.agents/skills/upload-github-attachment/SKILL.md
- use-agent-browser-for-airi.agents/skills/use-agent-browser-for-airi/SKILL.md
- use-agent-browser-with-input-file.agents/skills/use-agent-browser-with-input-file/SKILL.md
- use-vishot-for-airi.agents/skills/use-vishot-for-airi/SKILL.md
- use-vishot.agents/skills/use-vishot/SKILL.md
- use-vishot-with-capacitor.agents/skills/use-vishot-with-capacitor/SKILL.md
- use-vishot-with-electron.agents/skills/use-vishot-with-electron/SKILL.md
- use-vishot-with-input-file.agents/skills/use-vishot-with-input-file/SKILL.md
- use-vishot-with-web.agents/skills/use-vishot-with-web/SKILL.md
- vue-best-practices.agents/skills/vue-best-practices/SKILL.md
- vue.agents/skills/vue/SKILL.md
- vue-testing-best-practices.agents/skills/vue-testing-best-practices/SKILL.md
- vueuse-functions.agents/skills/vueuse-functions/SKILL.md
- web-design-guidelines.agents/skills/web-design-guidelines/SKILL.md
- xsai.agents/skills/xsai/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

