Introduction
AI Guard demo — detecting AI-generated code patterns
What is AI Guard?
AI Guard is an AST-based code analyzer that detects patterns commonly found in AI-generated code. It helps maintain code quality by identifying verbose, over-commented, or poorly structured code before it reaches your repository.
Unlike traditional linters that focus on syntax and style, AI Guard specifically targets characteristics of LLM-generated code: excessive comments, generic variable names, obvious explanations, and AI-typical phrases.
The Problem
Large Language Models tend to produce code with predictable patterns that reduce maintainability:
- Excessive inline comments explaining obvious operations
- Generic variable names like 'data', 'result', 'item', 'temp'
- Verbose function documentation that restates the code
- AI-typical phrases like 'this function will...', 'we need to...'
- Unnecessarily long functions with redundant logic
AI Guard catches these patterns early, allowing you to refactor before committing.
AI Guard CLI usage output
Use Cases
- Pre-commit hooks to validate staged files
- CI/CD pipelines for pull request checks
- Editor integrations for real-time feedback
- Code review automation
- Educational tools for teaching clean code practices
Key Features
- AST-based analysis using ts-morph for accurate detection
- 5 built-in rules covering common AI patterns
- CLI tool with git staging support
- Programmatic API for custom integrations
- Configurable thresholds and rule settings
- Fast analysis with TypeScript and JavaScript support
AI Guard is not a replacement for ESLint or Prettier. It complements your existing tools by focusing specifically on AI-generated code patterns.