GitLab CI/CD YAML Merge & !reference Conflict Debug Prompt
Resolve jobs that get the wrong merged configuration when extends, YAML anchors, !reference tags, and include overrides collide, producing silently dropped scripts, lost variables, or unexpected rules.
- Target user
- DevOps engineers maintaining large .gitlab-ci.yml files
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior GitLab CI/CD engineer who untangles broken config merges from extends, anchors, and !reference. I will provide: - The affected job plus every hidden job, anchor, and template it pulls from (`extends:`, `<<: *anchor`, `!reference [job, key]`) - Relevant `include:` entries and any global `default:` block - The merged result from the pipeline editor's "View merged YAML" (or what GitLab actually ran) - What I expected versus what happened (e.g. before_script vanished, rules overwritten) Your job: 1. **Trace the merge order** — lay out the precedence: `include` < `default` < `extends` (depth-first, deep-merged) < job-level keys, and where the conflict resolves. 2. **Find the override** — pinpoint which layer is winning each contested key, distinguishing deep-merged maps (variables, rules-by-key) from fully-replaced scalars/arrays (script, before_script). 3. **Explain anchors vs extends** — note that `<<:` merges at YAML-parse time (no deep merge of arrays) while `extends` merges in GitLab; mixing them is a common foot-gun. 4. **Audit !reference** — confirm each `!reference [job, key]` points at the intended key and isn't pulling stale or circular content. 5. **Rewrite cleanly** — propose a corrected structure (prefer `extends` + small hidden jobs over deep anchor nesting), keeping behavior explicit. 6. **Verify** — show how to confirm with the pipeline editor merged view and `glab ci lint` / CI Lint before pushing. Output as: (a) merged-key trace table, (b) the broken key and why, (c) corrected YAML snippet, (d) one rule of thumb to prevent recurrence.
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
-
GitLab CI/CD extends, YAML Anchors & !reference Prompt
Refactor a sprawling .gitlab-ci.yml using extends:, hidden .jobs, YAML anchors, and the !reference tag to kill duplication while keeping the pipeline readable and debuggable.
-
GitLab CI/CD before_script to extends Refactor Prompt
Refactor sprawling, duplicated before_script and inline shell across jobs into reusable hidden jobs, extends, and !reference so setup logic is defined once, tested, and consistent across the pipeline.
-
GitLab CI/CD needs: Graph Deadlock & Missing-Job Debug Prompt
Debug DAG pipelines that error with 'job X needs Y which is not present', skip jobs unexpectedly, or run in the wrong order because needs:, stages, and rules disagree about which jobs exist in the graph.
-
GitLab CI/CD Stuck-Pending Job Runner Triage Prompt
Diagnose why GitLab CI jobs sit in pending or stuck status by correlating job tags, runner registration, concurrency limits, and runner logs so pipelines stop hanging without a runner picking them up.
More GitLab CI/CD prompts & error guides
Browse every GitLab CI/CD 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.