# Claude Code deletes local coding sessions after 30 days

Digest AI · Agents & Tools · published 2026-11-02T19:10:38Z

Canonical: https://digestai.news/story/claude-code-deletes-local-coding-sessions-after-30-days

## Summary

Coding agent session histories contain valuable data on failed attempts, cost drivers, and correction patterns, but they are often ephemeral. The author argues that these transcripts are essential for debugging agent behavior and auditing billing, yet they face automatic deletion. Claude Code’s default settings remove local session records older than 30 days, including tool calls and results. If this is the only copy, the history is permanently lost.

The article highlights specific cases where session data revealed issues that metrics alone missed. For instance, a benchmark attempt cost 9x more than baseline due to a plugin rewriting commands, a detail only visible in the trajectory. Similarly, LangChain improved its agent’s pass rate from 52.8% to 66.5% by analyzing session logs to fix repeated failures. The author also notes that forgotten model configurations, such as using an older model version, can skew usage data and costs.

To prevent data loss, the author recommends backing up session files to off-device storage. For Claude Code users, changing the `cleanupPeriodDays` setting to 365 in `settings.json` can extend retention, though independent backups are still necessary to guard against accidental deletion or hardware failure. The post includes specific file paths for macOS, Linux, and Windows to help users locate and secure these records.

## Key points

- Claude Code automatically deletes local session files older than 30 days by default.
- Session transcripts reveal cost drivers and failure patterns that final diffs hide.
- Users can extend Claude Code retention to 365 days via settings.json.

## Why it matters

Preserving agent session data allows developers to debug costly failures, verify billing accuracy, and improve agent instructions. Without backups, critical insights into AI behavior are lost due to automatic cleanup policies.

## Sources

1. [Your agentic coding sessions are a treasure](https://kotrys.dev/blog/your-agent-trajectories-are-a-treasure) (kotrys.dev, 2026-11-02)

## Cite

Digest AI, "Claude Code deletes local coding sessions after 30 days", 2 November 2026, https://digestai.news/story/claude-code-deletes-local-coding-sessions-after-30-days

---

Written by Digest AI's editorial model from the linked sources; the sources are the record. Headlines, digests and key points are written by Digest AI and may be quoted with a link to the story page. Linked articles belong to their publishers. Terms: https://digestai.news/terms#reuse
JSON: https://digestai.news/story/claude-code-deletes-local-coding-sessions-after-30-days.json
