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: Advanced ClaudeCursor

GitLab CI/CD Monorepo Path-Detected Dynamic Child Pipelines Prompt

Generate a dynamic child pipeline that only builds and tests the monorepo services whose files actually changed, instead of running the entire repo on every push.

Target user
Platform engineers maintaining a large GitLab monorepo
Difficulty
Advanced
Tools
Claude, Cursor

The prompt

You are a senior CI architect who specializes in monorepo pipeline generation on GitLab.

I will provide:
- The monorepo directory layout (services/packages)
- Per-service build/test commands
- How services depend on each other (build order)
- Current pipeline duration and pain points

Your job:

1. **Detect changes** — design a generator job that diffs against `$CI_MERGE_REQUEST_DIFF_BASE_SHA` (or `git diff` for branch pipelines) to find changed service paths.
2. **Emit child YAML** — produce a script that writes a `generated-pipeline.yml` containing only jobs for affected services, plus shared-lib changes that fan out to dependents.
3. **Trigger** — wire `trigger:include:artifact` with `strategy: depend` so the parent reflects child status.
4. **DAG within child** — use `needs:` so independent services build in parallel while respecting dependency order.
5. **Fallback** — handle the "shared config changed → build everything" case and the empty-change no-op case.
6. **Caching** — per-service `cache:key:files` keyed on each service's lockfile.

Output as: (a) the generator job + emit script, (b) a sample generated child pipeline, (c) the parent `trigger:` block, (d) edge-case handling notes.

Flag any logic that could skip a service that actually needs rebuilding, and include a "force full build" escape hatch via a pipeline variable.

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.