All articles

Cleaning Up Old Sessions with cleanupPeriodDays

Claude Code keeps a record of your past sessions so you can resume them later. Over time that record grows. The cleanupPeriodDays key lets you decide how long to keep it before Claude clears the old stuff out.

The setting

The value is a number of days.

{
  "cleanupPeriodDays": 30
}

That tells Claude Code to keep session data for 30 days, then tidy away anything older. Set a smaller number to clear things sooner, a larger one to hold history longer.

Picking a number

Think about how far back you actually reach:

  • A short period, like 7 days, keeps things lean if you rarely resume old work.
  • A longer period, like 60 or 90 days, is handy if you often come back to sessions weeks later with /resume.

There's no single right answer — it's a trade between disk tidiness and how much past work you want on hand.

Where to set it

This is usually a personal choice, so your user file, ~/.claude/settings.json, is the natural home. Then it applies across every project.

If a specific project needs a particular retention window — maybe it churns through many short sessions — you can set it in that project's .claude/settings.json instead. As always, the project value overrides your user value when you work in that repo.

A gentle reminder

Once old session data is cleared, sessions past the window are gone, so you can't resume them anymore. If you know you'll want a record of a particular session, export it while it's still around with /export rather than counting on the cleanup window to spare it.

Comments

Be the first to comment.