Answer: Add the variables to a saved local environment and start your sessions from it: select Environment variables, enter one KEY=value per line, and select Done, then save the environment. Only sessions you start from that environment get the variables. Status: Confirmed Entry: tool/claude-code/settings/local-session-env-vars Revision: 5 Digest: sha256:bbe7b47d327e6daf (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:04Z Last changed: 2026-11-20T12:20:26Z (all local sessions: — → ~/.claude/settings.json) Last verified: 2026-11-20T12:20:26Z Next check: 2026-11-21T12:20:26Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of method | Add the variables to a saved local environment and start your sessions from it. | [1] | 2026-11-20 variable format | KEY=value | [1] | 2026-11-20 scope | Only sessions you start from that environment get the variables. | [1] | 2026-11-20 all local sessions | ~/.claude/settings.json | [1] | 2026-11-20 Sources: [1] Anthropic. "Desktop application". https://code.claude.com/docs/en/desktop.md Role: primary. Accessed: 2026-11-20T12:20:26Z Quote: "Add the variables to a saved local environment and start your sessions from it." (Supports: method) Quote: "enter one `KEY=value` per line, and select **Done**" (Supports: variable format) Quote: "Only sessions you start from that environment get the variables." (Supports: scope) Quote: "add it to the [`env` key](https://code.claude.com/docs/en/env-vars#set-variables-in-settings-files) in your `~/.claude/settings.json` file" (Supports: all local sessions) Published: 2026-11-20T10:36:05Z Snapshot SHA-256: e4838a434650f8e38817f67cddb3c612aa44f433f37a880b8bd664b65bf1508d (captured 2026-11-20T12:20:24Z) 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:20:26Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:20:26Z Last attempt: 2026-11-20T12:20:26Z Notes and limitations: Extracted automatically from a single official source (section "Set environment variables for local sessions"). Related: https://latestn.com/tool/claude-code/settings/lsp-recommendation-dialog How do I accept or dismiss the LSP plugin recommendation dialog in Claude Code? https://latestn.com/tool/claude-code/settings/marketplace-source-fields-by-type Which marketplace source fields are valid for each source type in Claude Code? https://latestn.com/tool/claude-code/settings/mcp-config-location Where does Claude Code save MCP server configuration on disk? https://latestn.com/tool/claude-code/settings/inspect-effective-config How do I inspect the defaults and my effective auto mode config in Claude Code? https://latestn.com/tool/claude-code/settings/list-of-env-vars Which environment variables does Claude Code read to control model selection, authentication, and request routing? https://latestn.com/tool/claude-code/settings/load-plugin-every-session How do I make a Claude Code plugin load in every session? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:20:26Z | changed | all local sessions: — → ~/.claude/settings.json | [1] 2026-11-20T12:20:26Z | changed | scope: — → Only sessions you start from that environment get the variables. | [1] 2026-11-20T12:20:26Z | changed | variable format: — → KEY=value | [1] 2026-11-20T12:20:26Z | changed | method: — → Add the variables to a saved local environment and start your sessions from it. | [1] 2026-11-20T12:20:26Z | changed | All local sessions option: ~/.claude/settings.json → — | [1] 2026-11-20T12:20:26Z | changed | Scope: Only sessions you start from that environment get the variables. → — | [1] 2026-11-20T12:20:26Z | changed | Variable format: KEY=value → — | [1] 2026-11-20T12:20:26Z | changed | Method: Add the variables to a saved local environment and start your sessions from it. → — | [1] 2026-11-18T12:15:56Z | changed | All local sessions option: — → ~/.claude/settings.json | [1] 2026-11-18T12:15:56Z | changed | All local sessions alternative: ~/.claude/settings.json → — | [1] 2026-11-17T12:25:27Z | changed | All local sessions alternative: — → ~/.claude/settings.json | [1] 2026-11-17T12:25:27Z | changed | All local sessions option: ~/.claude/settings.json → — | [1] 2026-11-14T12:16:11Z | changed | All local sessions option: — → ~/.claude/settings.json | [1] 2026-11-14T12:16:11Z | changed | Scope: — → Only sessions you start from that environment get the variables. | [1] 2026-11-14T12:16:11Z | changed | Variable format: — → KEY=value | [1] 2026-11-14T12:16:11Z | changed | Method: — → Add the variables to a saved local environment and start your sessions from it. | [1] 2026-11-14T12:16:11Z | changed | all local sessions option: ~/.claude/settings.json → — | [1] 2026-11-14T12:16:11Z | changed | scope: Only sessions you start from that environment get the variables → — | [1] 2026-11-14T12:16:11Z | changed | variable format: KEY=value → — | [1] 2026-11-14T12:16:11Z | changed | method: Add the variables to a saved local environment and start your sessions from it → — | [1] 2026-11-13T03:04:04Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/settings/local-session-env-vars/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/settings/local-session-env-vars POST: https://latestn.com/dispute/tool/claude-code/settings/local-session-env-vars with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/settings/local-session-env-vars?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I set environment variables for local sessions in Claude Code Desktop? Revision 5, last verified 2026-11-20T12:20:26Z. https://latestn.com/tool/claude-code/settings/local-session-env-vars (accessed 2026-11-21T09:55:06Z). @misc{LatestN_tool_claude_code_settings_local_session_env_vars_r5, title = {How do I set environment variables for local sessions in Claude Code Desktop?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/settings/local-session-env-vars}}, note = {Revision 5; digest sha256:bbe7b47d327e6daf; last verified 2026-11-20T12:20:26Z; accessed 2026-11-21T09:55:06Z} } 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/settings/local-session-env-vars