Guardrails for AI-written JavaScript and TypeScript
AI Guard is an ESLint plugin, CLI and set of agent hooks that catch the risky patterns AI coding tools often produce, such as swallowed errors, leaked secrets and packages that don't exist, before they reach a commit.
npm install --save-dev eslint-plugin-ai-guard- Node.js 20 or later
- ESLint 8 or later
- MIT licence
12,922downloads
Results
- 0 of 1,361real dependencies blockedHow this was measured: real dependencies blocked
- 34 of 36names from the 2017 crossenv malware campaign blockedHow this was measured: names from the 2017 crossenv malware campaign blocked
- 27 of 27rules give identical results in ESLint and OxlintHow this was measured: rules give identical results in ESLint and Oxlint
Measured on 12 November 2026. Method and limits
What it does
Checks at every point an agent's code passes through.
Every check is deterministic: the same code gives the same result, with no model in the loop. AI Guard does not try to tell whether code was written by a person or a model; it reports patterns wherever they came from.
Lint rules
27 rules for secrets, swallowed errors, floating promises, invented imports and placeholder code, in ESLint or a zero-config CLI.
Rule catalognpx ai-guard runChecks on the agent's change
One verdict for a change, plus checks for skipped tests, new eslint-disable comments and hidden text in agent config. Problems that were already there never block.
Verify and integritynpx ai-guard verifyPackage checks
Blocks packages that don’t exist on npm, removed malware and suspicious look-alikes before they are installed. Warns on releases from the last 24 hours.
What is blockednpx ai-guard verify-deps --allAgent hooks
Feedback after each edit and a check before the agent finishes, in Claude Code, Codex and Cursor, set up with one command.
Hooks by agentnpx ai-guard init-hooksPre-commit gate
Runs on every commit, whoever wrote the code, through husky, lefthook, simple-git-hooks or pre-commit. Only problems the commit introduces block it.
Pre-commit setupnpx ai-guard init-git-hookCI and Code Scanning
The GitHub Action annotates pull requests and writes a job summary and a SARIF file for GitHub Code Scanning.
Workflowuses: ai-guard-dev/eslint-plugin-ai-guard@v1
Package checks
A package is checked before it is installed.
Assistants suggest packages that don't exist, and attackers register those names. AI Guard looks each package up on npm and blocks only on facts: the name or version doesn't exist, npm replaced it with a security placeholder, or a look-alike or install script appears on a new or rarely downloaded package.
- Network use is opt-in and only queries the public npm registry.
- Packages from private registries are skipped, so internal names are never sent out.
npx ai-guard verify-deps crossenv AI GUARD Dependencies · 1 package · 1 blocked · 0 warnings command lineerror crossenv npm removed the package published as "crossenv" (usually for malware) and replaced it with an empty placeholder. Did you mean "cross-env"? security-holdingcrossenv was part of the August 2017 typosquatting campaign that imitated cross-env; npm replaced it with an empty security placeholder.Agent hooks
Claude Code, Codex and Cursor from one command.
npx ai-guard init-hooks detects the agents a project uses from .claude/, .cursor/ and .codex/. What each agent gets depends on what its hook system allows.
| Capability | Claude Code | Codex | Cursor |
|---|---|---|---|
| Lint and weakened checks fed back after each edit | Yes | Yes (apply_patch) | At the finish gate instead |
| Finish gate: problems the session introduced, raised once | Yes | Yes | Yes (follow-up message) |
| Session-start snapshot, so earlier work is not blamed on the agent | Yes | Yes | Yes |
Guard on git commit --no-verify and HUSKY=0 | Asks you | Denied; the agent is told to ask you | Asks you |
| Package check before installs (opt-in) | Deny or ask | Deny | Deny or ask |
Tested: Run against real installs in Claude Code and the Codex CLI. Cursor support follows Cursor’s documented hook format and has not been tested in the editor.
Frequently asked questions
What is eslint-plugin-ai-guard?
It is the npm package for AI Guard: an open-source ESLint plugin, CLI and set of agent hooks that catches risky patterns AI coding tools often produce in JavaScript and TypeScript and checks npm packages before they are installed. It is MIT licensed and runs locally.
Does AI Guard detect AI-written code?
No. It reports risky patterns that AI tools often produce, such as swallowed errors, leaked secrets, placeholder code and packages that don’t exist, wherever the code came from.
Does it replace ESLint or my existing config?
No. It is an ESLint plugin: you add its rules to your existing config. The ai-guard CLI can also run the same rules without your config. See AI Guard and ESLint.
Which AI coding agents does it work with?
npx ai-guard init-hooks sets up hooks for Claude Code, Codex and Cursor. Claude Code and the Codex CLI were tested against real installs; Cursor support follows Cursor’s documented hook format and has not been tested in the editor. Any MCP client can use the MCP server.
Does it send my code anywhere?
No. Lint and the checks on a change run locally with no network access and no telemetry. Only the package checks use the network, to query the public npm registry, and only when you run them.
Install
Try it on your project.
The CLI uses its own configuration, so you can see findings before you change your ESLint setup or CI.
- Node.js 20 or later
- ESLint 8 or later, flat config or legacy config
- Optional:
@typescript-eslint/parserfor TypeScript - Current version: 1.4.7
npm install --save-dev eslint-plugin-ai-guardpnpm add -D eslint-plugin-ai-guardyarn add -D eslint-plugin-ai-guardbun add -d eslint-plugin-ai-guardThen run
# Zero-config scan of the whole projectnpx ai-guard run # Hooks for Claude Code, Cursor and Codexnpx ai-guard init-hooks # Check every dependency on npmnpx ai-guard verify-deps --allOpen source
MIT licensed, developed in public.
The rules, CLI, GitHub Action, MCP server, and Claude Code plugin are all in one repository. Every rule has tests and a documentation page you can check a finding against.
- npm downloads, all time
- 12,922
- Last 30 days
- 3,727
Last verified count; live figures load from the npm downloads API. Downloads include CI installs and are not a count of users.
- Source codeai-guard-dev/eslint-plugin-ai-guard
- Report a false positive or bugGitHub issues
- Open issuesWhat is being worked on
- Contributing guideLocal setup, tests, adding a rule
- Security policyReport vulnerabilities privately
- ChangelogWhat changed in each release
- npm packageeslint-plugin-ai-guard
- GitHub MarketplaceESLint AI Guard action
- Licensed under MIT.

Ecosystem
AI Guard × Sarvam AI Startup Program
AI Guard was selected for the Sarvam AI Startup Program, supporting continued work on deterministic guardrails for AI-assisted software engineering.
Collaborate
Build AI Guard with us.
AI Guard is open source, and we're open to working with developers, security researchers, and teams building with AI coding tools.
Interested in contributing a rule, testing AI Guard on your codebase, exploring integrations, or discussing a partnership? We'd love to hear from you.
Have any queries? Email us directly at [email protected]
Rule Contributions
Author or refine AST detection rules for your stack.
Codebase Testing
Run differential benchmarks on real-world AI-assisted code.
Agent Integrations
Help bridge AST rules with Cursor, Claude Code, and Copilot.
Security Research
Share insights on recurring AI vulnerability patterns.
Have any queries? Email [email protected]
Maintainers
Created and maintained by
AI Guard is built in the open by two engineers working on developer tooling, static analysis, and code reliability.

Yash Jadhav
Co-Creator & MaintainerSoftware engineer specializing in developer tooling, AST static analysis, and code reliability infrastructure.

Vaishnavi Sawant
Co-Creator & MaintainerSoftware engineer focused on AI-assisted development guardrails, TypeScript tooling, and modern web systems.