GitHub CLI extension

Clean up stale Actions runs without risky one-off scripts.

gh-runs-cleanup helps you safely bulk-delete GitHub Actions workflow runs with dry-run previews, explicit confirmation, filtering by workflow, branch, age, and status, plus retry handling and machine-readable JSON summaries.

Safe by default JSON summaries Retry-aware
  • Safe by default with --dry-run and --confirm
  • Built for automation with --json
  • Works directly from source on modern Node.js

Install

Be productive in under a minute

Install the extension once, then use dry runs to preview cleanup safely before deleting anything.

install
gh extension install Nick2bad4u/gh-runs-cleanup
Dry-run first Preview everything before deletion.
Structured JSON Perfect for scripts, bots, and scheduled jobs.
Operational controls Retries, fail-fast, max-failures, and exclusions.

Features

Designed for safe cleanup at scale

Explicit safety controls

No destructive action happens unless you opt in with --confirm or --yes.

Flexible filtering

Filter by workflow, branch, event, actor, commit, created date, age threshold, and run status.

Operational resilience

Retries with backoff, fail-fast, max-failures, ordering, and exclusion filters help avoid noisy cleanup runs.

Automation ready

Use --json for machine-readable summaries in scheduled workflows, scripts, or local tooling.

Deterministic ordering

Process runs in oldest, newest, or none mode to match your retention strategy.

Built for gh users

Works with existing gh authentication and repository context instead of requiring a separate service or config file.

Usage

Common cleanup workflows

Preview everything

preview
gh runs-cleanup --repo owner/repo --dry-run

Delete failed/cancelled runs

default-cleanup
gh runs-cleanup --repo owner/repo --status failure,cancelled --confirm

Clean older failed runs only

age-filtered
gh runs-cleanup --repo owner/repo --status failure --before-days 30 --confirm

Exclude critical workflows

protected-pipelines
gh runs-cleanup --repo owner/repo --all-statuses --exclude-workflow CI,Release --dry-run

Filters & controls

Control what gets touched

Category Options
Repository --repo
Workflow selection --workflow, --exclude-workflow
Branch selection --branch, --exclude-branch
Status & age --status, --all-statuses, --before-days, --created
Execution controls --max-delete, --order, --max-retries, --retry-delay-ms, --fail-fast, --max-failures
Output --verbose, --quiet, --json

JSON mode

Machine-readable output for jobs and scripts

json-command
gh runs-cleanup \
  --repo owner/repo \
  --status failure \
  --before-days 14 \
  --dry-run \
  --json
summary.json
{
      "attempted": 0,
      "deleted": 0,
      "dryRun": true,
      "durationMs": 112,
      "failed": 0,
      "failedIds": [],
      "matched": 42,
      "repo": "owner/repo",
      "skippedByExclusion": 3,
      "statuses": ["failure"],
      "skippedByAge": 19
    }

Ready to clean up your Actions history?

Start with a dry run, confirm only what you want to remove, and automate the rest with JSON output and scheduled jobs.