Compound Engineering

CI/CD & What's Next

Mixed10 min

Claude Code as infrastructure

Everything you've learned so far assumes you're sitting at a terminal, interacting with Claude. But Claude Code also runs headless - in CI/CD pipelines, GitHub Actions, cron jobs, and deploy scripts.

This changes what's possible. Instead of "a tool I use," Claude Code becomes infrastructure that runs on every PR, every push, every deploy.

Claude Code isn't just a dev tool - it's infrastructure

When Claude Code runs in your CI/CD pipeline, every pull request gets an AI review. Every merge gets an AI-assisted deploy check. Every issue can get an AI-generated first response. The compound loop extends beyond your terminal into your entire development workflow.

Non-interactive mode

The -p flag runs Claude Code without interaction. This is the foundation for all CI/CD usage.

# Basic non-interactive prompt
claude -p "explain what this project does"
 
# Output formats for parsing
claude -p "list all TODO comments" --output-format json
claude -p "summarize recent changes" --output-format text
claude -p "review this diff" --output-format stream-json
 
# Limit scope to prevent runaway sessions
claude -p "fix the lint errors in src/" --max-turns 3
 
# Continue a previous session
claude -c -p "now run the tests for those changes"
FlagUse case
--output-format jsonParse structured output in scripts
--output-format textHuman-readable output for logs
--output-format stream-jsonReal-time streaming for dashboards
--max-turns NLimit cost and prevent infinite loops
-cContinue a previous session with follow-up

Using exit codes in scripts

Claude Code returns meaningful exit codes you can use in shell scripts:

# Run tests and fix failures automatically
claude -p "run npm test, fix any failures" --max-turns 5
if [ $? -ne 0 ]; then
  echo "Auto-fix failed, needs manual intervention"
  exit 1
fi

GitHub Actions with claude-code-action

The official GitHub Action is anthropics/claude-code-action@v1. It lets Claude respond to @claude mentions in PR comments and issues.

.github/workflows/claude.yml
name: Claude Code
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
 
jobs:
  claude:
    if: contains(github.event.comment.body, '@claude')
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
      issues: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          # Optional: custom system prompt
          custom_instructions: |
            Follow the conventions in CLAUDE.md.
            When reviewing PRs, check for security issues first.
          # Optional: limit scope
          max_turns: 10

What this enables

Once installed, your team can interact with Claude directly in GitHub:

  • PR comment: "@claude review this PR for security issues" - Claude reads the diff, posts findings as review comments
  • PR comment: "@claude fix the failing test" - Claude reads the error, pushes a fix commit
  • Issue comment: "@claude implement this feature based on the description" - Claude creates a PR with the implementation

Practical CI examples

Automated PR review

.github/workflows/pr-review.yml
name: AI PR Review
on:
  pull_request:
    types: [opened, synchronize]
 
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Run AI review
        run: |
          npm install -g @anthropic-ai/claude-code
          DIFF=$(git diff origin/main...HEAD)
          claude -p "Review this diff for security issues,
          performance problems, and bugs. Output as markdown.
 
          $DIFF" --output-format text --max-turns 3 > review.md
 
      - name: Post review comment
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = fs.readFileSync('review.md', 'utf8');
            github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: review
            });

Automated fix on lint failure

.github/workflows/auto-fix.yml
name: Auto-fix Lint
on:
  pull_request:
    types: [opened, synchronize]
 
jobs:
  fix:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
 
      - name: Run lint
        id: lint
        run: npm run lint 2>&1 | tee lint-output.txt || true
 
      - name: Auto-fix with Claude
        if: failure()
        run: |
          ERRORS=$(cat lint-output.txt)
          claude -p "Fix these lint errors: $ERRORS" --max-turns 3
          git add -A && git commit -m "fix: auto-fix lint errors"
          git push

Skills as pipeline steps

Each skill you built in the previous lesson can become a CI step:

steps:
  - name: Review
    run: claude -p "/review" --max-turns 5
 
  - name: Test
    run: claude -p "/test" --max-turns 3
 
  - name: Deploy
    run: claude -p "/deploy" --max-turns 5

Skills can reference outputs of previous steps through the filesystem - a /review skill that writes findings to review-report.md can be read by a subsequent /deploy skill that checks for P1 blockers before shipping.

What's coming next

AI-assisted development is moving fast. A few directions to watch:

Agent SDK - Build custom AI agents that use Claude as a backbone. Define tools, workflows, and memory systems tailored to your specific use case. This moves beyond "CLI tool" into "build your own AI engineering team."

Multi-model workflows - Different models for different tasks. A fast model for autocomplete, a reasoning model for architecture decisions, a specialized model for security review. Orchestrated together.

Persistent memory - Today, compounding happens through files (CLAUDE.md, solutions index). Tomorrow, models will maintain structured memory across sessions natively.

Deeper integrations - MCP servers for every tool in your stack. Deploy platforms, monitoring systems, databases, design tools - all accessible as natural conversation.

Resources

Course wrap-up

Here's what you've built across four modules:

ModuleWhat you learnedWhat you built
The LandscapeWhy agentic tools are different from autocompleteMental model for AI-assisted development
Core FeaturesCLAUDE.md, permissions, tools, agentic loopProject context that Claude reads automatically
Advanced WorkflowsHooks, skills, MCP, sub-agentsReusable automation for your workflow
Compound EngineeringThe five-step loop, pipelines, CI/CDA working compound engineering pipeline

The key insight across all of it: the developers who get the most from AI coding tools are the ones who invest in context. A well-structured CLAUDE.md, clear conventions, codified learnings, and automated quality gates create a compounding advantage that grows with every session.

Start with one thing: write a CLAUDE.md for your next project. Add your conventions. Capture a learning after your first session. The compound loop starts there.

One habit to keep

After every coding session, ask yourself: "What did I learn that future-me (or future-Claude) should know?" Write it down. That single habit is the difference between linear and exponential productivity.