{"version":"2.1.281","anchor":"plugin-state-store-for-the-hooks-module-runtime-stateget","canonical_anchor":"plugin-state-store-for-the-hooks-module-runtime-stateget","heading":"Plugin hook modules get a shared state store: $.state.get and $.state.set","tier":"use","area":"Plugins","url":"https:\/\/changelogs.core-directive.com\/v\/2.1.281\/e\/plugin-state-store-for-the-hooks-module-runtime-stateget","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.281","markdown":"### Plugin hook modules get a shared state store: $.state.get and $.state.set\n\nPlugin hook modules can read and write shared, versioned values with $.state.get and $.state.set, under static and runtime checks\n\n**What**\n\nPlugins can ship hook modules, small pieces of code Claude Code runs at set moments, including to draw plugin UI. These modules now have a shared key\/value store.\n\n- `$.state.get` and `$.state.set` take a reference `{ plugin, key, id? }`. A write can pass `ifVersion` so it only succeeds if the value has not changed since it was read.\n\n- Values must be JSON and stay under the same size limit as `store.set`.\n\n- Only the plugin that owns a key may write it, and writes are refused while `ui.render` is running.\n\n- Readers set up during rendering are refreshed when a value changes, and each write marks \"steady\" and \"live\" timestamps.\n\n- A handler cannot change the reference, `ifVersion` or the previous value.\n\n- `state.get` and `state.set` join the host's list of allowed calls, next to `store.*` and `clock.*`.\n\n- A static check (one that reads the code without running it) requires `plugin` and `key` to be string literals or file-level constants, reports an object literal there, and lists each module's state reads and writes.\n\n- At run time the host refuses a call whose plugin and key pair was not found by that scan.\n\n- Plugin validation reads `interface PluginState` from the plugin's types contract, reports modules that write another plugin's state and keys missing from the contract, and lists state owned by plugins that are not enabled as not checked.\n\n**Why**\n\nPlugin UI modules can share state that updates across render hooks. Plugin authors who build state keys at run time will get a refusal and need to write them as fixed strings.\n\n- Area: Plugins\n- Tier: Use it now\n- Useful: 5\/5\n- Signal: 3\/5"}