Context
Claude Code's cleanupPeriodDays setting drives a background retention sweep. Per the changelog, the sweep now covers:
~/.claude/projects/ — conversation history / transcripts (long-standing behaviour)
- tool result files
~/.claude/tasks/ (added recently)
~/.claude/shell-snapshots/ (added recently)
~/.claude/backups/ (added recently)
Defaults and quirks worth noting:
- Default horizon is 30 days.
cleanupPeriodDays: 0 is now rejected with a validation error (previously silently disabled transcript persistence).
--setting-sources without user previously caused the sweep to ignore the configured value; fixed.
PAI does not currently set cleanupPeriodDays anywhere in ~/.pai/ or ~/.claude/settings*.json (checked 2026-04-22), so it inherits the default 30-day sweep.
Why review now
PAI's MEMORY/LEARNING/ pipeline (FAILURES/, REFLECTIONS/, SIGNALS/, mine-output.md, review.md) depends on session artefacts that originate under ~/.claude/projects/. If the retention sweep deletes a transcript before the learning pipeline consumes or copies it, signals and failure analyses are lost silently. The new dirs added to the sweep (tasks/, shell-snapshots/, backups/) may also contain data PAI hooks touch.
What to review
- Dependency audit: enumerate every PAI hook, skill, or script that reads from
~/.claude/projects/, ~/.claude/tasks/, ~/.claude/shell-snapshots/, or ~/.claude/backups/. For each, determine whether it consumes within a predictable window or assumes indefinite retention.
- Consumption horizon: what is the longest delay between a Claude Code session ending and a PAI pipeline consuming its artefacts? (E.g. monthly
review.md synthesis may reach back further than the default 30 days.)
- Archive vs sweep: should PAI's learning pipeline copy any required session data into
~/.pai/MEMORY/ at end-of-session (hook) so it is independent of Claude Code's sweep, rather than depending on live ~/.claude/projects/ files?
- Recommended value: pick one of —
- Leave default (30d), rely on end-of-session archival hooks for anything PAI needs beyond that horizon.
- Ship PAI with an explicit higher value (e.g. 90d) in a PAI-managed
settings.json fragment.
- Make it user-configurable with a documented recommendation and guard-rails.
- Interaction with
--setting-sources: PAI loads rules at startup (loadAtStartup). Verify the current Claude Code CLI respects cleanupPeriodDays in whichever settings source PAI writes to; do not rely on the prior bug being the only issue.
Decision criteria
- If any PAI pipeline assumes retention beyond 30 days without making its own copy, the current default is a silent data-loss risk — raise the value and add an archival hook.
- If all PAI consumption happens within the default window, leaving the value alone is correct — do not over-configure.
- Archival hook is preferred over raising retention, because raised retention is a user-disk-space cost PAI shouldn't impose without cause.
Deliverable
- Audit output: a short table of PAI →
~/.claude/ directory dependencies with consumption windows.
- A decision: change default, add archival hook, or document current behaviour as sufficient.
- If config change: a proposed
settings.json fragment with rationale.
- If archival hook: a hook script plus where it plugs into PAI (likely an end-of-session hook).
Out of scope
- Replacing Claude Code's sweep with a PAI-owned sweep.
- Broader review of
~/.claude/ directory layout (track separately if wanted).
Context
Claude Code's
cleanupPeriodDayssetting drives a background retention sweep. Per the changelog, the sweep now covers:~/.claude/projects/— conversation history / transcripts (long-standing behaviour)~/.claude/tasks/(added recently)~/.claude/shell-snapshots/(added recently)~/.claude/backups/(added recently)Defaults and quirks worth noting:
cleanupPeriodDays: 0is now rejected with a validation error (previously silently disabled transcript persistence).--setting-sourceswithoutuserpreviously caused the sweep to ignore the configured value; fixed.PAI does not currently set
cleanupPeriodDaysanywhere in~/.pai/or~/.claude/settings*.json(checked 2026-04-22), so it inherits the default 30-day sweep.Why review now
PAI's
MEMORY/LEARNING/pipeline (FAILURES/, REFLECTIONS/, SIGNALS/, mine-output.md, review.md) depends on session artefacts that originate under~/.claude/projects/. If the retention sweep deletes a transcript before the learning pipeline consumes or copies it, signals and failure analyses are lost silently. The new dirs added to the sweep (tasks/,shell-snapshots/,backups/) may also contain data PAI hooks touch.What to review
~/.claude/projects/,~/.claude/tasks/,~/.claude/shell-snapshots/, or~/.claude/backups/. For each, determine whether it consumes within a predictable window or assumes indefinite retention.review.mdsynthesis may reach back further than the default 30 days.)~/.pai/MEMORY/at end-of-session (hook) so it is independent of Claude Code's sweep, rather than depending on live~/.claude/projects/files?settings.jsonfragment.--setting-sources: PAI loads rules at startup (loadAtStartup). Verify the current Claude Code CLI respectscleanupPeriodDaysin whichever settings source PAI writes to; do not rely on the prior bug being the only issue.Decision criteria
Deliverable
~/.claude/directory dependencies with consumption windows.settings.jsonfragment with rationale.Out of scope
~/.claude/directory layout (track separately if wanted).