Skip to content
📦 Technology & EngineeringDevops Cloud68 lines

CI/CD Pipelines

Design and maintain continuous integration and continuous delivery pipelines

Paste into your CLAUDE.md or agent config

CI/CD Pipelines

Core Philosophy

Continuous integration and continuous delivery transform software delivery from a manual, error-prone event into an automated, repeatable process. CI ensures that every code change is validated by automated builds and tests within minutes of being committed. CD extends this by automating the path from validated code to production deployment. The goal is to make releases boring — small, frequent, and low-risk rather than large, rare, and terrifying.

Key Techniques

  • Pipeline as Code: Define build, test, and deploy steps in version-controlled configuration files (YAML, Groovy, HCL) that live alongside the application code and evolve with it.
  • Parallel Stage Execution: Run independent pipeline stages concurrently — linting, unit tests, integration tests, security scans — to minimize total pipeline duration.
  • Artifact Promotion: Build artifacts once, then promote the same binary through staging, QA, and production environments rather than rebuilding at each stage.
  • Branch-Based Workflows: Use branch protection rules and pull request pipelines to gate merges on passing checks, enforcing quality before code reaches main.
  • Canary and Blue-Green Deployments: Deploy to a subset of production traffic first, validate metrics, then roll forward or back automatically.
  • Secret Management: Inject credentials and API keys at runtime from a vault rather than storing them in pipeline configuration or environment variables.

Best Practices

  • Keep pipeline execution under 10 minutes. Developers stop waiting and context-switch on longer pipelines, defeating the purpose of fast feedback.
  • Fail fast by running the quickest checks (lint, compile, unit tests) first.
  • Cache dependencies aggressively — package managers, Docker layers, compiled objects.
  • Make pipelines idempotent. Re-running the same pipeline on the same commit should produce identical results.
  • Use ephemeral build agents that start clean for every run, eliminating state drift.
  • Tag every artifact with the commit SHA and build number for full traceability.
  • Monitor pipeline reliability as a metric. Flaky pipelines erode team trust.

Common Patterns

  • Trunk-Based Development: All developers commit to main frequently with short-lived feature branches, relying on CI to catch integration issues immediately.
  • Monorepo Pipelines: Detect which projects changed and run only affected pipelines, avoiding full-repo builds on every commit.
  • Environment Promotion: dev → staging → production with automated gates (test pass rates, performance thresholds) between each stage.
  • Rollback Pipelines: One-click automated rollback to the previous known-good deployment when production issues are detected.

Anti-Patterns

  • Manual steps in the middle of an otherwise automated pipeline. Every manual gate is a bottleneck and a source of human error.
  • Running the entire test suite on every commit without parallelization or selective testing, creating unacceptable feedback delays.
  • Storing secrets in pipeline YAML or environment variables visible in logs.
  • Not versioning pipeline definitions alongside application code, making it impossible to reproduce historical builds.
  • Treating pipeline failures as someone else's problem. The developer who broke the build should fix it immediately.
  • Building different artifacts for different environments instead of promoting a single immutable artifact.