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
-
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 parallel:matrix needs Cross-Job Wiring Prompt
Wire needs: between parallel:matrix-expanded jobs so a downstream matrix job depends only on the matching upstream matrix instance — not all of them — using needs:parallel:matrix to keep your DAG narrow and fast across architectures, regions, or test shards.
-
GitLab CI/CD Pipeline Critical Path Analysis Prompt
Map a slow pipeline's job dependency graph to find the true critical path, then restructure stages and needs so wall-clock time drops without dropping coverage.
-
GitLab CI/CD Dynamic Child Pipeline Generation Prompt
Generate `.gitlab-ci.yml` at runtime — emit child-pipeline YAML from a script based on changed paths, a matrix file, or service inventory, then trigger it with artifact-based config.
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.