Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

prune-ci-images

БесплатноЗапускает вложенные скриптыНе проверен

Audit old container images in the posit-dev GHCR registry and delete them in a reviewed batch. Produces a review list of every positron-<os>* /…

posit-devот posit-dev★ 4 361 звезда на GitHub

Об этом скилле

Prune old CI images from GHCR

Two-phase, human-gated cleanup of stale container versions in https://github.com/orgs/posit-dev/packages:

  1. Audit (read-only) -> a markdown review list of deletion candidates.
  2. Human review -> the reviewer removes rows they want to KEEP.
  3. Prune -> batch-delete exactly the rows that remain.
  4. Delete emptied packages (optional, separate approval) -> clear packages that are down to a last tagged version GHCR will not remove.

<dir> below means .claude/skills/prune-ci-images.

Deletion is disruptive and only conditionally recoverable. GitHub can usually restore a deleted package version within 30 days, provided the package still exists and that version/tag has not been re-pushed:

gh api -X POST /orgs/<org>/packages/container/<pkg>/versions/<id>/restore

Do not rely on that. Restoring is manual and per-version, and it does nothing about the immediate breakage: any workflow or branch pinning a deleted tag fails as soon as the version goes away. Never run the prune step with --confirm until the human has explicitly approved the reviewed list.

Preflight

gh auth status          # needs read:packages AND delete:packages

read:packages alone is enough for the audit. The prune step checks for delete:packages itself and refuses to run without it. To add it:

gh auth refresh -h github.com -s read:packages -s delete:packages

The token also needs to be for an account with admin rights on the packages; org member read access is not sufficient to delete.

Phase 1 -- Audit

<dir>/scripts/ghcr-audit.sh \
  --repo-path "$REPO" \
  --out /tmp/ghcr-review-list.md

Options:

Flag Default Meaning
--org posit-dev Org that owns the packages
--age-days 90 Candidates must be older than this
--pattern see below ERE matched against package names
--repo-path none Checkout to scan for in-use image tags
--protect-tag none Extra tag to treat as in-use (repeatable)
--out stdout Where to write the review list

Default pattern:

^positron-(postgres|ubuntu|rocky|debian|opensuse|sles|windows|amazonlinux|fedora|alpine|centos)

This deliberately covers the OS images and postgres images (both the multi-arch index packages like positron-rocky8 and the old per-arch ones like positron-rocky8-amd64, which the builds no longer push to), and deliberately excludes other positron-* packages that are not OS images: positron-builds-rocky8, positron-ci, positron-sagemaker, positron-debian13 variants are covered, but build/tooling images are not. Widen with --pattern only on request.

Always pass --repo-path. Without it nothing is treated as in-use and live tags land in the candidate list.

What the audit protects automatically

A version is retained (never listed) when:

  • it is newer than the cutoff, or
  • one of its tags is referenced as ghcr.io/<owner>/<pkg>:<tag> under .github/, docker/, test/, scripts/, or build/ in --repo-path, or
  • it is a child manifest of a retained multi-arch index. The audit resolves every retained version against the ghcr.io registry API and protects the per-arch digests it points at. These appear in an "Excluded: children of retained images" section of the report.

That last rule is the one that matters most. The multi-arch build pushes an index plus two untagged per-arch manifests into the same package, all in the same second. The untagged rows look like garbage but deleting them breaks the tagged image.

Reading the report

  • "Packages that would be emptied completely" -- every version of these is a candidate. GHCR refuses to delete a package's last tagged version, so the prune step deletes all but one and reports the final version as a failure. That is expected, not a bug; clearing them needs phase 4. Surface this list to the user explicitly and confirm the image is retired.
  • "Warning: manifests that could not be resolved" -- registry reads failed, so the protected set may be incomplete. Do not proceed on a list with this section; fix access and re-run.
  • kind column -- tagged, untagged (an orphaned index whose tag moved away), or arch child (a per-arch manifest under a candidate index).
  • group column -- ties an index to its children. Rows sharing a group must be kept or deleted together.

Phase 2 -- Human review

Hand the file to the user and state plainly:

  • how many candidates there are and the cutoff used,
  • which packages would be emptied entirely,
  • that every row listed will be deleted, and they should delete the rows they want to keep,
  • that rows sharing a group must be kept or removed as a unit,
  • that id and group columns must not be edited.

Wait for the user to confirm the reviewed file. Do not guess at approval.

Phase 3 -- Prune

Dry run first, always. Pass t

Полный SKILL.md на GitHub

Установить prune-ci-images в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

scripts/ghcr-audit.shscripts/ghcr-delete-packages.shscripts/ghcr-prune.sh

FAQ

Что делает скилл prune-ci-images?

Audit old container images in the posit-dev GHCR registry and delete them in a reviewed batch. Produces a review list of every positron-<os>* / positron-postgres-* image version older than a cutoff (default 90 days), excluding anything a live tag or multi-arch manifest still points at; the human deletes rows they want to keep, then this drives the batch delete. Use when asked to clean up, prune, or garbage-collect old GHCR packages/images.

Как установить скилл prune-ci-images?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл prune-ci-images запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить prune-ci-images с