AgentKit
ReferenceCLI commands
BetaYou are reading docs for the beta channel (2.4.1-beta.1) — updated automatically on every beta release.Switch to stable →

CLI commands

ak backups prune

Delete snapshots older than a threshold or beyond a retention count

Delete snapshots that are NOT retained by the policy. A snapshot is RETAINED when it is among the --keep-last newest OR younger than --older-than (whichever is more protective). When neither flag is set the command is a no-op.

Who it's for: Power devs reclaiming disk; ops scripts.

When to use it: Periodic cleanup; before a major upgrade to drop ancient state.

What changes on disk: Removes ~/.agentkit/backups/<id>/ trees that fall outside the retention window.

Usage

ak backups prune [flags]

Examples

ak backups prune --older-than 30d                   # delete snapshots > 30 days old
ak backups prune --keep-last 5                      # retain the 5 newest
ak backups prune --older-than 7d --keep-last 3      # both rules apply (most protective wins)
ak backups prune --older-than 30d --dry-run         # preview deletion plan

Flags

FlagDescription
--dry-runPrint the deletion plan without removing anything
-h, --helphelp for prune
--jsonEmit machine-readable JSON (implies --no-interactive)
--keep-last intRetain the N newest snapshots
--no-interactiveDisable interactive prompts (CI-safe)
--older-than stringDelete snapshots older than this duration (e.g. 30d, 168h, 90d)
-q, --quietSuppress non-error output on stderr
-V, --verboseExtra diagnostic output on stderr (loses to --quiet)
-y, --yesAssume yes for all prompts

Output modes

ModeBehavior
prettydefault on TTY (colors, ASCII markers)
plainauto when stdout piped or --no-interactive
json--json (single-object envelope, NDJSON-safe)

Exit codes

CodeMeaning
0success
1runtime error
2invalid flags
3user-cancel (SIGINT, prompt-cancel)
2invalid --older-than duration
4another ak backups operation already holds the lock

On this page