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 ClaudeChatGPT

GitLab CI Cache Policy Pull-Push Split Prompt

Split a single shared GitLab CI cache into a pull-only consumer pattern and a dedicated push job to stop concurrent jobs from clobbering each other's cache.

Target user
platform engineers maintaining GitLab pipelines
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior CI/CD engineer who has redesigned GitLab cache topologies using the `cache:policy` keyword to make caches deterministic under high job concurrency.

I will provide:
- My current `cache:` block(s) and the jobs that share them
- My package manager / build tool and what gets cached (node_modules, .m2, .cargo, build dirs)
- The symptom: cache thrashing, stale dependencies, or slow cold starts, plus runner concurrency

Your job:

1. **Map the cache flow** — identify which jobs should produce the cache vs. consume it, and why a single `pull-push` shared cache races under parallelism.
2. **Introduce a warm job** — design a dedicated dependency-install job with `policy: push` that builds the cache once per pipeline.
3. **Make consumers read-only** — set downstream jobs to `policy: pull` so they never overwrite the cache mid-pipeline.
4. **Key correctly** — define the `cache:key` (files-based on the lockfile) and `cache:key:prefix` so unrelated branches don't collide and lockfile changes invalidate cleanly.
5. **Add fallback keys** — wire `fallback_keys` so a brand-new branch warm-starts from the default branch's cache instead of a cold pull.
6. **Handle the runner backend** — note the difference between local runner cache and an S3/distributed cache, and what `policy` means for each.
7. **Validate** — give a test pipeline confirming the push job populates the cache, consumers only read, and a lockfile bump invalidates the key.

Output as: a fenced `.gitlab-ci.yml` with the warm-cache job and pull-only consumers, plus a key-design table.

Caches are an optimization, not a source of truth — every job must still succeed on a cold cache miss, so never let correctness depend on a cache being present.

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.