Skip to content

feat: bulk cleanup command for test/scratch Actors (apify actors prune) #1256

Description

@DaveHanns

Problem

Users who iterate on Actor development — especially in automated / scripted / evaluation workflows — accumulate large numbers of one-off test Actors in their account. There is currently no first-class CLI affordance for cleaning them up in bulk:

  • apify actors rm <name> requires the exact name and only removes one Actor at a time.
  • apify actors ls prints a table but there is no way to pipe or filter its output into rm from within the CLI.
  • The web console requires clicking through each Actor individually.

In a recent scripted workflow that pushed a fresh Actor per test run, 20+ orphan Actors accumulated in a single account within a few days. Users have to either write a shell loop around apify client / the REST API, or clean up manually in the console.

Proposal

1. apify actors prune — bulk-delete filtered Actors

apify actors prune [--older-than <duration>] [--name-pattern <regex>] [--dry-run] [--yes]
  • --older-than 7d — only Actors whose modifiedAt (or createdAt) is older than the given duration. Accept 1h, 24h, 7d, 30d.
  • --name-pattern '^test-' — only Actors whose name matches the regex.
  • --dry-run — print the list of Actors that would be deleted, do not delete.
  • --yes — skip interactive confirmation (safe default is to confirm).

Implementation sketch: use the existing apify-client actors().list() + actor(id).delete() — no server-side changes required.

2. (optional, larger) apify push --temporary + server-side TTL

A follow-up that would require apify-core support: allow apify push --temporary to mark an Actor as ephemeral (e.g. auto-deleted after N days of no runs). apify actors prune --temporary-only could then target only those. This is out of scope for the CLI-only PR above and would need a separate design discussion with apify-core.

Alternatives considered

  • Shell one-linerapify actors ls --json | jq ... | xargs apify actors rm — works today but is fragile (name parsing, quoting, error handling), and requires jq + shell-fu that not all users have.
  • Web console bulk-select — not a CLI concern, but would help the same problem class.

Test plan

  • apify actors prune --dry-run --older-than 30d prints candidates, deletes nothing.
  • apify actors prune --name-pattern '^ci-test-' --yes deletes only matching Actors.
  • Prompts for confirmation when --yes is not passed and stdin is a TTY.
  • Non-zero exit code if any deletion fails; continue past failures and report at the end.

Willing to contribute

Happy to open a PR for part (1) — the prune subcommand using existing APIs — if the design above sounds reasonable. Please confirm the flag names / defaults / namespace (actors prune vs. a subcommand under actors rm).


Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions