Full Byte Developer.

Claude Code for DevOps: Actions, containers, OpenTofu

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

Published here , updated · 8 sources

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 for change packs, Claude Code for QA and security triage for Playwright in CI. Browse the Claude Code topic.

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. For Playwright workers and Dependabot, use Claude Code for QA and 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.

Keep this guide

By Full Byte Developer

Filed under Claude Code, Dev tools

Questions about this guide

Where do GitHub Actions workflows live?

GitHub's workflow docs say YAML files under .github/workflows, triggered by repository events, schedules, or manual runs. Each workflow has jobs and steps on a runner.

What does OpenTofu replace in this stack?

OpenTofu docs describe it as infrastructure as code: human-readable config you version and apply across cloud and on-prem resources. Use it for provision plans Claude drafts but a person applies.

Which Engineering plugin commands fit deploy day?

The Engineering README lists /deploy-checklist for pre-deploy verification and /incident for triage, communications, mitigation, and postmortem.

How do hooks help CI scripts in the repo?

Claude Code hooks can block Bash or Edit patterns that would rewrite production workflow files or drop --dry-run. Exit code 2 on PreToolUse refuses the tool call.

Sources

Next in this stack