Dotfiles and Workstation Bootstrap Installer Prompt
Generate an idempotent bootstrap script that sets up a fresh workstation — installs packages, symlinks dotfiles, and configures shells/tools — safely re-runnable, backing up existing files instead of clobbering them, across macOS and Linux.
- Target user
- Developers who want a reproducible, one-command machine setup
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a senior developer-experience engineer who has bootstrapped hundreds of laptops and knows the script must be safe to run on day 1 AND on a machine you've been using for a year. I will provide: - My dotfiles repo layout (which files map where) - Target OSes (macOS, Ubuntu/Debian, etc.) and package manager(s) - The tools to install (shell, editor, languages, CLIs) Your job: 1. **Idempotent above all** — every step must be safe to re-run. Check-then-act: skip installed packages, skip existing symlinks that already point correctly, never blindly overwrite. The 5th run should be a fast no-op, not a re-install. 2. **OS detection** — detect OS (`uname`, `/etc/os-release`) and pick the package manager (`brew`, `apt`, `dnf`). Abstract installs behind a `pkg_install` function so the rest of the script is OS-agnostic. State what's unsupported rather than guessing. 3. **Safe dotfile linking** — symlink dotfiles from the repo into `$HOME`. Before linking, if a real (non-symlink) file exists, BACK IT UP to a timestamped `~/.dotfiles-backup/` directory — never delete a user's existing config. If the correct symlink already exists, do nothing. 4. **Package installs** — install in groups (core, dev, optional) so a failure in one group doesn't abort everything. Make brew/apt non-interactive and pin where reproducibility matters. Run package-manager update once, not per-package. 5. **Shell + tool config** — set the default shell only if not already set; append to shell rc files using a guarded block (marker comments) so re-runs don't duplicate lines. Configure git identity only if unset. 6. **Safety + dry-run** — `set -euo pipefail`, a `--dry-run` that prints actions without executing, and a clear summary at the end (installed / skipped / backed-up). Never require running the whole thing as root; sudo only the specific commands that need it, and prompt clearly. 7. **Bootstrap entry** — a single `./install.sh` (or `curl ... | bash` ONLY if you also publish a checksum and the user opts in) that clones the repo if missing and runs the steps in order. Output: (a) the full bootstrap script with the pkg_install abstraction, (b) the guarded symlink+backup function, (c) the dry-run/summary output, (d) a re-run-safety note proving the 2nd run is a no-op. Bias toward: idempotency, backing up over clobbering, and minimal privilege.
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
-
Python Bulk File Processing Script Prompt
Build a safe, idempotent batch file-processing script in Python that walks directories, transforms or renames files atomically, handles huge datasets without exhausting memory, and can resume after interruption.
-
Bash Multi-Repo Git Bulk Command Runner Prompt
Build a Bash script that runs the same git or shell command across many local repositories with per-repo isolation, dirty-tree guards, and an aggregated pass/fail summary
-
Bash GPG Secrets Encrypt/Decrypt Workflow Prompt
Build a Bash workflow that encrypts and decrypts secret files with GPG for git-committable storage, with strict permissions, no plaintext left on disk, and safe handling in automation
-
Bash Safe In-Place sed Edit Wrapper Prompt
Build a Bash wrapper around sed -i that backs up, validates, and atomically applies in-place edits so a bad expression can never corrupt or truncate config files
More Bash & Python Automation prompts & error guides
Browse every Bash & Python Automation prompt and troubleshooting guide in one place.
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.