[
    {
        "role": "user",
        "content": "when%20i%20run%20claude%20code%2C%20i%20can%20use%20--name%20session-name%20to%20name%20a%20session%20and%20later%20claude%20--resume%20session-name.%20how%20long%20is%20the%20session%20context%20maintained%3F%20is%20it%20deleted%20after%20some%20period%20of%20time%3F"
    },
    {
        "role": "assistant",
        "content": "Here\u2019s what I found about how \u201cnamed + resumed\u201d sessions in **Claude Code** work \u2014 how long the context lasts, whether it's automatically deleted, and what kinds of time or storage limits you should know:\n\n---\n\n## What \u201cSessions\u201d Mean in Claude Code\n\n- A session captures your full conversation: prompts, responses, tool results, and the working directory.   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-session-management-resume-guide?utm_source=openai))  \n- Sessions are saved locally on your machine unless you\u2019re using a web session (in which case some data is stored by Anthropic under different rules).   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-session-management-resume-guide?utm_source=openai))  \n\nThat means when you do `claude --name session-name` and later `claude --resume session-name`, you\u2019re restoring that full local state \u2014 not just restarting, but continuing from where you left off.   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-session-management-resume-guide?utm_source=openai))\n\n---\n\n## How Long Context is Maintained\n\n### Locally\n\n- **Sessions persist indefinitely** on your machine unless you explicitly delete them.   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-session-management-resume-guide?utm_source=openai))  \n- Anthropic uses files in directories like `~/.claude/sessions/` to store these session transcripts and metadata.   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-session-management-resume-guide?utm_source=openai))  \n\n### In Cloud / Web Mode\n\n- For sessions that run through Anthropic\u2019s hosted infrastructure, **data retention depends on your account type and privacy settings**.   ([code.claude.com](https://code.claude.com/docs/en/data-usage?utm_source=openai))  \n- For free, pro, or max users:\n\n  \u2022 If you allow Anthropic to use your data for model improvement, session data may be kept up to *5 years*.  \n  \u2022 If you *opt out*, it may only be retained for *30 days*.   ([code.claude.com](https://code.claude.com/docs/en/data-usage?utm_source=openai))  \n\n- For commercial accounts (Teams, Enterprise, API users):\n\n  \u2022 Standard retention is about *30 days*.  \n  \u2022 Zero-data-retention (ZDR) options exist, depending on organization-level settings.   ([code.claude.com](https://code.claude.com/docs/en/data-usage?utm_source=openai))  \n\n---\n\n## Automatic Deletion? Timeout?\n\n- **No automatic deletion** based purely on time for local sessions \u2014 they stay until you delete them.   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-session-management-resume-guide?utm_source=openai))  \n- There is no hard time-of-day or clock-time cutoff for the session in normal CLI use: so a session can cover many days if you keep coming back to it.  \n\n- However, there *are* limits in other dimensions:\n\n  1. **Token / Context Window Limits:**  \n     Claude Code sessions have large but finite context windows. As context grows, performance can degrade (actions become \u201cnoisier\u201d, earlier prompts lose influence) and Anthropic provides tools for \u201ccompacting\u201d or summarizing old history to manage this.   ([claudelab.net](https://claudelab.net/en/articles/claude-code/claude-code-long-session-context-integrity?utm_source=openai))  \n\n  2. **Usage or Model Limits:**  \n     Your plan might impose quotas or usage caps (e.g. how many messages or tokens you can process), and exceeding those can limit how much you can continue doing within a session.   ([support.anthropic.com](https://support.anthropic.com/en/articles/11647753-understanding-usage-and-length-limits?utm_source=openai))  \n\n---\n\n## Key Mechanics / Tools That Affect How Durable Context Really Is\n\n- **/compact** \u2014 Summarizes older conversation history to make room in the context window, preserving important parts but losing some detail.   ([sitepoint.com](https://www.sitepoint.com/claude-code-context-management/?utm_source=openai))  \n- **CLAUDE.md** \u2014 A markdown file at project root (or elsewhere) that holds persistent instructions, conventions, etc. This gets loaded into context at the start of every session, and its content *survives* session resets, compactions, and even restarts.   ([sitepoint.com](https://www.sitepoint.com/claude-code-context-management/?utm_source=openai))  \n- **Auto memory** \u2014 Claude remembers patterns, preferences, etc., across sessions; but this is limited (e.g. first ~200 lines or ~25KB of memory content) to avoid bloating context.   ([code.claude.com](https://code.claude.com/docs/en/memory?utm_source=openai))  \n\n---\n\n## Practical Summary\n\n- If you're using Claude Code on your local machine with named sessions, context lasts *until you delete the session*.  \n- If using web/cloud-based sessions, retention depends on your settings and plan: up to years in some cases, or as short as 30 days.  \n- Even without deletion, long sessions degrade in performance due to token/context window limits. Using `--resume` works across days, weeks, etc., but effectiveness depends on how much context (and how clean) remains.  \n- The CLAUDE.md and auto memory systems help preserve crucial project context across sessions even if conversations get compacted.\n\n---\n\nIf you tell me which plan you\u2019re on (Free / Pro / Team / Enterprise), I can check what *your specific limits* are. Want me to pull those up for you?"
    }
]