# Retention

> Change how old snapshots are pruned (age, count, size, pinned/labelled protection). Use when the library grows without bound or a named snapshot disappeared.

- Skill: `hoangsonww/retention` (Agent Skill)
- Install (CLI): `npx skillmds@latest add hoangsonww/retention`
- Raw SKILL.md: https://api.skillmd.com/api/skills/hoangsonww/retention/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: hoangsonww (https://skillmd.com/u/hoangsonww)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/hoangsonww/retention

---


# Retention

`RetentionPlanner.plan` is pure over `[SnapshotSummary]`. Preview in UI must use the same function the store executes.

- Newest snapshot is **never** deleted. Without it there is nothing to compare against.
- Default policy: 90 days, 1 GiB, protects pinned and labelled snapshots.
- Empty labels are not protection. `protectsLabelled` / `protectsPinned` can be turned off.
- Protected snapshots do not consume the count/size quota.
- Age is applied before count/size so the reason stays `tooOld` when both apply.
- `SnapshotService.capture` runs retention **after** save so the new snapshot always survives a tight limit.

Tests: `Tests/Domain/RetentionPlannerTests.swift` and retention invariants.

