Claude Prompt Library

30 Claude Prompts That Write Bash Scripts

30 copy-paste prompts

Describe the task and Claude returns a complete, commented Bash script you can save and run: file operations, backups, monitoring, deploys, cron jobs, and grep/awk/sed text processing. Not "give me a command" โ€” a real, safe, ready-to-run script.

In short: This page contains 30 copy-paste ready prompts, organized into 6 categories with a description and pro tip for each. The first 15 prompts are free instantly โ€” no signup needed. Hand-curated and tested by the AI Academy team.

By Louis Corneloup ยท Founder, Techpresso
Last updated ยทHand-curated & tested by the AI Academy team

File Operations

5 prompts

Bulk File Renamer

1/30

You are a senior Bash scripting engineer who writes safe, portable shell scripts. <context> I need a single self-contained Bash script that batch-renames files in a directory following a pattern, so I can save it, make it executable, and run it. It must be safe to preview before it touches anything. </context> <inputs> - Target directory: [PATH] - Rename rule: [E.G. LOWERCASE + REPLACE SPACES WITH DASHES, OR PREFIX WITH DATE, OR SEQUENTIAL NUMBERING] - File filter: [E.G. *.jpg, OR ALL FILES] - Recursive or top-level only: [RECURSIVE / TOP-LEVEL] - Collision handling: [SKIP / APPEND SUFFIX / OVERWRITE] </inputs> <task> Write a Bash script that scans the target directory, computes each new name from the rule, and renames the files. Include a --dry-run flag (default on) that prints old -> new without renaming, a --apply flag to actually rename, argument parsing, and a summary count at the end. Comment each block explaining what it does. </task> <constraints> - Start with #!/usr/bin/env bash and set -euo pipefail. - Handle filenames with spaces and special characters (quote everything, use while read -r with null-delimited find where needed). - Never overwrite silently; respect the collision rule. Fail with a clear message if the directory is missing. </constraints> <format> Return the full script in one code block, then a short note on how to make it executable, run the dry-run, and apply it. </format>

Generates a safe bulk file renamer with dry-run preview and collision handling, ready to run.

๐Ÿ’ก

Pro tip: Always run the default --dry-run first and eyeball the old -> new list before adding --apply.

Duplicate File Finder & Deduper

2/30

You are a Bash scripting expert focused on safe file management. <context> I need one self-contained Bash script that finds duplicate files by content hash and optionally removes the extras, keeping one copy. I will save and run it directly. </context> <inputs> - Directory to scan: [PATH] - File-size floor to ignore tiny files: [E.G. 1k, OR NONE] - Which copy to keep: [OLDEST / NEWEST / SHORTEST PATH] - Action on duplicates: [REPORT ONLY / MOVE TO A QUARANTINE FOLDER / DELETE] </inputs> <task> Write a Bash script that walks the directory, groups files by size first (fast pre-filter), then confirms duplicates with a checksum (sha256sum, fall back to shasum). Print each duplicate group and the total wasted space. When an action other than report is chosen, keep exactly one file per group per the rule and move or delete the rest. Comment the size-then-hash strategy. </task> <constraints> - #!/usr/bin/env bash with set -euo pipefail. - Default action is REPORT ONLY; destructive actions require an explicit flag. - Handle spaces in paths, skip symlinks, and never delete the last remaining copy of a group. </constraints> <format> Return the full script in one code block, then a short note on interpreting the report and safely enabling the delete mode. </format>

Produces a size-then-hash duplicate finder that reports wasted space and can safely dedupe, ready to run.

๐Ÿ’ก

Pro tip: Run it in report mode first, then use the move-to-quarantine option so you can eyeball the pile before deleting anything.

Directory Organizer by Type & Date

3/30

You are a Bash automation engineer who writes tidy, well-commented scripts. <context> My downloads or media folder is a mess. I need one self-contained Bash script that sorts files into subfolders by type and/or date so I can save it and run it on demand. </context> <inputs> - Source directory: [PATH] - Sort strategy: [BY EXTENSION GROUP (IMAGES/DOCS/VIDEO/ARCHIVES/OTHER) / BY YEAR-MONTH / BY BOTH] - Date source: [FILE MODIFICATION TIME / TODAY] - Duplicate name handling: [APPEND NUMBER / SKIP] </inputs> <task> Write a Bash script that reads each file in the source directory, decides its destination folder from the chosen strategy (define clear extension-to-group mappings), creates the destination folder if needed, and moves the file there. Support --dry-run (default) and --apply, and print a per-folder count summary at the end. Comment the extension mapping and date-bucket logic. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Only touch files in the top level of the source directory (do not recurse into the folders it creates). - Quote all paths, handle spaces, and never overwrite an existing file silently. </constraints> <format> Return the full script in one code block, then explain how to add new extension groups and switch between date and type sorting. </format>

Builds a folder-organizer script that files documents into type or date buckets with a dry-run, ready to run.

๐Ÿ’ก

Pro tip: Add your own extension groups near the top of the script; the mapping block is designed to be edited without touching the logic.

Batch File Converter (Loop)

4/30

You are a Bash scripting engineer who writes robust batch-processing scripts. <context> I need one self-contained Bash script that batch-converts a folder of files from one format to another by looping a command-line converter, so I can save and run it. </context> <inputs> - Input directory and extension: [PATH, E.G. *.png] - Output directory and target format: [PATH, E.G. *.jpg] - Converter command: [E.G. convert (ImageMagick), ffmpeg, OR SPECIFY] - Extra converter options: [E.G. QUALITY, RESOLUTION, OR NONE] - Overwrite existing outputs: [YES / SKIP IF EXISTS] </inputs> <task> Write a Bash script that finds all matching input files, builds the output path for each, creates the output directory, and runs the converter command in a loop. Show a progress line (N of TOTAL), continue past a single failed file while recording it, and print a final summary of converted/skipped/failed counts. Comment the loop and the output-path derivation. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Check the converter binary exists up front (command -v) and exit with a helpful message if not. - Handle spaces in filenames; respect the skip-if-exists option; never delete inputs. </constraints> <format> Return the full script in one code block, then a short note on swapping in a different converter and adding parallelism with xargs -P. </format>

Generates a batch converter loop with progress, per-file error handling, and a summary, ready to run.

๐Ÿ’ก

Pro tip: For big batches, follow the note to switch the loop to xargs -P and use every CPU core.

Old / Large File Cleanup

5/30

You are a Bash scripting expert who writes cautious disk-cleanup scripts. <context> A directory keeps filling up with old or oversized files. I need one self-contained Bash script that finds them and archives or deletes them, safe to preview first. </context> <inputs> - Directory to clean: [PATH] - Age threshold: [E.G. OLDER THAN 30 DAYS, OR NONE] - Size threshold: [E.G. LARGER THAN 100M, OR NONE] - Name filter: [E.G. *.log, *.tmp, OR ALL] - Action: [LIST ONLY / MOVE TO ARCHIVE DIR / DELETE] </inputs> <task> Write a Bash script that uses find with the chosen mtime and size predicates to select matching files, prints them with sizes and a running total of space to be freed, and then applies the action. Default to LIST ONLY; deletion or moving requires an explicit --apply flag. Comment each find predicate. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Use find -print0 with while read -r -d '' to survive weird filenames. - Refuse to run against / or an empty path; require the directory to exist. Deletion must never be the default. </constraints> <format> Return the full script in one code block, then explain how to schedule it safely and how to test the filters before enabling --apply. </format>

Creates a guarded cleanup script that lists then archives or deletes old and large files, ready to run.

๐Ÿ’ก

Pro tip: Keep the default LIST ONLY mode until the file list and freed-space total look exactly right, then add --apply.

XML tags are just the start. Learn the full Claude workflow.

A growing library of 300+ hands-on AI tutorials covering Claude, ChatGPT, and 50+ tools. New tutorials added every week.

Start 7-Day Free Trial

Backups

5 prompts

Timestamped Tar Backup with Rotation

6/30

You are a Bash scripting engineer who writes reliable backup automation. <context> I need one self-contained Bash script that creates a compressed, timestamped archive of a directory and keeps only the most recent N backups. I will save and run it or schedule it via cron. </context> <inputs> - Source directory to back up: [PATH] - Backup destination directory: [PATH] - Paths to exclude: [E.G. node_modules, .cache, OR NONE] - How many backups to keep: [N] - Archive name prefix: [E.G. website-backup] </inputs> <task> Write a Bash script that tars and gzips the source into DEST/PREFIX-YYYYMMDD-HHMMSS.tar.gz, applying the exclude list, verifies the archive is non-empty, then deletes the oldest archives beyond the keep count. Log each step with timestamps and print the final archive path and size. Comment the rotation logic. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Fail loudly if the source is missing or the destination is not writable; create the destination if needed. - Rotation must sort by filename timestamp, not ctime, and never delete the newest backup. </constraints> <format> Return the full script in one code block, then a short note on the crontab line to run it nightly and how to test a restore. </format>

Produces a timestamped tar.gz backup script with exclude list and keep-N rotation, ready to run or cron.

๐Ÿ’ก

Pro tip: Test a restore into a scratch folder before trusting it โ€” a backup you have never restored is a hope, not a backup.

Database Dump & Rotation

7/30

You are a Bash and database operations engineer. <context> I need one self-contained Bash script that dumps a database to a compressed file, rotates old dumps, and is safe to run from cron. Credentials must not be hard-coded in plain sight. </context> <inputs> - Database engine: [POSTGRES / MYSQL] - Connection details: [HOST, PORT, DB NAME, USER] - How credentials are provided: [ENV VARS / .pgpass OR .my.cnf FILE] - Backup directory: [PATH] - Retention: [KEEP LAST N DUMPS] </inputs> <task> Write a Bash script that runs pg_dump or mysqldump (based on the engine), pipes it through gzip to DIR/DBNAME-YYYYMMDD-HHMMSS.sql.gz, checks the exit status of the dump (not just gzip), then prunes dumps beyond the retention count. Log start, success, size, and any failure. Comment the credential handling and the pipefail note. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail so a failed dump in the pipe is caught. - Read the password from an env var or credentials file; never echo it. Exit non-zero on dump failure so cron surfaces the error. - Prune only files matching this DB's prefix. </constraints> <format> Return the full script in one code block, then explain the safest way to supply credentials and the cron entry to run it daily. </format>

Generates a Postgres/MySQL dump-and-rotate script with proper credential handling and pipefail, ready to cron.

๐Ÿ’ก

Pro tip: Because it uses set -o pipefail, a failed dump won't be masked by a successful gzip โ€” cron will actually see the error.

Incremental rsync Backup to Remote

8/30

You are a Bash scripting engineer who specializes in rsync backups. <context> I need one self-contained Bash script that syncs a local directory to a remote server over SSH using rsync, incrementally, so I can save and schedule it. </context> <inputs> - Local source directory: [PATH] - Remote target: [USER@HOST:/PATH] - SSH key or port if non-default: [KEY PATH / PORT / NONE] - Paths to exclude: [LIST OR NONE] - Delete files on remote that were removed locally: [YES / NO] </inputs> <task> Write a Bash script that runs rsync with archive mode, compression, partial-transfer resume, and human-readable progress, honoring the exclude list and the optional delete flag. Add a --dry-run flag that passes rsync -n, capture the exit code, and log a start/finish line with a timestamp. Comment each rsync flag so I understand what it does. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Build the SSH transport with -e 'ssh ...' only when a key or custom port is given. - --delete must be opt-in, never default; abort clearly if rsync is not installed or the source is missing. </constraints> <format> Return the full script in one code block, then explain the difference between mirror and additive mode and the cron line to run it hourly. </format>

Builds an incremental rsync-over-SSH backup script with dry-run and opt-in mirror delete, ready to schedule.

๐Ÿ’ก

Pro tip: Run with --dry-run after any change to the exclude list so you can confirm nothing important is about to be deleted on the remote.

Config & Dotfiles Backup

9/30

You are a Bash scripting expert who writes portable backup utilities. <context> I want one self-contained Bash script that backs up a curated list of config files and dotfiles into a single timestamped, versionable archive so I can restore a machine quickly. </context> <inputs> - Files and directories to back up: [E.G. ~/.bashrc, ~/.ssh/config, ~/.config/nvim, /etc/nginx] - Backup output directory: [PATH] - Include a manifest of what was captured: [YES / NO] - Optional GPG encryption passphrase source: [ENV VAR / NONE] </inputs> <task> Write a Bash script that copies each listed path into a staging folder preserving relative structure, writes a manifest.txt listing every captured path and its size, tars and gzips the staging folder to a timestamped archive, and optionally encrypts it with gpg. Skip missing paths with a warning instead of failing. Comment the staging and manifest steps. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Preserve file permissions with cp -a; never follow into huge caches unless listed. - If encryption is requested but no passphrase is available, abort before creating a plaintext archive. </constraints> <format> Return the full script in one code block, then explain how to restore from the archive and how to store the encrypted backup safely. </format>

Creates a dotfiles/config backup script with a manifest and optional GPG encryption, ready to run.

๐Ÿ’ก

Pro tip: Keep the file list at the top of the script under version control so your backup set evolves with your setup.

Backup with Cloud Upload & Verify

10/30

You are a Bash and cloud-storage automation engineer. <context> I need one self-contained Bash script that creates a local archive, uploads it to object storage, verifies the upload, and prunes old local copies. It must be cron-safe. </context> <inputs> - Directory to back up: [PATH] - Cloud tool and destination: [E.G. aws s3 cp TO s3://bucket/path, OR rclone TO remote:path] - Local staging directory: [PATH] - Keep how many local archives: [N] - Notify on failure: [WEBHOOK URL / EMAIL / NONE] </inputs> <task> Write a Bash script that builds a timestamped tar.gz locally, uploads it with the chosen cloud command, confirms the upload succeeded (check exit code and, where possible, that the remote object exists), then rotates local archives beyond the keep count. On any failure, send the optional notification with the error. Log every stage with timestamps. Comment the verify and notify blocks. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Verify the cloud CLI exists and is configured before creating the archive. - Do not delete the local copy until the upload is confirmed; exit non-zero on any failure so cron reports it. </constraints> <format> Return the full script in one code block, then explain how to swap aws for rclone and how to wire the failure notification. </format>

Produces a backup-and-upload script that verifies the remote copy before pruning locally, ready to cron.

๐Ÿ’ก

Pro tip: The verify-before-prune order is the whole point โ€” never delete a local archive until the cloud upload is confirmed.

Monitoring & Health Checks

5 prompts

Website / HTTP Uptime Checker

11/30

You are a Bash scripting engineer who builds lightweight monitoring tools. <context> I need one self-contained Bash script that checks whether one or more URLs are up and alerts me when they are not. I will run it from cron every few minutes. </context> <inputs> - URLs to check: [LIST] - Expected HTTP status: [E.G. 200, OR ANY 2xx/3xx] - Timeout in seconds: [N] - Alert channel: [SLACK/DISCORD WEBHOOK URL / EMAIL / STDOUT] - Optional string that must appear in the body: [TEXT OR NONE] </inputs> <task> Write a Bash script that loops the URLs, uses curl to fetch each with the timeout, records the HTTP status and response time, and flags any that miss the expected status or fail the optional body-content check. Print a status line per URL and send an alert only for failures. Exit non-zero if any check failed. Comment the curl flags and the alert trigger. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Use curl -s -o /dev/null -w for status and timing; never let one dead URL abort the whole loop. - Do not alert on transient success; only failures notify. Keep the script dependency-free beyond curl. </constraints> <format> Return the full script in one code block, then explain the cron entry for a 5-minute interval and how to add a retry before alerting. </format>

Generates a multi-URL uptime checker with status/timing and webhook alerts on failure, ready to cron.

๐Ÿ’ก

Pro tip: Add the suggested single retry before alerting so a one-off network blip doesn't page you at 3am.

Disk Space Monitor with Threshold Alert

12/30

You are a Bash scripting expert who writes server monitoring scripts. <context> My server filled its disk once and crashed the database. I need one self-contained Bash script that warns me before that happens, run from cron. </context> <inputs> - Filesystems or mount points to watch: [E.G. /, /var, OR ALL] - Warning threshold percent: [E.G. 80] - Critical threshold percent: [E.G. 90] - Alert channel: [WEBHOOK URL / EMAIL / STDOUT] - Also report largest directories on breach: [YES / NO] </inputs> <task> Write a Bash script that parses df output for each watched mount, compares usage against the warning and critical thresholds, and prints a clear per-mount status. On a breach, send an alert naming the mount and usage; if enabled, include the top space-consuming directories from du. Return exit code 0 (ok), 1 (warning), or 2 (critical). Comment the df parsing and threshold comparison. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Parse df -P for portable, single-line output; strip the % sign safely before numeric comparison. - Do not run du unless a breach occurred and it is enabled (it can be slow). </constraints> <format> Return the full script in one code block, then explain the cron schedule and how the exit codes map to monitoring systems. </format>

Builds a disk-usage monitor with warning/critical thresholds and optional top-dirs report, ready to cron.

๐Ÿ’ก

Pro tip: Set the warning threshold well below critical so you get a heads-up with time to clean up, not just an emergency.

Service / Process Watchdog

13/30

You are a Bash scripting engineer who writes self-healing watchdog scripts. <context> A process on my server occasionally dies and I want it restarted automatically with a log entry, via one self-contained Bash script run from cron. </context> <inputs> - What to watch: [SYSTEMD SERVICE NAME / PROCESS NAME / PORT / URL HEALTH ENDPOINT] - How to detect down: [systemctl is-active / pgrep / check listening port / curl endpoint] - Restart command: [E.G. systemctl restart X, OR A START COMMAND] - Max restarts before giving up in this run: [N] - Alert channel on restart: [WEBHOOK / EMAIL / STDOUT] </inputs> <task> Write a Bash script that checks whether the target is healthy using the chosen method, and if not, runs the restart command, waits, and re-checks up to the max-restart limit. Log every check and action with a timestamp to a log file, and send an alert whenever a restart happens or the limit is hit. Comment the detection and restart-with-backoff logic. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Detection must not produce false positives (e.g. grep for the exact process, exclude the grep line itself). - Never loop forever; respect the max-restart cap and exit non-zero if the service is still down after trying. </constraints> <format> Return the full script in one code block, then explain the cron interval and why a systemd unit with Restart=on-failure may be better for some cases. </format>

Creates a watchdog that detects a down service, restarts it with a cap, and alerts, ready to cron.

๐Ÿ’ก

Pro tip: Point it at a real health endpoint rather than just "is the process alive" โ€” a hung process is still a running process.

System Resource Report

14/30

You are a Bash scripting expert who writes clean system diagnostics. <context> I want one self-contained Bash script that prints a readable snapshot of a server's health so I can eyeball it over SSH or capture it in a log. </context> <inputs> - What to include: [CPU LOAD, MEMORY, DISK, TOP PROCESSES, NETWORK, UPTIME โ€” CHOOSE] - Number of top processes to list: [N] - Output format: [HUMAN-READABLE SECTIONS / SINGLE-LINE FOR LOGGING] - Optional threshold to highlight in red: [E.G. LOAD > CORES, MEM > 90%] </inputs> <task> Write a Bash script that gathers the requested metrics using portable tools (uptime, free or vm_stat, df, ps sorted by CPU and memory) and prints them as tidy labeled sections with a header showing hostname, date, and uptime. Highlight any metric that crosses the optional threshold. Comment where each number comes from so it is trustworthy. Support a --oneline mode for log ingestion. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Prefer widely available commands; guard Linux-only vs macOS differences (e.g. free vs vm_stat) with a check. - Read-only: the script must never change system state. </constraints> <format> Return the full script in one code block, then explain how to append its --oneline output to a daily metrics log. </format>

Produces a read-only server health report with CPU, memory, disk, and top processes, ready to run.

๐Ÿ’ก

Pro tip: Use the --oneline mode in cron to build a time-series log you can later grep or graph.

SSL Certificate Expiry Checker

15/30

You are a Bash scripting engineer who automates certificate monitoring. <context> I have been burned by an expired TLS certificate. I need one self-contained Bash script that checks how many days are left on one or more certificates and warns me early, run from cron. </context> <inputs> - Domains or endpoints to check: [LIST, E.G. example.com:443] - Warning threshold in days: [E.G. 21] - Critical threshold in days: [E.G. 7] - Alert channel: [WEBHOOK / EMAIL / STDOUT] - Also check local cert files: [PATHS OR NONE] </inputs> <task> Write a Bash script that, for each domain, opens a TLS connection with openssl s_client, extracts the notAfter date, converts it to days remaining, and compares against the thresholds. Also inspect any local cert files with openssl x509. Print a per-target line with days left and a status, and alert on anything within the warning window. Exit 0/1/2 for ok/warning/critical. Comment the date math (portable between GNU and BSD date). </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Handle connection failures gracefully (unreachable host is its own alert, not a silent pass). - Date arithmetic must work on both Linux and macOS; detect and branch if needed. </constraints> <format> Return the full script in one code block, then explain the cron schedule and how to combine it with an auto-renewal step. </format>

Generates a TLS certificate expiry checker with warning/critical day thresholds and alerts, ready to cron.

๐Ÿ’ก

Pro tip: Set the warning window to at least 21 days so you have room to renew and propagate before anything actually expires.

Deploy & Setup

5 prompts

Build, Upload & Restart Deploy

16/30

You are a DevOps engineer who writes safe, repeatable Bash deploy scripts. <context> I need one self-contained Bash script that deploys my app from my local machine to a remote server: build locally, package, upload, extract, and restart the service. I will save and run it as deploy.sh. </context> <inputs> - Local project directory and build command: [PATH, E.G. npm run build OR NONE] - Files to include and exclude in the tarball: [INCLUDE / EXCLUDE LISTS] - Remote target: [USER@HOST, DEST PATH] - Restart command on the server: [E.G. systemctl restart myapp, OR docker service update] - Post-deploy health check URL: [URL OR NONE] </inputs> <task> Write a Bash script that runs the build, creates a versioned tarball (excluding node_modules/.git/etc.), scp's it to the server, extracts it into the destination, runs the restart command over SSH, then hits the health check URL and rolls back messaging if it fails. Log each phase with a version tag and timestamps. Comment the packaging and the health-gate. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Abort the whole deploy if the build fails; never upload a broken build. - Do not capture log output into the scp target variable; keep the tarball path clean. Verify the health check returns success before declaring the deploy done. </constraints> <format> Return the full script in one code block, then explain how to add a rollback to the previous release and where to inject secrets safely. </format>

Builds a build-package-upload-restart deploy script with a post-deploy health gate, ready to run.

๐Ÿ’ก

Pro tip: Keep the last few versioned tarballs on the server so a rollback is a one-line re-extract of the previous release.

New Server Bootstrap / Provisioning

17/30

You are a systems engineer who writes idempotent server provisioning scripts. <context> I need one self-contained Bash script that takes a fresh Linux server from bare to ready: packages, a non-root user, SSH hardening, firewall, and my base tooling. It must be safe to re-run. </context> <inputs> - Distro: [UBUNTU/DEBIAN / RHEL/ALMA] - Packages to install: [LIST, E.G. git, curl, ufw, fail2ban, docker] - New sudo user to create: [USERNAME + PUBLIC KEY] - SSH hardening: [DISABLE ROOT LOGIN, DISABLE PASSWORD AUTH โ€” YES/NO] - Firewall ports to open: [E.G. 22, 80, 443] </inputs> <task> Write a Bash script that updates the package index, installs the packages, creates the sudo user with the provided public key, applies the SSH hardening to sshd_config (backing it up first), configures the firewall to allow the listed ports and enable it, and prints a summary of what changed. Make every step idempotent (check-before-change) so re-running is safe. Comment each hardening change. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Must run as root or via sudo; detect and warn if not. - Never lock yourself out: only apply SSH password-auth changes after the new user and key are confirmed working; back up sshd_config before editing. </constraints> <format> Return the full script in one code block, then explain the safe order to test SSH access before closing password login and how to re-run it. </format>

Produces an idempotent server bootstrap script for users, packages, SSH hardening, and firewall, ready to run.

๐Ÿ’ก

Pro tip: Open a second SSH session and confirm the new key-based login works before you let the script disable password auth.

Docker Container Deploy & Health Wait

18/30

You are a Bash and Docker automation engineer. <context> I need one self-contained Bash script that deploys a new version of a Docker container with minimal downtime and waits until it is healthy before finishing. </context> <inputs> - Image name and how it is built or pulled: [IMAGE:TAG, BUILD FROM DOCKERFILE / docker pull] - Container or service name: [NAME] - Run mode: [docker run / docker compose / docker service update (swarm)] - Health check: [CONTAINER HEALTHCHECK / curl AN ENDPOINT / PORT OPEN] - Env vars to pass: [LIST OR REFERENCE AN ENV FILE] </inputs> <task> Write a Bash script that builds or pulls the image with a version tag, starts the new container/service using the chosen run mode, waits in a loop (with timeout) until the health check passes, and only then removes the old container or confirms convergence. On health-check timeout, print logs and exit non-zero. Comment the tagging and the health-wait loop. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Never delete the old container before the new one is confirmed healthy. - Bound the health-wait with a max timeout; do not loop forever. Verify docker is available up front. </constraints> <format> Return the full script in one code block, then explain how to roll back to the previous image tag and how to prune old images safely afterward. </format>

Generates a Docker deploy script that waits for health before cutting over, with rollback notes, ready to run.

๐Ÿ’ก

Pro tip: Always prune old images after a successful deploy โ€” piled-up build images have filled disks and crashed databases.

Dev Environment Setup

19/30

You are a developer-experience engineer who writes onboarding scripts. <context> New teammates waste a day setting up. I need one self-contained Bash script that gets a dev machine from clone to running in one command, idempotently. </context> <inputs> - OS support target: [MACOS / LINUX / BOTH] - Tools and versions to install: [E.G. node 20, python 3.12, docker, a package manager] - Repo tasks: [INSTALL DEPS, COPY .env.example TO .env, RUN MIGRATIONS, SEED] - Version manager preference: [nvm/asdf/pyenv OR SYSTEM PACKAGES] - Final check: [E.G. npm run dev STARTS, OR A SMOKE TEST] </inputs> <task> Write a Bash script that detects the OS, installs the required tools via the appropriate package manager (Homebrew on macOS, apt on Debian/Ubuntu), sets up the version manager and language versions, installs project dependencies, prepares the .env file if missing, runs migrations/seed, and finishes with the smoke check. Skip anything already present (idempotent) and print a clear next-steps summary. Comment the OS-detection and each install step. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Check for each tool before installing; never clobber an existing .env. - Fail with an actionable message if a required tool cannot be installed automatically. </constraints> <format> Return the full script in one code block, then explain how to keep it idempotent as the stack grows and how to make it re-runnable after a pull. </format>

Builds an idempotent dev-environment setup script that takes a machine from clone to running, ready to run.

๐Ÿ’ก

Pro tip: Guard the .env step with an existence check so re-running setup never wipes a teammate's local secrets.

Git-Based Deploy with Rollback

20/30

You are a release engineer who writes git-driven deploy scripts. <context> I need one self-contained Bash script that deploys the latest code on a server by fetching a git branch, building, restarting, and keeping the ability to roll back to the previous commit instantly. </context> <inputs> - Repo path on the server: [PATH] - Branch to deploy: [E.G. main] - Build/install command: [E.G. npm ci && npm run build] - Restart command: [E.G. systemctl restart app / pm2 reload] - Health check: [URL OR COMMAND, AND TIMEOUT] </inputs> <task> Write a Bash script that records the current commit SHA (for rollback), fetches and hard-resets to origin/BRANCH, runs the build, restarts the service, and runs the health check. If the health check fails, automatically reset back to the recorded SHA, rebuild, restart, and report the rollback. Log each phase with the SHA. Support a manual --rollback flag that reverts to the last recorded good SHA. Comment the rollback bookkeeping. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Fail fast if the working tree is dirty or the branch does not exist. - Persist the last-known-good SHA to a file so --rollback works across separate invocations. </constraints> <format> Return the full script in one code block, then explain the deploy-then-verify-then-keep-or-revert flow and how to test the rollback path safely. </format>

Creates a git-pull deploy script with automatic health-check rollback to the prior commit, ready to run.

๐Ÿ’ก

Pro tip: Trigger a deliberate failing health check once in staging to prove the automatic rollback actually restores the last good SHA.

Cron Jobs

5 prompts

Log Rotation & Cleanup Cron

21/30

You are a Bash scripting engineer who writes maintenance cron jobs. <context> An app writes logs that grow forever. I need one self-contained Bash script, meant to run from cron, that rotates and compresses logs and deletes ones past a retention window. </context> <inputs> - Log directory and pattern: [PATH, E.G. *.log] - Rotate when a file exceeds: [SIZE, E.G. 50M โ€” OR ROTATE DAILY REGARDLESS] - Compress rotated logs: [YES gzip / NO] - Delete rotated logs older than: [N DAYS] - Signal the app to reopen logs after rotation: [COMMAND OR NONE] </inputs> <task> Write a Bash script that finds matching logs, rotates each qualifying file to NAME-YYYYMMDD.log (or numbered), compresses it if enabled, sends the optional reopen signal to the app, then deletes compressed logs older than the retention window. Print a summary of rotated and deleted files. Comment why the reopen signal matters and the retention logic. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Be cron-safe: no interactive prompts, absolute paths, and a clear exit code. - Do not truncate a log the app still has open without sending the reopen signal (or note logrotate as the production-grade alternative). </constraints> <format> Return the full script in one code block, then give the exact crontab line to run it nightly and note when to prefer logrotate instead. </format>

Generates a cron-safe log rotation and retention script with compression and app reopen signal, ready to schedule.

๐Ÿ’ก

Pro tip: For high-volume production logs, follow the note and use logrotate; this script is ideal for app-specific logs it doesn't manage.

Locked Backup Cron (No Overlap)

22/30

You are a Bash scripting expert who writes robust scheduled jobs. <context> My backup cron sometimes overlaps with the previous run and doubles the load. I need one self-contained Bash script that guarantees only one instance runs at a time using a lock. </context> <inputs> - The command or steps the job performs: [DESCRIBE, E.G. tar + upload] - Lock file location: [PATH, E.G. /var/lock/mybackup.lock] - Behavior if already running: [EXIT QUIETLY / LOG AND EXIT] - Max expected runtime for a stale-lock warning: [MINUTES] - Log file path: [PATH] </inputs> <task> Write a Bash script that acquires an exclusive lock with flock at the top (self-locking via a file descriptor), and if the lock is held, exits per the chosen behavior. Inside the lock, run the job steps, timing them, and log start/finish/duration to the log file. Warn if the run exceeds the max-runtime hint. Ensure the lock is always released, even on error. Comment the flock mechanism. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Use flock so the lock auto-releases if the process dies (no stale lock files to clean up manually). - Cron-safe: absolute paths, no prompts, meaningful exit codes. </constraints> <format> Return the full script in one code block, then give the crontab line and explain why flock beats a hand-rolled PID file. </format>

Builds a flock-guarded cron job that prevents overlapping runs and logs duration, ready to schedule.

๐Ÿ’ก

Pro tip: flock auto-releases if the process is killed, so unlike a manual PID file you'll never get stuck behind a stale lock.

Scheduled Database Dump Cron

23/30

You are a database operations engineer who writes scheduled backup jobs. <context> I want a cron job as one self-contained Bash script that dumps my database on a schedule, keeps a tiered retention (daily/weekly/monthly), and reports failures loudly. </context> <inputs> - Engine and connection: [POSTGRES/MYSQL, HOST, DB, USER] - Credential source: [ENV / .pgpass / .my.cnf] - Backup root directory: [PATH] - Retention tiers: [E.G. KEEP 7 DAILY, 4 WEEKLY, 6 MONTHLY] - Failure alert: [WEBHOOK / EMAIL / EXIT NON-ZERO ONLY] </inputs> <task> Write a Bash script that dumps the database compressed with a timestamp into a daily folder, then on the right calendar days copies or promotes the dump into weekly and monthly folders, and prunes each tier to its retention count. Check the dump's exit status (with pipefail) and alert on failure. Log every action. Comment the tiered-retention promotion logic. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Credentials from env or a protected file, never inline; exit non-zero on any dump failure. - Prune strictly per tier and never delete the most recent dump in any tier. </constraints> <format> Return the full script in one code block, then give the crontab line and explain the daily/weekly/monthly promotion so retention is predictable. </format>

Produces a scheduled DB dump script with tiered daily/weekly/monthly retention and failure alerts, ready to cron.

๐Ÿ’ก

Pro tip: Tiered retention gives you both recent granularity and long-term history without unbounded disk growth.

Certificate Renewal Cron

24/30

You are a Bash and TLS automation engineer. <context> I need one self-contained Bash script, run from cron, that renews certificates only when they are near expiry and reloads the web server just once if anything changed. </context> <inputs> - Renewal tool: [certbot / acme.sh / OTHER COMMAND] - Domains or leave to the tool's config: [LIST OR AUTO] - Days-before-expiry to trigger renewal: [E.G. 30] - Web server reload command: [E.G. nginx -s reload / systemctl reload nginx] - Failure alert: [WEBHOOK / EMAIL / STDOUT] </inputs> <task> Write a Bash script that runs the renewal tool in its check-and-renew mode, captures whether any certificate was actually renewed, and reloads the web server only if a renewal occurred. On renewal failure, alert with the tool's error output. Log the outcome (renewed / not yet due / failed) with a timestamp. Comment the deploy-hook vs conditional-reload approach. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Do not reload the web server on every run โ€” only when a cert changed. - Cron-safe with absolute paths; exit non-zero on renewal failure so it is noticed. </constraints> <format> Return the full script in one code block, then give the twice-daily crontab line certbot recommends and explain deploy hooks as an alternative. </format>

Generates a cron certificate-renewal script that reloads the web server only on actual renewal, ready to schedule.

๐Ÿ’ก

Pro tip: Reloading only when a cert actually changed avoids needlessly bouncing nginx twice a day for months on end.

Daily Digest / Report Emailer Cron

25/30

You are a Bash scripting engineer who builds reporting automation. <context> I want a cron job as one self-contained Bash script that gathers a few metrics or log summaries and sends me a short daily digest by email or webhook. </context> <inputs> - What to include: [E.G. DISK USAGE, ERROR COUNT FROM A LOG, NEW SIGNUPS FROM A QUERY, BACKUP STATUS] - How to fetch each: [COMMAND OR QUERY PER ITEM] - Delivery: [mail/sendmail / SLACK OR DISCORD WEBHOOK / SES] - Recipient(s): [ADDRESS OR CHANNEL] - Subject line format: [E.G. Daily report โ€” HOSTNAME โ€” DATE] </inputs> <task> Write a Bash script that runs each fetch step, formats the results into a clean plain-text (or simple HTML) digest with a header and one section per metric, then delivers it via the chosen channel. Handle a failed fetch by including an error line for that item rather than aborting the whole report. Log delivery success/failure. Comment how each metric is gathered and the delivery block. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail (but isolate each fetch so one failure does not kill the digest). - Cron-safe: absolute paths, no prompts. Do not embed secrets inline; read tokens from env. - Keep the message concise and skimmable. </constraints> <format> Return the full script in one code block, then give the crontab line for a daily send and explain how to add a new metric section. </format>

Builds a cron digest script that gathers metrics and emails or posts a daily summary, ready to schedule.

๐Ÿ’ก

Pro tip: Isolate each metric fetch so a single broken query shows an error line instead of silently killing the whole digest.

Most people use 10% of Claude. Tutorials unlock the rest.

AI Academy: 300+ hands-on tutorials on Claude, ChatGPT, Midjourney, and 50+ AI tools. New tutorials added every week.

Start Your Free Trial

Text Processing (grep / awk / sed)

5 prompts

Access Log Analyzer (awk)

26/30

You are a Bash and awk expert who writes log-analysis one-shot scripts. <context> I need one self-contained Bash script that parses a web server access log and prints a useful summary, so I can save it and run it against any log file. </context> <inputs> - Log file path: [PATH] - Log format: [COMMON/COMBINED NGINX/APACHE, OR DESCRIBE FIELD ORDER] - What to report: [TOP IPS, TOP URLS, STATUS-CODE BREAKDOWN, TOP 4xx/5xx PATHS, REQUESTS PER HOUR] - Time window filter: [E.G. TODAY, LAST HOUR, OR ALL] - Top-N size: [E.G. 20] </inputs> <task> Write a Bash script that uses awk to parse the chosen log format and produce each requested report as a clean, aligned table (rank, count, value), sorted descending. Include totals (total requests, unique IPs, error rate). Support reading from a file or stdin so it can be piped. Comment the awk field mapping and each aggregation. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Do the heavy lifting in a single awk pass where possible; avoid slow shell loops over lines. - Handle a missing or empty log file with a clear message; align columns with printf or column -t. </constraints> <format> Return the full script in one code block, then explain how to adapt the awk field numbers to a custom log format and how to pipe zcat of a gzipped log into it. </format>

Generates an awk-powered access-log analyzer producing top IPs, URLs, and status breakdowns, ready to run.

๐Ÿ’ก

Pro tip: Pipe gzipped logs straight in with zcat access.log.gz | ./analyze.sh โ€” the script reads stdin too.

CSV Column Extractor & Transformer (awk)

27/30

You are an awk and Bash expert who writes reliable CSV-processing scripts. <context> I need one self-contained Bash script that extracts, reorders, filters, or computes columns from a CSV file using awk, so I can reshape data without a spreadsheet. </context> <inputs> - Input CSV path and whether it has a header: [PATH, HEADER YES/NO] - Delimiter: [COMMA / TAB / OTHER] - Columns to keep and in what order: [E.G. 1,3,2 OR BY HEADER NAME] - Filter condition: [E.G. COLUMN 4 > 100, OR NONE] - Computed column: [E.G. ADD A TOTAL = col2*col3, OR NONE] </inputs> <task> Write a Bash script that uses awk with the correct field separator to select and reorder the requested columns, apply the optional row filter, and append any computed column, preserving or regenerating the header. Print the result to stdout (redirectable to a new file). Note the limitation with quoted fields containing the delimiter and how to handle it. Comment the FS/OFS setup and the filter/compute logic. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Set FS and OFS correctly; keep the header aligned with the reordered columns. - Warn (in a comment and at runtime if detected) that naive awk splitting breaks on quoted commas, and suggest a real CSV tool for that case. </constraints> <format> Return the full script in one code block, then explain selecting columns by header name vs number and when to reach for csvkit instead. </format>

Produces an awk CSV tool that extracts, reorders, filters, and computes columns, ready to run.

๐Ÿ’ก

Pro tip: For CSVs with quoted commas inside fields, heed the warning and use a real CSV parser โ€” awk field splitting will corrupt them.

Bulk Find & Replace Across Files (sed)

28/30

You are a Bash and sed expert who writes safe in-place editing scripts. <context> I need one self-contained Bash script that finds a string or pattern across many files and replaces it, with a preview and a backup, so I never corrupt a codebase. </context> <inputs> - Directory to search: [PATH] - File filter: [E.G. *.js, *.md, OR ALL TEXT FILES] - Search pattern: [LITERAL STRING OR REGEX] - Replacement: [TEXT] - Recursive: [YES / NO], case-sensitive: [YES / NO] </inputs> <task> Write a Bash script that lists every match first (with file and line) as a preview under a default --dry-run, then, only with --apply, performs the sed substitution in place while creating a .bak of each changed file. Report how many files and lines changed. Escape the pattern and replacement for sed safely, and skip binary files. Comment the escaping and the portable in-place editing (GNU vs BSD sed -i). </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Default is DRY-RUN; --apply is required to modify files and must write .bak backups. - Handle the sed -i portability difference between Linux and macOS; use grep -Il to skip binaries and survive spaces in paths. </constraints> <format> Return the full script in one code block, then explain how to review changes with the .bak files and how to escape special regex characters in the pattern. </format>

Builds a preview-first bulk find-and-replace script with per-file backups and portable sed -i, ready to run.

๐Ÿ’ก

Pro tip: Read the dry-run match list carefully before --apply โ€” the .bak files are your undo, so keep them until you've verified the diff.

Pattern Extractor & Counter (grep)

29/30

You are a Bash and grep expert who writes text-mining scripts. <context> I need one self-contained Bash script that extracts all occurrences of a pattern from files (e.g. emails, IPs, error codes, URLs), counts and ranks them, so I can save and reuse it. </context> <inputs> - Files or directory to search: [PATH OR GLOB] - What to extract: [E.G. EMAIL ADDRESSES / IPv4 / URLS / A CUSTOM REGEX] - Recursive: [YES / NO] - Output: [UNIQUE SORTED LIST / RANKED BY FREQUENCY / RAW MATCHES] - Optional: also show the file each match came from: [YES / NO] </inputs> <task> Write a Bash script that runs grep -Eo with the appropriate regex to pull only the matching substrings, then pipes through sort and uniq -c to rank by frequency (or just dedupe) per the chosen output. Provide ready-made regexes for email, IPv4, and URL, and allow a custom pattern. Print a clean ranked table. Comment each provided regex and the sort | uniq -c pipeline. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Use grep -Eo for match-only extraction; use -r only when recursive is chosen. - Note the limits of regex email/URL matching in a comment; handle no-matches gracefully. </constraints> <format> Return the full script in one code block, then explain how to plug in a custom regex and how to feed piped input from another command. </format>

Generates a grep extractor that pulls and frequency-ranks emails, IPs, or URLs from files, ready to run.

๐Ÿ’ก

Pro tip: The sort | uniq -c | sort -rn pipeline is the workhorse โ€” swap in any grep -Eo pattern to rank whatever you need.

Safe Config File Editor (sed)

30/30

You are a Bash and sed expert who automates config-file edits safely. <context> I need one self-contained Bash script that sets or updates a key-value setting in a config file (e.g. add the line if missing, replace it if present) without duplicating entries, so it is safe to run repeatedly. </context> <inputs> - Config file path: [PATH] - Setting format: [E.G. KEY=VALUE, key value, key: value] - Key to set: [KEY] - New value: [VALUE] - Comment character to respect: [E.G. #] </inputs> <task> Write a Bash script that backs up the config file, then uses sed/grep to check whether the key already exists (uncommented): if it does, replace its value in place; if it exists only commented out, uncomment and set it; if it is absent, append the setting. Guarantee exactly one active line for the key (idempotent). Print a before/after diff of the changed line. Comment the three-case logic and the escaping. </task> <constraints> - #!/usr/bin/env bash, set -euo pipefail. - Always back up the file first; escape the value for sed (slashes, ampersands) and use a delimiter unlikely to collide. - Running twice with the same input must leave the file unchanged (true idempotency); handle the portable sed -i difference. </constraints> <format> Return the full script in one code block, then explain how to extend it to multiple keys and how to verify idempotency by running it twice. </format>

Produces an idempotent config-editor script that sets a key exactly once with a backup and diff, ready to run.

๐Ÿ’ก

Pro tip: Run it twice and confirm the second run reports no change โ€” that's the proof the edit is truly idempotent.

Frequently Asked Questions

A complete, ready-to-run script. Each prompt asks for a full file starting with a shebang and set -euo pipefail, with comments on every block, argument parsing, and error handling. You copy it into a .sh file, chmod +x it, and run it.
They are built to be. The prompts insist on dry-run defaults for anything destructive, backups before edits, existence and permission checks, and refusing dangerous paths. Still read the script and test it in a scratch directory before pointing it at real data or production.
Mostly yes. The prompts explicitly ask Claude to handle portability differences like GNU vs BSD sed -i and date, and free vs vm_stat for memory. Tell Claude your exact OS in the inputs and it will target the right commands.
Yes. The cron-focused prompts produce jobs that use absolute paths, avoid interactive prompts, return meaningful exit codes, and use flock to prevent overlapping runs. Each one also gives you the exact crontab line to schedule it.
Fill in the bracketed placeholders in the prompt with your paths, thresholds, and commands before sending it. After Claude replies, you can paste an error or ask it to add a flag, change the retention, or adapt it to a different tool, and it will revise the script.

Prompts are the starting line. Tutorials are the finish.

A growing library of 300+ hands-on tutorials on ChatGPT, Claude, Midjourney, and 50+ AI tools. New tutorials added every week.

7-day free trial. Cancel anytime.