---
name: ci-pipeline-design
description: "A CI pipeline redesign that fails fast, runs in parallel where it safely can, caches well, and quarantines flaky tests, with a target total runtime and a list of what to cut to reach it. Use when a CI pipeline is slow, flaky, or expensive and needs its stages reordered, parallelised, cached, and trimmed to a target runtime. Do not use for writing deployment or release automation, or fixing one failing build. Related topics: Engineering, Technical, Productivity."
---

# CI Pipeline Design

A CI pipeline redesign that fails fast, runs in parallel where it safely can, caches well, and quarantines flaky tests, with a target total runtime and a list of what to cut to reach it.

## When to use

Use this skill when a CI pipeline is slow, flaky, or expensive and needs its stages reordered, parallelised, cached, and trimmed to a target runtime. Do not use it for writing deployment or release automation, or fixing one failing build.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Order the stages so the cheapest checks fail first and slow end-to-end tests run last.
3. Mark which stages can run in parallel and which depend on another stage, with the reason for each dependency.
4. Define a cache for dependencies and build artefacts with a key that invalidates only when its inputs change.
5. Split the commit-blocking checks from main-only and nightly jobs, and quarantine flaky tests rather than retrying them.
6. Set a target runtime for the blocking path and list the exact steps to cut or move to reach it.

## Inputs

- **Project** (longer free text)
- **Pipeline today** (longer free text)
- **Test suite** (longer free text)
- **Platform** (choose one: GitHub Actions, GitLab CI, CircleCI, Jenkins, Buildkite)
- **Team size and commits per day** (free text, e.g. "Both")
- **What hurts** (choose any: Too slow, Flaky tests, Unclear failures, Expensive, Blocks releases)

## Output

A stage table with columns stage, runs when, parallel with, cache, and expected time, then a config skeleton for the chosen platform and a numbered list of cuts to reach the target runtime.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### CI Pipeline Design

Redesign my CI pipeline so it is fast enough that nobody reaches for the skip-ci flag.

- Project: {{Project}}
- Pipeline today: {{Pipeline today}}
- Test suite: {{Test suite}}
- Platform: {{Platform}}
- Team size and commits per day: {{Team size and commits per day}}
- What hurts: {{What hurts}}

Order the stages so the cheapest checks fail first: lint and type checks before unit tests, unit tests before integration, slow end-to-end last. Say which stages can truly run in parallel and which depend on another's output. Give a caching plan for dependencies and build artefacts, with the cache key for each so it invalidates only when it should. Split what runs on every commit from what runs only on main or nightly. Treat flaky tests as a defect: identify them, quarantine them from the blocking path, and track them to a fix, rather than adding retries everywhere. Set a target total runtime for the blocking path and name the specific steps to cut or move to reach it. Make failures readable by saying which stage output a developer should look at first. Return the pipeline as a stage table (stage, runs when, parallel with, cache, expected time) followed by the config skeleton for the chosen platform and the list of cuts.

## Pitfalls

- Adding blanket retries to hide flaky tests, which doubles runtime and lets real failures slip through.
- Using a cache key that never changes, so stale dependencies are served after a lockfile update.
- Parallelising stages that share a build artefact, so jobs race and fail intermittently.
