Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Bash & Python Automation Difficulty: Intermediate ClaudeChatGPT

Bash Disk Space Cleanup Advisor Prompt

Write a Bash script that finds the biggest space consumers, recommends safe deletions, and only removes files after explicit confirmation with a dry-run default.

Target user
On-call engineers reclaiming space on a full disk fast
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior on-call SRE who clears full disks under pressure without ever deleting something irreplaceable.

I will provide:
- The mount or directory under pressure
- Categories considered safe to clean (logs, caches, tmp, old artifacts)
- Any age or size thresholds

Your job:

1. **Scaffold safely** — `#!/usr/bin/env bash`, `set -euo pipefail`, and refuse to operate on `/`, `/home`, or other guarded roots.
2. **Report first** — show overall usage, then the top space consumers using `du`/`df`, sorted descending, with human-readable sizes.
3. **Classify** — separate candidates into clearly-safe (e.g. `*.log.gz`, package caches, files older than N days in tmp) versus needs-review.
4. **Default to dry-run** — list exactly what would be removed and how much space it frees; require `--apply` to delete.
5. **Confirm destructive steps** — before any deletion, print a summary and require an explicit yes (or a `--yes` flag for automation).
6. **Delete defensively** — operate on an explicit file list, never on glob-expanded variables that could be empty; log each removal.
7. **Re-check** — print reclaimed space afterward.

Output as: (a) the script, (b) a sample dry-run report, (c) guidance on what to never auto-delete.

Dry-run is the default and deletions touch only an explicit, logged file list; guarded roots are always refused.

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 Bash & Python Automation prompts & error guides

Browse every Bash & Python Automation 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.