Back to blog

GitHub Actions: Quality Gates for the AI Era

github-actionsci-cdaidevopsautomation
GitHub Actions: Quality Gates for the AI Era

Here is a pattern I keep seeing. A team adopts AI coding assistants. Pull requests double in number and grow in size. The reviewers, who are the same few humans as before, start skimming. Then one Friday a bug ships that "looked fine".

Nobody was careless. The system simply produces more code than humans can carefully read.

The fix is not "review harder". It is to automate everything a machine can check, so human attention goes only where it is needed. This post is about doing that with GitHub Actions, and about where AI fits in as one more gate.

What I'll Talk About

✅ Why the AI era needs more quality gates, not fewer
✅ Why GitHub Actions is a good place to start (and what "free" really means)
✅ Two kinds of gates: deterministic checks and AI review
✅ A working CI workflow you can copy
✅ Adding an AI reviewer to every pull request
✅ Pitfalls: cost, secrets, flaky tests, and over-trusting the bot


1. Why We Need More Gates Now

When writing code was slow, the writing itself acted as a filter. You thought about each line because typing it cost effort. AI removes that filter. Code is now cheap, and cheap code is not the same as correct code.

Look at what changes:

Before AIWith AI
A few hundred lines per PRA few thousand lines per PR
Author understood every lineAuthor understood the idea, maybe not every line
Reviewer trusted the author's careReviewer cannot assume anyone read it closely
Bugs came from mistakesBugs also come from plausible-looking code that is subtly wrong

Notice the last row. AI-written code rarely has a typo. It has a confident, well-formatted, wrong assumption. Humans are bad at spotting those when skimming, and machines with tests are very good at it.

That is why the title of my earlier post, High Expectations in the AI Era, matters here: if the expectation is "faster", the only responsible way to meet it is to make checking faster too, not to skip it.

2. Why GitHub Actions

If you host code on GitHub, Actions is already there. No server to run, no separate CI product to buy and integrate. A workflow is one YAML file in .github/workflows/, versioned with the code.

On cost, be precise, because "free" gets misquoted:

  • Public repositories: standard GitHub-hosted runners are free.
  • Private repositories: every plan includes a monthly quota of free minutes, and you pay for usage beyond it. Check GitHub's current pricing page for the numbers, since they change.
  • AI steps are not free: Actions runs the job for free, but if a step calls an AI model, you pay that provider for the tokens.

For a personal project or a small team, the free tier covers a lot. The point is that the barrier to having a gate is now close to zero. There is no good excuse for a repository without one.

3. Two Kinds of Gates

I think of quality gates in two layers. The order matters.

Layer 1: Deterministic gates. Same input, same answer, every time.

  • Formatter and linter
  • Type checker
  • Unit and integration tests
  • Build succeeds
  • Dependency and secret scanning

These are cheap, fast and objective. A failing test is not an opinion.

Layer 2: AI review. A model reads the diff and comments.

  • Spots logic errors and missing edge cases
  • Notices when the change contradicts the PR description
  • Flags missing tests, risky migrations, security smells
  • Explains a large diff so the human reviewer starts oriented

This layer is fuzzy. It can be wrong and it can miss things. It is valuable because it catches the kind of issue that Layer 1 cannot express as a rule.

Run the cheap, objective layer first. There is no point paying an AI to review code that does not compile.

4. A Working CI Workflow

Here is a baseline for a Node.js project. Adapt the commands to your stack.

# .github/workflows/ci.yml
name: CI
 
on:
  pull_request:
  push:
    branches: [main]
 
# Cancel an older run of the same PR when a new commit arrives
concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  check:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
 
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
 
      - run: npm ci
      - run: npm run lint
      - run: npx tsc --noEmit
      - run: npm test
      - run: npm run build

A few small details that matter:

  • timeout-minutes stops a hung job from eating your quota.
  • concurrency cancels outdated runs, which saves minutes when an AI assistant pushes five commits in a row.
  • npm ci gives a reproducible install from the lockfile.

Make It Actually Block Merges

A workflow that can be ignored is just a suggestion. In the repository settings, add a branch protection rule (or ruleset) for main:

  • Require a pull request before merging
  • Require status checks to pass, and select the check job
  • Require branches to be up to date before merging

Now the gate is real. Nobody, human or AI-assisted, merges red.

5. Adding an AI Reviewer

With Layer 1 in place, add Layer 2. Anthropic maintains a GitHub Action for Claude Code that can review pull requests and respond to @claude mentions. Here is a minimal review workflow.

# .github/workflows/ai-review.yml
name: AI Review
 
on:
  pull_request:
    types: [opened, synchronize]
 
permissions:
  contents: read
  pull-requests: write
 
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            Review this pull request. Focus on:
            1. Logic errors and unhandled edge cases
            2. Missing or weak tests for the changed behaviour
            3. Security issues (input validation, secrets, injection)
            4. Anything that contradicts the PR description
            Be concise. Comment only on real problems, not style.

Check the action's README for the current input names before you copy this, because the interface evolves. The important idea is the prompt. A vague "review this" gives vague noise. A prompt that names what you care about gives comments you will actually read.

Teach It Your Rules

The AI reviewer is much better when it knows your conventions. Put them in a CLAUDE.md at the repository root: architecture rules, naming, "never do X". The reviewer reads it, and so does every developer's local assistant. One file, two jobs. I wrote about this idea in Context Engineering for AI Agents.

If you are using domain-driven design, this pairs well with the split from DDD Matters More in the Age of AI: the reviewer can be told "business rules live only in the domain model, flag any PR that re-implements them in a controller".

6. What Else Can Actions Automate

Quality gates are the main event, but the same mechanism removes a lot of other toil:

  • Dependency updates: Dependabot opens PRs, CI proves they are safe.
  • Security scanning: CodeQL and secret scanning run on every push.
  • Release notes and changelogs: generated from merged PRs, or summarized by AI.
  • Issue triage: label and route new issues automatically.
  • Preview deployments: every PR gets a URL a human can click.

The theme is the same: if a step is repetitive and has a clear definition of "done", a machine should own it. If you are new to GitHub itself, start with GitHub-First Project Guide.

7. Pitfalls

Over-trusting the AI reviewer. It is a second pair of eyes, not the final authority. It can be confidently wrong and it can miss real bugs. Keep a human approval requirement for anything that matters.

Flaky tests destroy the whole system. If CI fails randomly, people learn to re-run until green and stop reading failures. Fix or quarantine flaky tests quickly. A gate people ignore is worse than none, because it gives false confidence.

Secrets and untrusted code. Workflows triggered by pull requests from forks do not get your secrets by default, and for good reason. Never run untrusted PR code with write permissions or secrets available. Also be aware of prompt injection: a PR description or code comment can contain text aimed at your AI reviewer. Give the AI job the minimum permissions it needs, as shown above.

Cost creep. An AI review on every push of every PR adds up. Trigger on opened and synchronize sparingly, skip draft PRs, or run the review only when a label is added.

Slow pipelines. If CI takes 30 minutes, people will batch changes and review gets worse again. Cache dependencies, parallelize jobs, and run the slow suites only where they matter.

Gates without ownership. Somebody has to maintain the workflows, the same way somebody maintains the code. Treat .github/workflows/ as production code, with review.

Summary and Key Takeaways

✅ AI increases code volume, so human review alone cannot keep up
✅ Automate every check a machine can do: lint, types, tests, build, security
✅ GitHub Actions makes the barrier to a gate close to zero (mind the private-repo quota)
✅ Run deterministic checks first, then add AI review as a second layer
✅ Use branch protection so gates actually block merges
✅ Give the AI reviewer your conventions and least-privilege permissions
✅ Keep humans for design, intent and final approval

The goal is not to remove people from the loop. It is to stop spending their attention on things a machine can check, so the attention that remains goes to the questions only a person can answer. For the full day-to-day picture of working with these tools, see My Coding Workflow with AI.

📬 Subscribe to Newsletter

Get the latest blog posts delivered to your inbox every week. No spam, unsubscribe anytime.

We respect your privacy. Unsubscribe at any time.

💬 Comments

Sign in to leave a comment

We'll never post without your permission.