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.
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.
- Run
npx vitest run --coverageonce againstmainto record the current baseline, don't guess at the starting number. - Set the threshold a few points below that baseline so the gate passes today and only blocks regressions, not the entire history.
- Raise the threshold by 5 points every couple of weeks until you reach 80%, giving the team time to backfill tests gradually.
- 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
| Gate | What it catches | Runs on |
|---|---|---|
| 1. Strict compile check | Type errors, implicit any | Every push |
| 2. TypeScript-specific ESLint rules | Unsafe patterns the compiler allows | Every push |
| 3. Test coverage threshold | Untested code paths | Every push |
| 4. Automated AI code review | Design-level issues: missing null checks, happy-path-only tests | PRs 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.
- Settings > Branches > Add rule, with
mainas the branch name pattern. - Enable "Require status checks to pass before merging" and select
typecheck,lintandtest. - 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.