โ† Back to Projects
๐Ÿค–

Agentic DevOps Pipeline with Claude Code

5-layer AI-powered infrastructure system โ€” CLAUDE.md ยท Skills ยท Subagents ยท MCP ยท Safety Hooks

PlatformAWS S3 + CloudFront
AI ToolClaude Code (Agentic)
IaCTerraform
CourseUltimate Agentic DevOps โ€” Pravin Mishra
Read on MediumView Article โ†’

Overview

What I Built

A fully automated, safety-guarded, auditable DevOps pipeline using Claude Code as an AI copilot. The system deploys a static portfolio website to AWS S3 with CloudFront CDN โ€” but what makes it remarkable is not the destination, it is the five-layer agentic architecture that makes every action consistent, safe, and auditable.

5
Architecture Layers
4
Slash Command Skills
3
Safety Hooks
0
Manual Terraform Commands
LAYER 1 CLAUDE.md โ€” Giving the Agent a Memory

A markdown file in the project root that Claude Code reads before doing anything. It contains the project overview, architecture, folder structure, and conventions โ€” including a rule that prohibits JavaScript frameworks. When I asked Claude to add a React component, it refused โ€” not because it could not write React, but because CLAUDE.md said no. That was the first moment I realized I was not just using a tool. I was building a team member.

LAYER 2 Skills โ€” Turning Long Prompts Into One Command

Skills are markdown files with a defined playbook the agent follows every time. I built four: /scaffold-terraform (generates all Terraform files from scratch), /tf-plan (runs plan with correct flags, counts resources, flags high-risk changes โ€” cannot edit files), /tf-apply (provisions S3, CloudFront, bucket policies), and /deploy (syncs files to S3 and invalidates CloudFront cache). One command. Two AWS operations. Zero manual steps.

LAYER 3 Subagents โ€” Isolated Specialists With One Job

Three subagents, each running in completely isolated context. The security-auditor reads Terraform files and checks against security rules โ€” it cannot write anything. It found 13 security issues including a CRITICAL one: my terraform.tfstate file sat in the project directory with my real AWS account ID and CloudFront distribution IDs. Bots scan GitHub for this within minutes. The tf-writer fixes Terraform files using live MCP documentation. The audit-fix-verify loop runs in minutes on any project.

LAYER 4 MCP โ€” Live Connection to the World

AI models are trained up to a date then frozen. New Terraform provider versions are released. AWS adds new services. Without MCP, the agent generates Terraform from stale training memory โ€” deprecated arguments, missing required fields. With the Terraform MCP server, the agent reads the actual current provider documentation for every resource it writes. With the AWS MCP server, it queries your live account rather than assuming. Training data tells you what was true. MCP tells you what is true.

LAYER 5 Hooks โ€” Safety That Cannot Be Bypassed

Three shell scripts outside the AI entirely โ€” the agent cannot read, modify, or override them. user-prompt-guard.sh fires at prompt submission and blocks dangerous words (Delete all, terraform destroy, DROP TABLE). pre-tool-guard.sh fires before every bash command and blocks dangerous executions with exit code 2. post-tool-logger.sh logs every command with timestamp to an audit trail. SAY guards intent. DO guards execution. LOG makes everything auditable. You need all three โ€” intent and execution are two different things.

Lessons Learned

What I Took Away

AI Amplifies Engineers โ€” It Does Not Replace Them

Claude Code generated 400+ lines of Terraform in minutes. But when something unexpected happened, I had to understand and respond. The engineers who win with AI are the ones who understand what it is doing, not just that it is doing it.

Security Audit Before You Push

The subagent found my tfstate file with live AWS credentials before I pushed to GitHub. This is not a theoretical risk โ€” bots actively scan public repositories for exposed credentials within minutes of a push. The audit-fix-verify loop is non-negotiable.

Training Data vs Live Data

For DevOps, the difference between what was true (training data) and what is true (MCP live data) is the difference between working Terraform and a deployment that fails on the first plan.

Claude CodeMCPTerraformAWS S3CloudFrontAgentic AISecurity AuditIaC
Read Full Article on Medium โ†’