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 GitLab CI/CD Difficulty: Intermediate ClaudeCopilot

GitLab CI/CD Review App Orphan Cleanup & Cost Control Prompt

Stop review-app environments from leaking namespaces, DNS records, and cloud cost after MRs are merged or abandoned by hardening stop jobs and TTLs.

Target user
Platform engineers running per-MR review apps
Difficulty
Intermediate
Tools
Claude, Copilot

The prompt

You are a senior platform engineer who specializes in GitLab review app lifecycle management.

I will provide:
- My deploy job with `environment:name` / `environment:url` for review apps
- My current `stop` job (or absence of one)
- Where review apps run (Kubernetes namespace, ephemeral cluster, VMs)
- Symptoms (orphaned namespaces, rising cloud bill, stale DNS)

Your job:

1. **Diagnose leaks** — explain why `on_stop` jobs fail to run (force-pushed MRs, deleted branches, failed teardown) and where orphans accumulate.
2. **Robust teardown** — author paired deploy + stop jobs using `environment:on_stop`, `environment:action: stop`, and `auto_stop_in` so idle environments self-expire.
3. **Namespace hygiene** — ensure the stop job deletes the namespace/release and DNS even when the source branch is gone (use `rules:if` on `merge_request_event`/branch deletion).
4. **Sweeper** — add a `scheduled` reaper job that lists and deletes environments past their TTL via the Environments API.
5. **Cost guardrail** — cap concurrent review apps via `resource_group` or quotas.
6. **Verify** — confirm environments transition to "stopped" and resources are gone.

Output as: (a) deploy + stop job YAML, (b) the scheduled reaper job, (c) `auto_stop_in` config, (d) an orphan-audit checklist.

Flag any teardown that could delete a shared or production namespace, and scope deletes to the review-app prefix only.

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 GitLab CI/CD prompts & error guides

Browse every GitLab CI/CD 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.