Skip to content

borghei/Claude-Skills / engineering/devops-workflow-engineer

devops-workflow-engineer

Flagged

Generate and optimize GitHub Actions CI/CD workflows. Use when designing workflows, planning multi-environment deployments, optimizing pipeline cost and runtime, or implementing blue-green, canary, or rolling deployment strategies.

references/workflows-and-optimization.md

View on GitHub
# CI/CD Workflows, Strategies, and Optimization

Read this when designing a CI or CD pipeline, choosing a deployment strategy, optimizing pipeline cost/runtime, applying GitHub Actions patterns, or troubleshooting workflows.

## Workflow 1: CI Pipeline Design

The agent generates pipelines following fail-fast ordering:

1. **Lint and format** (~30s) -- cheapest gate first
2. **Unit tests** (~2-5m) -- matrix across versions
3. **Build verification** (~3-8m)
4. **Integration tests** (~5-15m, parallel with build)
5. **Security scanning** (~2-5m)

```yaml
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - run: make lint

  test:
    needs: lint
    strategy:
      matrix:
        python-version: ['3.10', '3.11', '3.12']
    steps:
      - uses: actions/setup-python@v7
        with: { python-version: "${{ matrix.python-version }}", cache: pip }
      - run: pip install -r requirements.txt
      - run: pytest --junitxml=results.xml

  security:
    needs: lint
    steps:
      - run: pip-audit -r requirements.txt
```

**CI targets:**

| Metric | Target | Fix |
|--------|--------|-----|
| Total CI time | < 10 min | Parallelize, add caching |
| Lint step | < 1 min | Use pre-commit locally |
| Unit tests | < 5 min | Split suites, use matrix |
| Flaky rate | < 1% | Quarantine flaky tests |
| Cache hit rate | > 80% | Review cache keys |

## Workflow 2: CD Pipeline and Multi-Environment Deployment

```bash
python scripts/deployment_planner.py --type webapp --environments dev,staging,prod --format json
```

**Environment promotion flow:**
```
Build -> Dev (auto) -> Staging (auto) -> Production (manual approval)
                                              |
                                        Canary (10%) -> Full rollout
```

| Aspect | Dev | Staging | Production |
|--------|-----|---------|------------|
| Trigger | Every push | Merge to main | Manual approval |
| Replicas | 1 | 2 | 3+ (auto-scaled) |
| Secrets | Repository | Environment | Vault/OIDC |
| Monitoring | Basic logs | Full observability | Full + alerting |

**Key CD rules:**
- Build once, deploy the same artifact everywhere
- Tag artifacts with commit SHA for traceability
- Use environment protection rules for production gates
- Maintain rollback capability at every stage

## Workflow 3: Pipeline Optimization

```bash
python scripts/pipeline_analyzer.py .github/workflows/ --format json -o report.json
```

The agent checks for:

1. **Missing caching** -- dependencies reinstalled every run
2. **No timeouts** -- stuck jobs burn budget
3. **Sequential chains** that could parallelize
4. **Deprecated actions** with newer versions available
5. **Security issues** -- secrets in logs, missing permissions scoping
6. **Cost inefficiency** -- oversized runners, no path filtering

**Optimization techniques:**

**Path-based filtering** -- skip CI for docs-only changes:
```yaml
on:
  push:
    paths: ['src/**', 'tests/**', 'requirements*.txt']
    paths-ignore: ['docs/**', '*.md']
```

**Concurrency cancellation** -- cancel superseded runs:
```yaml
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
```

**Dependency caching:**
```yaml
- uses: actions/cache@v6
  with:
    path: ~/.cache/pip
    key: ${{ runner.os }}-deps-${{ hashFiles('**/requirements.txt') }}
```

## Deployment Strategies

**Decision tree:**
```
Zero-downtime required?
  No  -> Rolling deployment
  Yes -> Need instant rollback?
    No  -> Rolling with health checks
    Yes -> Budget for 2x infrastructure?
      Yes -> Blue-green
      No  -> Canary
```

**Canary traffic split schedule:**

| Phase | % | Duration | Gate |
|-------|---|----------|------|
| 1 | 5% | 15 min | Error rate < 0.1% |
| 2 | 25% | 30 min | P99 latency < 200ms |
| 3 | 50% | 60 min | Business metrics stable |
| 4 | 100% | -- | Full promotion |

## GitHub Actions Patterns

**Reusable workflows** -- define once, call everywhere:
```yaml
# .github/workflows/reusable-deploy.yml
on:
  workflow_call:
    inputs:
      environment: { required: true, type: string }
      image_tag: { required: true, type: string }
    secrets:
      DEPLOY_KEY: { required: true }
```

**OIDC authentication** -- no long-lived credentials:
```yaml
permissions:
  id-token: write
  contents: read
steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789:role/github-actions
      aws-region: us-east-1
```

**Secrets hierarchy:** Organization > Repository > Environment. Never echo secrets; use `add-mask` for dynamic values. Prefer OIDC for cloud auth.

## Runner Cost Optimization

| Runner | vCPU | RAM | Cost/min | Best For |
|--------|------|-----|----------|----------|
| 2-core | 2 | 7 GB | $0.008 | Standard tasks |
| 4-core | 4 | 16 GB | $0.016 | Build-heavy |
| 8-core | 8 | 32 GB | $0.032 | Large compilations |
| 16-core | 16 | 64 GB | $0.064 | Parallel test suites |

**Monthly estimate:** `(runs/day) x (avg min/run) x 30 x (cost/min)`
Example: 50 pushes/day x 8 min x 30 = 12,000 min x $0.008 = **$96/month**.

## Anti-Patterns

| Anti-Pattern | Problem | Fix |
|-------------|---------|-----|
| Monolithic workflow | 45-min single workflow | Split into parallel jobs |
| No caching | Reinstall deps every run | Cache dependencies and builds |
| Secrets in logs | Leaked credentials | `add-mask`, avoid `echo` |
| No timeout | Stuck jobs burn budget | `timeout-minutes` on every job |
| Full matrix every push | 30-min matrix on every commit | Full nightly; reduced on push |
| No rollback plan | Stuck with broken deploy | Automate rollback in CD pipeline |

## Troubleshooting

| Problem | Cause | Solution |
|---------|-------|----------|
| Workflow never triggers | Wrong `on:` config or branch name mismatch | Verify triggers match branching strategy |
| Cache miss every run | Volatile cache key (timestamp) | Use `hashFiles()` on lock files |
| Matrix fails on one OS only | Platform-specific paths or deps | Use `shell: bash`; install OS deps per matrix entry |
| Secret not available | Wrong environment scope | Ensure job declares correct `environment:` |
| Health check fails after deploy | App not started before check | Add retry loop with backoff |
| Concurrency cancels needed runs | Overly broad group key | Scope to `workflow-ref`; separate groups for deploy |
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 321kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall