Answer: To keep a value in `$.state` across redraws and sessions, declare it in a type declaration file, point the manifest at that declaration with a `types` field, then define it with `atom`, read it with `read`, and write it with `update`. A value in `$.state` survives a module reload and lasts until the session ends or the user runs `/clear`, `/resume`, or `/branch`. Status: Confirmed Entry: tool/claude-code/features/keep-state-in-mod Revision: 3 Digest: sha256:eec6cce9af2a3f8c (changes whenever the content changes) Timeline: Created: 2026-11-13T12:13:08Z Last changed: 2026-11-20T12:23:44Z (manifest types field: — → "types": "./types/index.d.ts") Last verified: 2026-11-20T12:23:44Z Next check: 2026-11-21T12:23:44Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of state lifetime | The session ends, or the user runs `/clear`, `/resume`, or `/branch` | [1] | 2026-11-20 state purpose | Values a drawing depends on that should survive a reload | [1] | 2026-11-20 store lifetime | Your mod deletes it, or no session reads or writes the store for [`cleanupPeriodDays`] | [1] | 2026-11-20 store location | ~/.claude/plugins/store/ | [1] | 2026-11-20 atom example | const count = atom({ plugin: 'hello-tabs', key: 'count' }, 0) | [1] | 2026-11-20 read example | const n = await read($, count) | [1] | 2026-11-20 update example | onPress: () => update($, count, (value) => value + 1) | [1] | 2026-11-20 manifest types field | "types": "./types/index.d.ts" | [1] | 2026-11-20 Sources: [1] Anthropic. "Draw in the interface with a mod". https://code.claude.com/docs/en/plugins/mods/interface.md Role: primary. Accessed: 2026-11-20T12:23:44Z Quote: "`$.state` | The session ends, or the user runs `/clear`, `/resume`, or `/branch`" (Supports: state lifetime) Quote: "Values a drawing depends on that should survive a reload" (Supports: state purpose) Quote: "`$.store` | Your mod deletes it, or no session reads or writes the store for [`cleanupPeriodDays`]" (Supports: store lifetime) Quote: "saved as a JSON file of your plugin's own under `~/.claude/plugins/store/`" (Supports: store location) Quote: "const count = atom({ plugin: 'hello-tabs', key: 'count' }, 0)" (Supports: atom example) Quote: "const n = await read($, count)" (Supports: read example) Quote: "onPress: () => update($, count, (value) => value + 1)" (Supports: update example) Quote: ""types": "./types/index.d.ts"" (Supports: manifest types field) Published: 2026-11-20T03:28:15Z Snapshot SHA-256: 5203311695590ed2a1ee08b0eba3b73e7b0c47ccb411106942748b7b15260a05 (captured 2026-11-20T12:23:44Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:23:44Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:23:44Z Last attempt: 2026-11-20T12:23:44Z Notes and limitations: Extracted automatically from a single official source (section "Keep state"). Related: https://latestn.com/tool/claude-code/features/mobile-limitations What are the limitations of using Claude Code on mobile? https://latestn.com/tool/claude-code/features/mod-code-diff-element How do I show a code diff in a Claude Code mod interface? https://latestn.com/tool/claude-code/features/mod-image-in-tmux How do I draw an image inside tmux in a Claude Code mod? https://latestn.com/tool/claude-code/features/how-features-layer How do CLAUDE.md, Skills, subagents, hooks, MCP, and plugins layer and combine together in Claude Code? https://latestn.com/tool/claude-code/features/idle-session-notice How do I get a notice in Claude Code when another session goes idle? https://latestn.com/tool/claude-code/features/internal-adoption-playbook How do I get my team to adopt Claude Code internally? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:23:44Z | changed | manifest types field: — → "types": "./types/index.d.ts" | [1] 2026-11-20T12:23:44Z | changed | update example: — → onPress: () => update($, count, (value) => value + 1) | [1] 2026-11-20T12:23:44Z | changed | read example: — → const n = await read($, count) | [1] 2026-11-20T12:23:44Z | changed | atom example: — → const count = atom({ plugin: 'hello-tabs', key: 'count' }, 0) | [1] 2026-11-20T12:23:44Z | changed | store location: — → ~/.claude/plugins/store/ | [1] 2026-11-20T12:23:44Z | changed | store lifetime: — → Your mod deletes it, or no session reads or writes the store for [`cleanupPeriodDays`] | [1] 2026-11-20T12:23:44Z | changed | update call: onPress: () => update($, count, (value) => value + 1) → — | [1] 2026-11-20T12:23:44Z | changed | read call: const n = await read($, count) → — | [1] 2026-11-20T12:23:44Z | changed | atom definition: const count = atom({ plugin: 'hello-tabs', key: 'count' }, 0) → — | [1] 2026-11-20T12:23:44Z | changed | manifest field: "types": "./types/index.d.ts" → — | [1] 2026-11-20T12:23:44Z | changed | reload survival: A value in `$.state` also survives a reload of the module, which a variable doesn't. → — | [1] 2026-11-15T12:23:58Z | recovered | Check succeeded again | — 2026-11-15T12:23:58Z | changed | update call: — → onPress: () => update($, count, (value) => value + 1) | [1] 2026-11-15T12:23:58Z | changed | read call: — → const n = await read($, count) | [1] 2026-11-15T12:23:58Z | changed | atom definition: — → const count = atom({ plugin: 'hello-tabs', key: 'count' }, 0) | [1] 2026-11-15T12:23:58Z | changed | manifest field: — → "types": "./types/index.d.ts" | [1] 2026-11-15T12:23:58Z | changed | reload survival: — → A value in `$.state` also survives a reload of the module, which a variable doesn't. | [1] 2026-11-15T12:23:58Z | changed | state purpose: — → Values a drawing depends on that should survive a reload | [1] 2026-11-15T12:23:58Z | changed | store API: `$.store.get(key)` resolves to the value or `undefined`, and `$.store.set(key, value)` takes any JSON value. → — | [1] 2026-11-15T12:23:58Z | changed | reset hook sources: ['clear', 'resume', 'fork'] → — | [1] 2026-11-15T12:23:58Z | changed | store location: ~/.claude/plugins/store/ → — | [1] 2026-11-15T12:23:58Z | changed | store lifetime: Your mod deletes it, or no session reads or writes the store for [`cleanupPeriodDays`] → — | [1] 2026-11-15T12:23:58Z | changed | state survives reload: A value in `$.state` also survives a reload of the module → — | [1] 2026-11-14T12:19:31Z | check-failed | Extraction did not pass verification: answer does not contain any extracted value | — 2026-11-13T12:13:08Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/features/keep-state-in-mod/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/features/keep-state-in-mod POST: https://latestn.com/dispute/tool/claude-code/features/keep-state-in-mod with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/features/keep-state-in-mod?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I keep a value in $.state across redraws and sessions in a Claude Code mod? Revision 3, last verified 2026-11-20T12:23:44Z. https://latestn.com/tool/claude-code/features/keep-state-in-mod (accessed 2026-11-21T09:54:10Z). @misc{LatestN_tool_claude_code_features_keep_state_in_mod_r3, title = {How do I keep a value in $.state across redraws and sessions in a Claude Code mod?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/features/keep-state-in-mod}}, note = {Revision 3; digest sha256:eec6cce9af2a3f8c; last verified 2026-11-20T12:23:44Z; accessed 2026-11-21T09:54:10Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/features/keep-state-in-mod