eslint-plugin-ai-guardrails logo
npm versionCI statusMIT licenseMonthly downloadsBuilt with TypeScriptESLint v8 and v9

eslint-plugin-
ai-guardrails

Stop AI-generated code from becoming long-term tech debt. Enforce structure-first linting rules that catch the patterns AI coding tools get wrong most often.

Works with Copilot, Cursor, ChatGPT, Claude, and any AI coding assistant. Supports ESLint v8 & v9, TypeScript ≥ 5.

Quick install

npm install --save-dev eslint-plugin-ai-guardrails

Why AI Guardrails?

Catch What AI Gets Wrong

AI coding assistants are incredibly productive — but they introduce predictable quality drift. These aren't style nitpicks; they're the exact patterns that turn a productive AI sprint into months of refactoring.

No More God Files

max-file-lines

Problem AI keeps appending to one file instead of splitting

Fix Warns when a file exceeds 300 lines

No More God Functions

max-function-lines

Problem AI generates monolithic functions with everything inlined

Fix Warns when a function exceeds 50 lines

No Orphan TODOs

no-orphan-todos

Problem AI leaves TODO / FIXME / HACK with no tracking reference

Fix Errors without a link or deadline

No Redundant Comments

no-ai-obvious-comments

Problem AI adds massive blocks of unnecessary explanations

Fix Enforces max density (20%), length, and quality

Quick Start

Get Started in Seconds

One command sets up everything — ESLint config, scripts, and TypeScript baseline.

1

One-command setup recommended

npx eslint-plugin-ai-guardrails init
2

Or add to your ESLint v9 flat config manually

eslint.config.mjs
// eslint.config.mjs
import aiGuardrails from 'eslint-plugin-ai-guardrails';

export default [
  aiGuardrails.flatConfigs.recommended
];

Rules

Rules at a Glance

max-file-lineswarn

Prevent files from exceeding 300 lines

max-function-lineswarn

Prevent functions from exceeding 50 lines

no-orphan-todoserror

Require TODO/FIXME/HACK to include a tracking reference

no-ai-obvious-commentswarn

Enforce strict comment density, length, and quality constraints

Compatibility

Works With Your Stack

Requirements

Node.js
Node.js
≥ 18.0.0
ESLint
ESLint
v8.x · v9.x
TypeScript
TypeScript
≥ 5.0.0
@typescript-eslint/parser
@typescript-eslint/parser
v6.x · v7.x · v8.x

Tested With

Next.jsNext.js
NestJSNestJS
ExpressExpress
HonoHono
ElysiaJSElysiaJS
SvelteKitSvelteKit
ViteVite

Compatible With

CursorCursor
WindsurfWindsurf
AntigravityAntigravity
KiroKiro

Community

Contributors

FAQ

Frequently Asked Questions

An ESLint plugin that enforces structure-first linting rules designed to catch the code quality patterns AI coding assistants (Copilot, Cursor, ChatGPT, Claude) introduce most often — including god files, god functions, orphan TODOs, and redundant comments.

Yes. Use aiGuardrails.flatConfigs.recommended in your eslint.config.mjs for ESLint v9. ESLint v8 legacy .eslintrc config is also supported via plugin:ai-guardrails/recommended.

Yes. MIT license. Free forever. Source code on GitHub, package on npm.

TypeScript files only: .ts, .tsx, .mts, and .cts. JavaScript files are intentionally excluded — this plugin targets TypeScript-first AI-assisted workflows.

Add --max-warnings 0 to your lint script: "lint": "eslint . --max-warnings 0". Then gate your build: "build": "npm run lint && npm run typecheck && <build-step>".

More questions? Read the docs or open an issue.