# Claude Code for DevOps: Actions, containers, OpenTofu

> Draft GitHub Actions and OpenTofu with Claude, keep Docker images pinned, and gate deploys with checklists.

Source: https://fullbytedeveloper.com/blog/claude-code-for-devops-ci-cd
Published here: 2026-11-26, updated 2026-11-26

DevOps with Claude Code drafts workflow YAML, Dockerfiles, and OpenTofu plans; a person plus CI applies them. Pin container tags by digest or immutable tag, keep a rollback checklist before promote, and treat OpenTofu files as the versioned IaC you can diff. [1] [2] [3]

After this page you can draft Actions YAML, pin container images, keep OpenTofu files reviewable, and close a deploy with a rollback checklist. Related: [Claude Code for operations](/blog/claude-code-for-operations) for change packs, [Claude Code for QA and security triage](/blog/claude-code-for-qa-security-triage) for Playwright in CI. Browse the [Claude Code topic](https://fullbytedeveloper.com/blog/topic/claude-code).

## Install Engineering commands for deploy day

```bash
claude plugin marketplace add anthropics/knowledge-work-plugins
claude plugin install engineering@knowledge-work-plugins
```

```text
/deploy-checklist payments-api v1.4.2
/incident edge gateway returning 502s
```

`/deploy-checklist` covers tests, review of changes, dependencies, and rollback. `/incident` covers triage, communications, mitigation, and postmortem when the deploy goes wrong. [4]

## Draft GitHub Actions workflows as reviewable YAML

GitHub documents workflows as YAML under `.github/workflows`, triggered by `on:` events (push, schedule, manual, and more). Each workflow has jobs; each job has steps that run scripts or actions on a runner. [1]

Ask Claude for a workflow that triggers on `pull_request`, runs install plus tests, and never embeds secret values (repository secrets by name only). [1]

```yaml
# Conceptual shape from GitHub Actions workflow docs
name: ci
on:
  pull_request:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test
```

Best practices: "done" means green CI, not a confident paragraph. You should see the workflow in a PR you can read before merge. [1] [6]

## Pin container images the way Docker describes them

Docker Learn: a container is an isolated process with its own filesystem view; an image is the immutable layered package it starts from. Prefer named tags plus digests for production bases, and treat registries as the share point. [2]

```dockerfile
# Example pattern: explicit base tag in a Dockerfile Claude drafts
FROM node:22-slim
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY . .
CMD ["node", "src/index.js"]
```

**Warning:** do not let the agent push to a production registry from a laptop session. Draft the Dockerfile and compose file; CI builds and pushes under your rules. [2] [6]

## Keep infrastructure in OpenTofu files Claude can diff

OpenTofu docs describe versioned, reusable configuration for cloud and on-prem resources with a consistent CLI workflow. Ask Claude to edit `.tf` files and print `tofu plan` output; you run apply. [3]

```text
# Human gate
tofu plan -out=tfplan
# review the plan
tofu apply tfplan
```

Put account ids and remote state backends in files Claude may read only when the session is allowed to. Hooks can block Bash that runs `tofu apply` without a plan file you already approved. Exit code 2 on `PreToolUse` refuses the call. [3] [5]

## Close the deploy loop

1. PR with Actions workflow and app tests green. [1]
2. Image build from a pinned Dockerfile. [2]
3. OpenTofu plan reviewed. [3]
4. `/deploy-checklist` filled with rollback owner named. [4]
5. Person applies; `/incident` is ready if health checks fail. [4]

For vendor and change paperwork around the same cutover, use [Claude Code for operations](/blog/claude-code-for-operations). For Playwright workers and Dependabot, use [Claude Code for QA and security triage](/blog/claude-code-for-qa-security-triage). [7] [8]

You now have a DevOps loop: Actions drafts, pinned containers, OpenTofu plans, Engineering deploy and incident commands, human apply.

Send this to the platform engineer who wants Claude drafting pipelines without applying prod alone.

## Sources

1. [GitHub Actions: About workflows, accessed 2026-11-26](https://docs.github.com/en/actions/writing-workflows/about-workflows)
2. [Docker Learn: What is a container, accessed 2026-11-26](https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-container/)
3. [OpenTofu documentation overview, accessed 2026-11-26](https://opentofu.org/docs/)
4. [Anthropic Engineering plugin README, accessed 2026-11-26](https://raw.githubusercontent.com/anthropics/knowledge-work-plugins/main/engineering/README.md)
5. [Claude Code docs: Hooks, accessed 2026-11-26](https://code.claude.com/docs/en/hooks)
6. [Claude Code best practices, accessed 2026-11-26](https://code.claude.com/docs/en/best-practices)
7. [Full Byte Developer: Claude Code for operations](https://fullbytedeveloper.com/blog/claude-code-for-operations)
8. [Full Byte Developer: Claude Code for QA and security triage](https://fullbytedeveloper.com/blog/claude-code-for-qa-security-triage)
