Getting Started with AI Guard
Quick installation and setup guide for adding AI Guard to your JavaScript or TypeScript codebase in under 2 minutes.
AI Guard is designed to be adopted incrementally with zero disruption to your existing developer tooling. You can run it directly with npx, install it as an ESLint plugin, or integrate it into your GitHub Actions workflow.
Installation
Install AI Guard as a development dependency using your preferred package manager:
# npm
npm install --save-dev eslint-plugin-ai-guard
# pnpm
pnpm add -D eslint-plugin-ai-guard
# yarn
yarn add -D eslint-plugin-ai-guardPrerequisites: Node.js ≥ 18.0.0 and ESLint ≥ 8.0.0 (supports ESLint 8 and ESLint 9 Flat Config).
Running Your First Scan
You do not even need to configure your ESLint config file to run your first project scan. AI Guard ships with a high-performance native CLI:
# Run a quick scan with the recommended preset
npx ai-guard run
# Or scan only modified files in your current working branch
npx ai-guard changedThe scan parses all .js, .ts, .jsx, and .tsx files using deterministic AST analysis, checking each syntax tree against AI-specific anti-patterns in under 400 milliseconds.
Choosing a Preset
AI Guard provides three carefully tuned presets depending on your team's workflow:
- `recommended` (Default): Zero noise. Turns on high-impact reliability and security rules at
errorlevel (such as unhandled floating promises, hardcoded secrets, and empty catches), while keeping context-dependent checks atwarnor disabled. - `strict`: Maximum safety for mature codebases. Enables all 18 rules at
errorlevel. Recommended for CI gates and pull request validation. - `security`: Focused security auditing. Enables rules catching SQL concatenation, unsafe deserialization, missing route auth middleware, and API keys.
Applying Autofixes
Many common AI code defects can be safely corrected automatically:
# Apply automatic fixes across your project
npx eslint . --fix
# Or run via AI Guard CLI
npx ai-guard run --fixRules like no-floating-promise will mark deliberate fire-and-forget calls with void, no-hardcoded-secret replaces raw literals with process.env, and no-empty-catch inserts explicit error audit TODOs.
Next Steps
- Configure ESLint Flat Config in your repository.
- Integrate GitHub Actions for pull request validation with SARIF annotations.
- Run ai-guard init-context to guide Claude Code, Cursor, and Copilot before code generation.