Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for GitLab CI/CD Difficulty: Advanced ClaudeChatGPT

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.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week