Code Auditor

Your codebase has rules your AI agent doesn't know. Install one skill — it enforces them on every edit it makes.

Two commands to install everywhere:

npm install -g code-auditor-mcp
code-audit install --agent all

Claude Code, Cursor, Codex, Gemini CLI, and any SKILL.md agent. Blocking hooks on Claude Code and Codex; MCP reporting everywhere. code-audit install --list shows the matrix.

How It Works

You declare the rules once. The agent enforces them on every edit — before anything reaches your repo.

You declare the rules once — .codeauditor.json

{
  "rules": [
    {
      "id": "no-lodash",
      "kind": "import-ban",
      "severity": "critical",
      "module": "lodash",
      "message": "Use native Array/Object methods instead of lodash"
    },
    {
      "id": "no-new-function",
      "kind": "ast-pattern",
      "severity": "critical",
      "pattern": "new Function($$$)",
      "message": "new Function() is eval by another name"
    },
    {
      "id": "tailwind-only",
      "kind": "style-mechanism",
      "severity": "warning",
      "allow": ["tailwind"],
      "path": "src/components/**",
      "message": "Only Tailwind in src/components/"
    },
    {
      "id": "no-raw-colors",
      "kind": "no-raw-values",
      "severity": "warning",
      "properties": ["color", "background-color"],
      "path": "src/pages/**",
      "message": "Use design tokens, not raw hex"
    }
  ]
}
  1. 01

    Install the skill

    code-audit install --agent claude

    Drops a SKILL.md into your agent — plus a PostToolUse hook and MCP server where the agent supports them.

  2. 02

    Declare your invariants

    .codeauditor.json

    Import bans, call constraints, module boundaries, naming, AST patterns, style mechanisms, raw-value bans. Your codebase's laws.

  3. 03

    The agent audits its own edits

    code-audit changed --fail-on critical

    The skill teaches the agent to run code-audit on the files it changed, instead of grep. On Claude Code and Codex, the hook fires it after every Write and Edit.

  4. 04

    Critical violations block the edit

    no-lodash · critical · src/utils/format.ts:3

    The agent reads the rule id, severity, file, line, and message — fixes it — and only passing code reaches your repo.

TypeScript, JavaScript, Go, and CSS/SCSS — parsed with tree-sitter WASM grammars.

What It Catches

Thirteen analyzers across TypeScript, JavaScript, Go, and CSS/SCSS — the bugs your agent introduces and your review misses.

SQL injection

`SELECT * FROM users WHERE id = ${id}`

String-built queries. The data-access analyzer flags injection, tenant leaks, and N+1s before they reach review.

Cross-tenant leak

SELECT * FROM orders // no org filter

A multi-tenant query missing WHERE org_id = ?. One customer's data, another customer's screen.

Banned import

import _ from "lodash"

You banned lodash. The agent imports it anyway. It finds out in the edit, not the PR.

Circular dependency

a.ts → b.ts → a.ts

Broken tree-shaking and undefined at import time, caught before it ships.

The full catalog — thirteen analyzers

SOLID Principles

The five principles, enforced mechanically.

DRY Violations

Copy-paste, caught before it's debt.

Data Access & Security

SQL injection, tenant leaks, N+1s.

Documentation Quality

Undocumented exports are future bugs.

React Best Practices

The mistakes that survive review.

Schema Awareness

Queries referencing columns that don't exist.

Invariant Rules

Your team's rules, enforced as hard invariants.

Schema Definitions

When schema and code disagree.

API Contract

Endpoints, fields, auth vs the contract.

Dependency Graph

Cycles, coupling, hubs, orphans.

Styles

Token drift, z-index sprawl.

Conventions

Mines your code's conventions, flags deviations.

Cross-Domain

What's visible only across boundaries.

Diff-Scoped, Every Edit

Your agent runs code-audit changed on the files it just touched, not the whole project. Each analyzer returns structured violations — file, line, severity, rule id, and a message the agent can read and fix.

JSON output
SARIF 2.1.0 output
CSV output
HTML output