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
- Target user
- engineers who automate ops with Bash and Python
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are an automation engineer who maintains dozens of related git repositories and needs to run the same operation (pull, checkout, status, or an arbitrary command) across all of them safely. I will provide: - A directory (or list) of repo paths to iterate over - The command to run in each repo (git or arbitrary shell) - Rules for what should block a repo — e.g. skip repos with uncommitted changes, or only act on a given branch Your job: 1. **Discover repos** — find directories containing `.git` under the root, and iterate deterministically (sorted), skipping non-repos. 2. **Isolate each run** — run each repo in a subshell so a `cd` or failure in one never leaks into the next, and never let one repo's non-zero exit abort the whole loop. 3. **Guard destructive actions** — before pull/checkout/reset, check `git status --porcelain`; skip (and record) any repo with a dirty working tree unless an explicit `--force` is passed. Detect the current branch and honor a `--branch` filter. 4. **Capture per-repo output** — collect stdout/stderr, exit code, and elapsed time for each repo without interleaving output from parallel runs. 5. **Optional parallelism** — offer a bounded-concurrency mode (e.g. via `xargs -P` or background jobs with a job cap) while keeping output attributable to each repo. 6. **Summarize** — print an aligned table of repo → status (OK / SKIPPED / FAILED) at the end and exit non-zero if any repo failed. Output as: the full script (`set -euo pipefail`) in one fenced block, then example invocations for status-all, guarded-pull-all, and running an arbitrary command. Default to read-only and skip-dirty behavior; require an explicit flag before any command that can lose local work.
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
-
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
-
Bash Health-Gated Service Restart Orchestrator Prompt
Build a Bash script that restarts services one at a time, waits for each to pass a health check before moving on, and rolls back or aborts on failure to avoid taking a whole fleet down at once
-
Bash TCP Port Connectivity Diagnostic Prompt
Build a Bash script that checks TCP reachability to a set of host:port dependencies, times each connection, and produces a clear reachable/unreachable report for pre-flight or incident triage
-
Bash Nameref (declare -n) Indirect-Variable Script Prompt
Write a Bash script that uses namerefs (declare -n) to pass arrays and associative arrays into functions by reference and return structured results, replacing brittle eval-based indirection.
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.