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

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-guardrailsWhy AI Guardrails?
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.
max-file-lines
Problem AI keeps appending to one file instead of splitting
Fix Warns when a file exceeds 300 lines
max-function-lines
Problem AI generates monolithic functions with everything inlined
Fix Warns when a function exceeds 50 lines
no-orphan-todos
Problem AI leaves TODO / FIXME / HACK with no tracking reference
Fix Errors without a link or deadline
no-ai-obvious-comments
Problem AI adds massive blocks of unnecessary explanations
Fix Enforces max density (20%), length, and quality
Quick Start
One command sets up everything — ESLint config, scripts, and TypeScript baseline.
One-command setup recommended
npx eslint-plugin-ai-guardrails initOr add to your ESLint v9 flat config manually
// eslint.config.mjs
import aiGuardrails from 'eslint-plugin-ai-guardrails';
export default [
aiGuardrails.flatConfigs.recommended
];Rules
| Rule | Default | Description |
|---|---|---|
| max-file-lines | warn | Prevent files from exceeding 300 lines |
| max-function-lines | warn | Prevent functions from exceeding 50 lines |
| no-orphan-todos | error | Require TODO/FIXME/HACK to include a tracking reference |
| no-ai-obvious-comments | warn | Enforce strict comment density, length, and quality constraints |
Prevent files from exceeding 300 lines
Prevent functions from exceeding 50 lines
Require TODO/FIXME/HACK to include a tracking reference
Enforce strict comment density, length, and quality constraints
Compatibility
Explore
Documentation
Full API reference, guides, and examples
GitHub Repository
Source code, issues, and contributions
npm Package
Install and version history
Report an Issue
Bug reports and feature requests
Changelog
What changed in each release
Support the Project
Buy the author a coffee on Ko-fi
FAQ
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.