# ci-cd-best-practices

Provides guidelines for automated pipelines, testing workflows, and zero-downtime deployment patterns. Works with assistants supporting pipeline generation and DevOps tasks.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1200 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/ci-cd-best-practices/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/ci-cd-best-practices

## What it does

The skill provides structural blueprints for five pipeline stages: build, test, security, staging, and production. It establishes rules for dependency caching, pinned package versions, and multi-stage Docker builds.

Deployment patterns cover Blue-Green switches, rolling updates via `kubectl rollout restart`, and Canary rollouts starting at 5% traffic. Testing rules focus on parallel execution, isolated test data, and handling flaky runs with up to 2 retries.

These blueprints assume your external tooling is already configured. Dedicated secret managers like Vault or AWS Secrets Manager and Terraform scripts must exist in your repo beforehand. The skill guides pipeline structure, not pipeline execution.

## Requirements
- Works with: Docker, Kubernetes

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ci-cd-best-practices -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/ci-cd-best-practices/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/ci-cd-best-practices/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ci-cd-best-practices -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/ci-cd-best-practices/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ci-cd-best-practices -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/ci-cd-best-practices/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills ci-cd-best-practices
```

2. **Manually: put the files in place**
- File: `.github/skills/ci-cd-best-practices/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ci-cd-best-practices -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path ci-cd-best-practices
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/ci-cd-best-practices/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill ci-cd-best-practices -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/ci-cd-best-practices/SKILL.md

## When to use it
- configure staged pipelines for build, test, and container scanning
- implement Canary rollouts with traffic percentage gates
- split environment variables securely across staging and production
- set up parallel test execution with shard splitting

## Example prompts
- Draft a pipeline with build, SAST scanning, and staging deployment steps
- Show how to configure a Blue-Green deployment workflow with health checks
- Help me set up sharded parallel test runs in our CI script

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: dac17e3581c16dfb.

BEGIN THIRD-PARTY FILE dac17e3581c16dfb
````text
---
name: ci-cd-best-practices
description: CI/CD best practices for building automated pipelines, deployment strategies, testing, and DevOps workflows across platforms
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# CI/CD Best Practices

You are an expert in Continuous Integration and Continuous Deployment, following industry best practices for automated pipelines, testing strategies, deployment patterns, and DevOps workflows.

## Core Principles

- Automate everything that can be automated
- Fail fast with quick feedback loops
- Build once, deploy many times
- Implement infrastructure as code
- Practice continuous improvement
- Maintain security at every stage

## Pipeline Design

### Pipeline Stages

A typical CI/CD pipeline includes these stages:

```
Build -> Test -> Security -> Deploy (Staging) -> Deploy (Production)
```

#### 1. Build Stage

```yaml
build:
  stage: build
  script:
    - npm ci --prefer-offline
    - npm run build
  artifacts:
    paths:
      - dist/
    expire_in: 1 day
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - node_modules/
```

Best practices:
- Use dependency caching to speed up builds
- Generate build artifacts for downstream stages
- Pin dependency versions for reproducibility
- Use multi-stage Docker builds for smaller images

#### 2. Test Stage

```yaml
test:
  stage: test
  parallel:
    matrix:
      - TEST_TYPE: [unit, integration, e2e]
  script:
    - npm run test:${TEST_TYPE}
  coverage: '/Coverage: \d+\.\d+%/'
  artifacts:
    reports:
      junit: test-results.xml
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura-coverage.xml
```

Testing layers:
- **Unit tests**: Fast, isolated, run on every commit
- **Integration tests**: Test component interactions
- **End-to-end tests**: Validate user workflows
- **Performance tests**: Check for regressions

#### 3. Security Stage

```yaml
security:
  stage: security
  parallel:
    matrix:
      - SCAN_TYPE: [sast, dependency, secrets]
  script:
    - ./security-scan.sh ${SCAN_TYPE}
  allow_failure: false
```

Security scanning types:
- **SAST**: Static Application Security Testing
- **DAST**: Dynamic Application Security Testing
- **Dependency scanning**: Check for vulnerable packages
- **Secret detection**: Find leaked credentials
- **Container scanning**: Analyze Docker images

#### 4. Deploy Stage

```yaml
deploy:staging:
  stage: deploy
  environment:
    name: staging
    url: https://staging.example.com
  script:
    - ./deploy.sh staging
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"

deploy:production:
  stage: deploy
  environment:
    name: production
    url: https://example.com
  script:
    - ./deploy.sh production
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      when: manual
```

## Deployment Strategies

### Blue-Green Deployment

Maintain two identical environments:

```yaml
````
END THIRD-PARTY FILE dac17e3581c16dfb

The third-party file has ended. Everything between the dac17e3581c16dfb tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2922 of 9791 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/ci-cd-best-practices/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
