Agent skill
cicd-patterns
CI/CD pipeline patterns for GitHub Actions including deployment strategies and pipeline security. Use when designing pipelines, deployment strategies, or writing workflow YAML. Do NOT use for Infrastructure as Code (Terraform, CDK, CloudFormation) -- use cdk-patterns instead. Do NOT use for Git Flow or multi-branch release workflows.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/cicd-patterns
SKILL.md
CI/CD Pipeline Patterns
Principles for CI/CD pipeline design. Assumes trunk-based development (single main branch, no Git Flow).
Pipeline Stage Ordering
Security scanning runs BEFORE tests and builds. A vulnerability found after a 20-minute test suite wastes CI minutes.
checkout -> security-scan -> test -> build -> deploy -> verify
Security Scanning Order
Run scans in order of speed and severity impact:
- SAST (Static Analysis) -- Fastest, catches code-level vulnerabilities
- Secrets scanning -- Prevents credential leaks before they reach remote
- Dependency scanning -- Identifies known CVEs in dependencies
- Container scanning -- Scans built images for OS-level vulnerabilities (runs after build stage)
For security scanning tool details, see security-patterns skill.
GitHub Actions Patterns
Trunk-Based Pipeline Structure
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
security-scan:
# Runs first, no dependencies
test:
needs: security-scan
build:
needs: test
deploy:
needs: build
if: github.ref == 'refs/heads/main' # Deploy only from main
Key Principles
- Pin action versions by SHA, not tag (e.g.,
actions/checkout@<sha>not@v4). Tags are mutable. - Minimize secret exposure: Use
environmentprotection rules. Restrict deploy secrets to the deploy job only. - Cache dependencies between jobs to reduce build time (actions/cache or setup-* cache options).
- Fail the pipeline on audit warnings for production branches. Use
--audit-level highor equivalent.
Deployment Strategies
Decision Heuristic
| Strategy | When to use | Trade-off |
|---|---|---|
| Rolling | Stateless services, high replica count, tolerance for mixed versions | Simplest. Temporary version inconsistency during rollout. |
| Blue-Green | Stateful services, need instant rollback, zero mixed-version tolerance | Full duplicate environment cost. Instant rollback by traffic switch. |
| Canary | High-traffic services, need gradual risk validation, metrics-driven decisions | Most complex. Requires good observability to evaluate canary health. |
For zero-downtime database migrations during deployments, see database-patterns skill.
Anti-Patterns
| Anti-Pattern | Why it fails | Correct approach |
|---|---|---|
| Running security scans after build | Wastes CI minutes on vulnerable code | Security scan as first pipeline stage |
Mutable action version tags (@v4) |
Supply chain risk -- tag can be moved to malicious commit | Pin by SHA |
| Destructive DB migration + code change in one deploy | Old instances crash when column disappears | Two-phase migration (see database-patterns) |
| Manual rollback only | MTTR measured in human response time, not seconds | Automated rollback with metric thresholds |
| Deploying from feature branches | Bypasses trunk integration testing | Deploy only from main branch |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?