[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M782CBFRVHCK44ZZPAV06VQM":3,"skill-same:01M782CBFRVHCK44ZZPAV06VQM":55},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":6,"ownerHtmlUrl":37,"ownerBlogUrl":38,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M782CBFRVHCK44ZZPAV06VQM","persist",null,"Core @stainless-code\u002Fpersist concepts — persistSource, PersistOptions, PersistApi, hydration gate, throttle, cross-tab, migrate. Load before framework hydration skills or when wiring a custom PersistableSource.","stainless-code\u002Fpersist","stainless-code","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F188862219?v=4","01M7826VYMCF2NTQWQZRWQ454T","STAINLESS CODE","01M7826VZKNC149Y9ZNK0F93N7",5,"MIT","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fpersist\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: persist\ndescription: Core @stainless-code\u002Fpersist concepts — persistSource, PersistOptions, PersistApi, hydration gate, throttle, cross-tab, migrate. Load before framework hydration skills or when wiring a custom PersistableSource.\nlicense: MIT\nmetadata:\n  type: core\n  library: \"@stainless-code\u002Fpersist\"\n  library_version: \"0.4.1\"\nsources:\n  - stainless-code\u002Fpersist:src\u002Fcore\u002Fpersist-core.ts\n  - stainless-code\u002Fpersist:docs\u002Farchitecture.md\n  - stainless-code\u002Fpersist:README.md\n---\n\n# Persist\n\nZero-dep `persistSource(source, options)` owns hydrate → subscribe → write. First-party `.\u002Fsources\u002F*` adapters map library APIs onto `PersistableSource` (`getState` \u002F `setState` \u002F `subscribe`) and may add opinions (default `merge`, reducer wraps, assign vs `$patch`).\n\n## When to use this skill\n\n- Custom store shape (no `persist-*` adapter).\n- Shared Options \u002F `PersistApi` semantics across adapters.\n- Before `react-persist` (and other framework hydration skills).\n\nLibrary-specific wiring → the matching `persist-*` composition skill.\n\n## Minimal custom source\n\n```ts\nimport { createJSONStorage, persistSource } from \"@stainless-code\u002Fpersist\";\n\nconst persist = persistSource(\n  {\n    getState: () => state,\n    setState: (updater) => {\n      state = updater(state);\n    },\n    subscribe: (listener) => {\n      listeners.add(listener);\n      return { unsubscribe: () => listeners.delete(listener) };\n    },\n  },\n  {\n    name: \"app:custom:v1\",\n    storage: createJSONStorage(() => localStorage),\n  },\n);\n```\n\n## Contracts agents must not invent\n\n- **Hydration write gate** — `setState` before hydrate settles does not clobber storage. Don't double-gate manually.\n- **`throttleMs`** — trailing-only; first write waits out the window. `destroy()` flushes pending writes.\n- **`maxAge`** — opt-in; prefs should not silently expire.\n- **`instanceof Promise`** on reads — not thenable duck-typing.\n- **`PersistDecodeRethrowError`** — decode errors that must rethrow \u002F skip `clearCorrupt` (e.g. wrong sync\u002Fasync schema lane).\n- **`migrate`** — called once with `(state, fromVersion)`; multi-step chains → `createMigrationChain`.\n- **Teardown** — `persist.destroy()` for non-singleton lifetimes.\n\n## `PersistApi` (keep the reference)\n\n`rehydrate()`, `hasHydrated()`, `onHydrate`, `onFinishHydration`, `setOptions`, `clearStorage`, `getOptions`, `destroy`.\n\n## Hydration signal for UI\n\n```ts\nimport { toHydrationSignal } from \"@stainless-code\u002Fpersist\";\n\nexport const hydration = toHydrationSignal(persist);\n\u002F\u002F frameworks\u002Freact → useHydrated(hydration) — see react-persist\n```\n\n## Backend × codec (short)\n\n| State              | Backend        | Helper \u002F codec      |\n| ------------------ | -------------- | ------------------- |\n| JSON-able          | `localStorage` | `createJSONStorage` |\n| `Set`\u002F`Map`\u002F`Date` | `localStorage` | seroval codec       |\n| Structured clone   | IndexedDB      | `identityCodec`     |\n\nSee also: `persist-*` for sources \u002F codecs \u002F backends \u002F transport; `*-persist` for UI frameworks.\n","# Persist\n\nZero-dep `persistSource(source, options)` owns hydrate → subscribe → write. First-party `.\u002Fsources\u002F*` adapters map library APIs onto `PersistableSource` (`getState` \u002F `setState` \u002F `subscribe`) and may add opinions (default `merge`, reducer wraps, assign vs `$patch`).\n\n## When to use this skill\n\n- Custom store shape (no `persist-*` adapter).\n- Shared Options \u002F `PersistApi` semantics across adapters.\n- Before `react-persist` (and other framework hydration skills).\n\nLibrary-specific wiring → the matching `persist-*` composition skill.\n\n## Minimal custom source\n\n```ts\nimport { createJSONStorage, persistSource } from \"@stainless-code\u002Fpersist\";\n\nconst persist = persistSource(\n  {\n    getState: () => state,\n    setState: (updater) => {\n      state = updater(state);\n    },\n    subscribe: (listener) => {\n      listeners.add(listener);\n      return { unsubscribe: () => listeners.delete(listener) };\n    },\n  },\n  {\n    name: \"app:custom:v1\",\n    storage: createJSONStorage(() => localStorage),\n  },\n);\n```\n\n## Contracts agents must not invent\n\n- **Hydration write gate** — `setState` before hydrate settles does not clobber storage. Don't double-gate manually.\n- **`throttleMs`** — trailing-only; first write waits out the window. `destroy()` flushes pending writes.\n- **`maxAge`** — opt-in; prefs should not silently expire.\n- **`instanceof Promise`** on reads — not thenable duck-typing.\n- **`PersistDecodeRethrowError`** — decode errors that must rethrow \u002F skip `clearCorrupt` (e.g. wrong sync\u002Fasync schema lane).\n- **`migrate`** — called once with `(state, fromVersion)`; multi-step chains → `createMigrationChain`.\n- **Teardown** — `persist.destroy()` for non-singleton lifetimes.\n\n## `PersistApi` (keep the reference)\n\n`rehydrate()`, `hasHydrated()`, `onHydrate`, `onFinishHydration`, `setOptions`, `clearStorage`, `getOptions`, `destroy`.\n\n## Hydration signal for UI\n\n```ts\nimport { toHydrationSignal } from \"@stainless-code\u002Fpersist\";\n\nexport const hydration = toHydrationSignal(persist);\n\u002F\u002F frameworks\u002Freact → useHydrated(hydration) — see react-persist\n```\n\n## Backend × codec (short)\n\n| State              | Backend        | Helper \u002F codec      |\n| ------------------ | -------------- | ------------------- |\n| JSON-able          | `localStorage` | `createJSONStorage` |\n| `Set`\u002F`Map`\u002F`Date` | `localStorage` | seroval codec       |\n| Structured clone   | IndexedDB      | `identityCodec`     |\n\nSee also: `persist-*` for sources \u002F codecs \u002F backends \u002F transport; `*-persist` for UI frameworks.\n",{"name":5,"license":15,"sources":24,"metadata":28,"description":7},[25,26,27],"stainless-code\u002Fpersist:src\u002Fcore\u002Fpersist-core.ts","stainless-code\u002Fpersist:docs\u002Farchitecture.md","stainless-code\u002Fpersist:README.md",{"type":29,"library":30,"library_version":31},"core","@stainless-code\u002Fpersist","0.4.1","main","29ca2183c92cd13e04ce6c14fb431fd6993862cd","skills\u002Fpersist",0,"https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist","https:\u002F\u002Fgithub.com\u002Fstainless-code","https:\u002F\u002Fstainless-code.com\u002F","Open-source tooling for JS\u002FTS and AI agents.","2026-11-01 20:56:20",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add stainless-code\u002Fpersist --skill persist",{"tool":47,"command":48},"bunx","bunx skills add stainless-code\u002Fpersist --skill persist",{"tool":50,"command":51},"pnpm","pnpm dlx skills add stainless-code\u002Fpersist --skill persist","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fpersist\u002FSKILL.md",true,[],[56,63,70,77,84,91],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M782D4ZQGJPNT470FSKDB6A8","vue-persist","Gate Vue 3 UI on Persist hydration with useHydrated (shallowRef). Use in setup\u002FeffectScope when avoiding flash of default state on async backends.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fvue-persist\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M782D1GJRWNQ3458F3H1FK2F","svelte-store-persist","Gate Svelte store-based UI on Persist hydration with hydratedStore (Readable). Use for Svelte 3–4 or Svelte 5 apps that still use stores; runes UI → svelte-persist.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fsvelte-store-persist\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M782CWBTRWAQ52TBNQ8665CC","svelte-persist","Gate Svelte 5 runes UI on Persist hydration with hydratedRune (.current). Use for Svelte 5; for stores \u002F Svelte 3–4 use svelte-store-persist.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fsvelte-persist\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M782CR8Z2V3SJW661RTMWY2F","solid-persist","Gate Solid UI on Persist hydration with useHydrated (Accessor). Use when avoiding flash of default state on async backends; read hydrated() in reactive scopes.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fsolid-persist\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M782CJQGP7739WA9BS801HZP","react-persist","Gate React UI on Persist hydration with useHydrated + toHydrationSignal. Use when avoiding flash of default state on async backends (IndexedDB), SSR snapshot true, or wiring HydrationSignal into React 18\u002F19.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Freact-persist\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M782CF96RMXCDETM5TF2JDRV","preact-persist","Gate Preact UI on Persist hydration with useHydrated (preact\u002Fcompat useSyncExternalStore). Use when avoiding flash of default state on async backends or wiring HydrationSignal into Preact.","https:\u002F\u002Fgithub.com\u002Fstainless-code\u002Fpersist\u002Fblob\u002Fmain\u002Fskills\u002Fpreact-persist\u002FSKILL.md",[],[]]