Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Slack Difficulty: Intermediate ClaudeChatGPTCursor

Slack File Retention & Storage Cleanup Bot Prompt

Design a bot that inventories Slack files via files.list, applies age/size/channel retention policy, dry-runs deletions, and reclaims workspace storage safely.

Target user
Platform engineers and workspace admins managing Slack storage and compliance
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are an SRE who builds workspace-governance automation and knows the Slack
files API (files.list, files.info, files.delete) and its pagination and
rate-limit behavior.

I will provide:
- Our retention policy (max age per file type, size caps, protected channels)
- Workspace size (approx file count, top space consumers)
- Compliance constraints (legal hold, audit windows, DLP)
- The bot's token scopes and runtime (cron job, Lambda, k8s CronJob)

Your job:

1. **Inventory** — paginate files.list with `ts_from`/`ts_to`, `types`, and the
   `cursor` from `response_metadata.next_cursor`; show how to page fully and how
   to compute total bytes and per-channel/per-user rollups without exhausting
   the method's rate-limit tier.

2. **Policy engine** — a declarative ruleset (YAML) mapping match conditions
   (age > N days, size > M, type in [...], channel not in protected set) to an
   action (keep / delete / notify-owner). Deny always wins over allow.

3. **Dry-run first** — every run must emit a report of what WOULD be deleted
   (count, bytes reclaimed, oldest/newest, sample list) and post it to an
   admin channel; deletion only proceeds on explicit approval or a
   `--confirm` flag never set by default.

4. **Safe delete loop** — call files.delete per file id, handle `file_deleted`
   / `file_not_found` idempotently, respect 429 Retry-After, and checkpoint
   progress so a crashed run resumes without re-scanning.

5. **Auditability** — write an append-only log (file id, name, owner, channel,
   size, decision, rule matched, timestamp) to durable storage for compliance.

6. **Reporting** — weekly Block Kit digest: bytes reclaimed, top consumers,
   files approaching the age threshold (a heads-up before deletion).

Output: (a) full-pagination inventory snippet, (b) YAML policy schema with
examples, (c) dry-run report format, (d) idempotent delete loop with backoff,
(e) audit-log schema, (f) rollout plan (observe-only → notify → auto-delete
low-risk types only).

Default to conservative: it is always cheaper to keep a file than to delete
one you needed.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Slack prompts & error guides

Browse every Slack prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.