Skip to content

CI/CD Quality Gates - AI-Generated TypeScript Tests

AI coding tools introduce any types and skipped edge cases faster than humans can review. These 4 GitHub Actions quality gates catch them automatically.

· · 11 min read

Updated: November 27, 2026

Table of four CI gates: strict compile, ESLint rules, coverage threshold and automated AI review

Quick Take

CodeRabbit's December 2025 study of 470 open source pull requests found about 1.7x more issues in AI-co-authored ones than in human-only ones. Four mechanical GitHub Actions gates target it before merge: tsc --noEmit with noUncheckedIndexedAccess, ESLint at --max-warnings 0, an 80% Vitest coverage floor, and CodeRabbit for judgment calls. No catch rate was measured for the pipeline as a whole, so treat it as a filter to try, not a guarantee.

CI/CD quality gates, sometimes written CICD gates, are automated checks wired into your continuous integration pipeline that fail a pull request the moment generated code violates a defined standard, before a human reviewer ever looks at the diff. CI/CD quality gates exist because AI-generated TypeScript code doesn't look obviously wrong: it follows patterns, uses the right library APIs and compiles, so nothing prompts a reviewer to look closer. A gate only helps if it actually inspects the files you think it does, which is what the lint coverage audit measures.

What it also does: introduce any types when inference gets hard, skip the error case in unit tests, generate as SomeType casts instead of proper validation, and assume array indexes are always safe. These slip through a casual review because they look like ordinary code. The array-index case is easy to check yourself: the six-line function below stops compiling once the right flag is on.

My position is that AI commits should go through the same pipeline as human ones, with no exceptions. Code review and careful habits still help, but only a gate that runs on every push applies the rule each time.

I use Claude Code and GitHub Copilot every day, and have for over a year. What sold me on gates was the agent ignoring the repo's own rules: conventions written down in CLAUDE.md, read at the start of the session, and then skipped halfway through a task. Prose in a config file can't block a merge, and a failing check can.

This is the GitHub Actions workflow I'd start from. Four gates, under 50 lines of YAML total.

For the broader quality strategy these gates fit into, see Vibe Coding TypeScript.

Why AI code needs automated gates

CodeRabbit's December 2025 report analysed 470 open source pull requests, 320 AI-co-authored and 150 human-only, and found AI-co-authored ones averaged 10.83 issues each against 6.45, about 1.7x. Logic and correctness issues rose by roughly 75%. I don't read that as a knock on the tools. A model predicts plausible tokens; it doesn't execute your code and check the edge cases.

Speed makes this worse. A developer who writes 10 lines slowly is also thinking about error handling. A developer who reviews 200 AI-generated lines is pattern-matching, not auditing. The defects that slip through are exactly the ones that look fine on a quick scan: a missing null check, a function typed as any, a test that never calls the failure branch.

A gate runs the same checks on every push, no matter who wrote the code or how late in the day it is.

Gate 1: strict TypeScript compile check

The fastest gate is also the most effective. tsc --noEmit runs the TypeScript compiler over your entire codebase without emitting output files. It needs no setup beyond a tsconfig.json.

In GitHub Actions:

- name: TypeScript check
  run: npx tsc --noEmit

This catches implicit any under strict and assertions between types that don't overlap at all (error TS2352). It doesn't catch the as SomeType casts AI tools generate when they can't infer the correct type: an assertion from unknown, or between compatible types, compiles clean, and so does as any. Those belong to the lint gate below. For this gate to do real work, your tsconfig.json needs strict: true plus noUncheckedIndexedAccess:

{
  "compilerOptions": {
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitReturns": true
  }
}

How many bugs this gate stops is not something measured here. The narrower check is this: I compiled a six-line function, const first = items[0]; return first.name.toUpperCase();, with TypeScript 6.0.3. Under plain --strict it compiled clean. Adding --noUncheckedIndexedAccess produced error TS18048: 'first' is possibly 'undefined'. That flag is the one I'd argue does the most work against AI-generated code, because it forces items[0] to be treated as T | undefined instead of T, which catches the "assume the array isn't empty" pattern that generated code leans on.

See the strict TypeScript config for the full breakdown of what each strict flag catches.

Gate 2: TypeScript-specific ESLint rules

tsc checks types, and ESLint catches patterns that compile fine but signal AI shortcuts. The flag that makes it a gate is --max-warnings 0, which turns every warning into a CI failure.

- name: ESLint
  run: npx eslint . --max-warnings 0

Three rules do the most work against AI-generated TypeScript. ESLint 9 made the flat config format the default and ESLint 10 removed the legacy .eslintrc format, so they go in eslint.config.js, next to the typescript-eslint parser and plugin that the @typescript-eslint/* rules need (on TypeScript 7 that parser still blocks npm install on peer range):

// eslint.config.js
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';

export default defineConfig(
  tseslint.configs.recommended,
  {
    rules: {
      '@typescript-eslint/no-explicit-any': 'error',
      '@typescript-eslint/no-non-null-assertion': 'error',
      '@typescript-eslint/explicit-function-return-type': 'error',
    },
  },
);

My opinion: @typescript-eslint/no-explicit-any should be "error", not "warn". AI tools use any the moment a stricter type requires more reasoning. A warning lets it accumulate across 50 files before someone notices. An error means the PR doesn't merge, and I haven't seen the rule work any other way.

@typescript-eslint/no-explicit-any should be "error", not "warn" - a warning lets it accumulate across 50 files before someone notices.

Share this Post on X Bluesky

no-non-null-assertion blocks the ! operator. explicit-function-return-type forces every function to declare what it returns. AI tools skip return types constantly, this rule makes that a build failure.

Gate 3: a test coverage threshold

AI coding tools generate tests, but what they generate is happy-path coverage: call the function with valid inputs, assert it returns the expected output. The error cases, null input, network failure, empty array, malformed data, don't exist. If you're specifically testing AI-generated React components, the React component testing strategies guide covers the patterns that catch the gaps coverage thresholds alone won't expose.

Vitest's coverage thresholds fix this indirectly. Set a minimum and the build fails when coverage drops below it:

// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',
      thresholds: {
        lines: 80,
        functions: 80,
        branches: 75,
      },
      include: ['src/**/*.ts'],
      exclude: ['src/**/*.d.ts'],
    },
  },
});

GitHub Actions step:

- name: Test coverage
  run: npx vitest run --coverage

80% line coverage is a reasonable floor. The number matters less than what happens when it drops: the developer (or AI tool) has to write the missing tests, and that's when the error paths get covered.

Is 80% the right threshold for every project? Probably not. But it's a defensible starting point, and you can raise it once the baseline is established.

How do you roll a new coverage threshold into an existing repo without breaking every open PR overnight? Follow this order.

  1. Run npx vitest run --coverage once against main to record the current baseline, don't guess at the starting number.
  2. Set the threshold a few points below that baseline so the gate passes today and only blocks regressions, not the entire history.
  3. Raise the threshold by 5 points every couple of weeks until you reach 80%, giving the team time to backfill tests gradually.
  4. Once at 80%, treat any further increase as a deliberate team decision, not a default you bump just because you can.

Gate 4: automated AI code review

The first three gates are mechanical. They catch specific patterns with no judgment. This gate is different, it reads the code and flags design-level issues. For TypeScript projects on GitHub, CodeRabbit is the fastest path to get this running, and it isn't a job in your workflow at all. Sign in at coderabbit.ai with GitHub, install the app on the repos you want reviewed, and it comments on the next pull request on its own schedule, alongside the CI run.

A minimal .coderabbit.yaml in the repo root that focuses on TypeScript-specific patterns:

reviews:
  profile: "assertive"
  path_instructions:
    - path: "**/*.{ts,tsx}"
      instructions: |
        Flag any use of `any` type or non-null assertion operators.
        Check that functions have explicit return types.
        Flag tests that don't include at least one assertion on an error path.
        Note missing input validation on function parameters that accept external data.

This gate runs on PRs only, not on every push. It's qualitative, not a hard pass/fail, and I'd keep it that way: in my own Copilot review loops the bot never ran out of comments, and the late rounds were all style and naming, so a person has to decide when the code is good enough. It still surfaces the issues the compiler can't: a function that technically type-checks but has no input validation, a test that covers the success path but assumes the happy path is all that matters.

I only tried CodeRabbit briefly, as a test, so there's no rate here for how often a review bot catches something the three mechanical gates miss. The class of problem is easy to describe, though: a missing null check on external data, or a test that only runs with valid inputs. That's where I'd expect the gate to earn its slot, and where I'd look first if you want to check it on your own PRs.

Expect false positives too: a comment on something that's designed that way on purpose. Don't ignore them silently. Reply on the line, mention @coderabbitai and say why it's intentional. CodeRabbit's docs describe replies like that being saved as learnings and applied to later reviews, so the same project-specific complaint shouldn't keep coming back.

The four gates at a glance

GateWhat it catchesRuns on
1. Strict compile checkType errors, implicit anyEvery push
2. TypeScript-specific ESLint rulesUnsafe patterns the compiler allowsEvery push
3. Test coverage thresholdUntested code pathsEvery push
4. Automated AI code reviewDesign-level issues: missing null checks, happy-path-only testsPRs only, qualitative not pass/fail

The full workflow

All four gates as a single GitHub Actions workflow. Save this as .github/workflows/quality.yml:

name: Quality Gates

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]

jobs:
  typecheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
          cache: npm
      - run: npm ci
      - name: TypeScript check
        run: npx tsc --noEmit

  lint:
    runs-on: ubuntu-latest
    needs: typecheck
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
          cache: npm
      - run: npm ci
      - name: ESLint
        run: npx eslint . --max-warnings 0

  test:
    runs-on: ubuntu-latest
    needs: lint
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
          cache: npm
      - run: npm ci
      - name: Test coverage
        run: npx vitest run --coverage

The jobs run in sequence: typecheck first, then lint, then test. CodeRabbit runs automatically on PRs once installed, no additional workflow configuration needed.

Making the gates mandatory

The workflow file only makes the checks run. Until branch protection requires them, a red X is a suggestion.

  1. Settings > Branches > Add rule, with main as the branch name pattern.
  2. Enable "Require status checks to pass before merging" and select typecheck, lint and test.
  3. Enable "Require branches to be up to date before merging".

One catch: admins can still bypass a classic branch protection rule unless you also tick "Do not allow bypassing the above settings". Guess who merges at 11pm before a deadline?

Two details in that YAML are easy to misread. cache: npm stores npm's download cache (~/.npm), keyed on a hash of package-lock.json. It doesn't restore node_modules, and npm ci deletes that folder anyway, so what you save is the download and not the install. And tsc will never object to an as any someone added to quiet the editor, in CI or anywhere else. Gate 2's no-explicit-any flags the any itself; the no-unsafe-* rules in typescript-eslint's type-checked configs flag the places where that value leaks into typed code. When those rules land on an existing codebase, go through the flagged assertions one at a time. Each is either working around a real compiler limitation or hiding a mismatch, and the rule can't tell you which.

A heads-up on runs-on: ubuntu-latest: GitHub moved that label to Ubuntu 26.04 in a rollout scheduled between October 19 and November 19, 2026, and the runner-images README lists ubuntu-latest on the 26.04 row as of November 27. Every job here sets its Node version through setup-node, which keeps the gates on Node 24 either way. If you copy the YAML and drop that step, the runner's default Node changes with the label. Our Ubuntu 26.04 CI guide lists the differences and a safe way to test them.

The whole thing is under 50 lines of YAML. Run time scales with your codebase, so measure it on your own repo.

Skipping the gates doesn't make AI-assisted development faster for long. What accumulates instead is technical debt: any types spreading through the codebase, untested error paths waiting to fail in production, and type assertions that mask real bugs. No AI tool reverses that easily once it's established. A CI check on every push does.

Frequently Asked Questions

What is a CI/CD quality gate?
A quality gate is an automated check in your CI pipeline that fails the build when code doesn't meet a defined standard. For TypeScript projects, that means type errors, lint violations, or test coverage drops below a threshold. The GitHub Actions docs describe jobs and steps as the unit of CI automation. Run each gate as a separate job and the failure message tells you which one tripped.
Why do AI coding tools need stricter CI gates than human developers?
AI tools generate code fast, which means defects accumulate fast too. CodeRabbit's December 2025 report, which compared 320 AI-co-authored pull requests with 150 human-only ones, found about 1.7x more issues per AI PR. More importantly, AI tools reach for any, non-null assertions, and happy-path-only tests the moment a stricter approach requires more tokens to generate. A gate in CI applies the same check to every pull request, which a reviewer scanning a long diff can't promise.
What coverage threshold should I set for AI-generated code?
80% line coverage is a reasonable floor when AI tools are writing tests alongside code. The real issue isn't the number, it's that AI-generated tests almost exclusively cover the happy path. A threshold forces the question: does this test suite actually try the error case? Vitest's coverage thresholds fail the build when the number drops, which surfaces untested paths immediately.
Does adding these gates slow down AI-assisted development?
No, they shift friction earlier. A TypeScript compile check and an ESLint run are the cheap end of a pipeline, and their cost scales with your codebase, so time them on your own. What they prevent is a production bug that somebody has to trace by hand. Next to that, waiting on a pipeline is cheap.