AgentKit
ReferenceCLI commands

CLI commands

ak backups prune

Delete snapshots older than a threshold or beyond a retention count

ak backups prune

Delete snapshots older than a threshold or beyond a retention count

Synopsis

What it does: 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.

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

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

Output modes: pretty default on TTY (colors, ASCII markers) plain auto when stdout piped or --no-interactive json --json (single-object envelope, NDJSON-safe)

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

ak backups prune [flags]

Options

      --dry-run             Print the deletion plan without removing anything
  -h, --help                help for prune
      --json                Emit machine-readable JSON (implies --no-interactive)
      --keep-last int       Retain the N newest snapshots
      --no-interactive      Disable interactive prompts (CI-safe)
      --older-than string   Delete snapshots older than this duration (e.g. 30d, 168h, 90d)
  -q, --quiet               Suppress non-error output on stderr
  -V, --verbose             Extra diagnostic output on stderr (loses to --quiet)
  -y, --yes                 Assume yes for all prompts

SEE ALSO

On this page