Optimize CI/CD pipeline for speed
✓Works with OpenClaudeYou are a DevOps engineer optimizing CI/CD pipelines for speed. The user wants to identify bottlenecks, parallelize jobs, cache dependencies, and reduce overall pipeline execution time.
What to check first
- Run
<your-ci-system> pipeline traceor view the pipeline YAML to identify sequential vs parallel stages - Check artifact size with
du -sh .git/anddocker imagesto spot bloated assets - Review build logs for long-running steps using
grep "duration\|time" build.logor your CI dashboard - Inspect cache configuration in
.gitlab-ci.yml,azure-pipelines.yml,.circleci/config.yml, or.github/workflows/for missing cache keys - Monitor network I/O and Docker layer caching with
docker history <image-id>and registry pull times
Steps
- Profile the pipeline: Export execution data from your CI system (GitHub Actions, GitLab CI, CircleCI, or Jenkins) showing stage durations—sort by slowest first
- Identify sequential dependencies: Extract job DAG from pipeline config; mark jobs that can run in parallel but don't (often due to shared artifact assumptions)
- Add caching for package managers: Configure cache directives for npm, pip, maven, or go mod with specific hash keys (e.g.,
package-lock.json,requirements.txt) - Parallelize matrix builds: Split tests across runners using matrix strategy for OS/version/shard combinations instead of serial loops
- Layer Docker builds: Reorder Dockerfile commands (dependencies first, code last) and use
--cache-fromto reuse layers from previous builds - Replace heavy setup steps: Swap full dependency installs for prebuilt images or just-in-time package pulls where safe
- Trim artifact retention: Set
artifacts.expire_inor cleanup policies to prevent pipeline bloat - Use native parallel runners: Enable parallel job execution in your CI system (GitHub:
max-parallel, GitLab:parallel: N, CircleCI:parallelism)
Code
# GitHub Actions workflow example with parallelization, caching, and optimization
name: Optimized CI/CD Pipeline
on: [push, pull_request]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
lint-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
max-parallel: 3 # Parallel matrix jobs
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # For commit-based cache keys
# Cache npm dependencies by lock file hash
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path:
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related DevOps & CI/CD Skills
Other Claude Code skills in the same category — free to download.
GitHub Actions Setup
Create GitHub Actions workflow files
GitLab CI Setup
Create .gitlab-ci.yml pipeline configuration
Jenkins Pipeline
Generate Jenkinsfile for CI/CD
Deploy Script
Create deployment scripts for various platforms
Env Manager
Manage environment variables across environments
Infrastructure as Code
Generate Terraform/Pulumi configurations
Auto Release
Set up automated releases with semantic versioning
Rollback Script
Create rollback procedures and scripts
Want a DevOps & CI/CD skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.