How it works

One program that reads your SQL and applies your policy

Lexega runs in your CI or next to your application. It reads SQL files or SQL an agent writes, works out what they do, and returns a decision your pipeline can act on.

From a SQL file to a decision

  1. 01

    Render

    dbt models and Jinja templates are rendered the way they will run, without Python, dbt or a warehouse. A ref() becomes the real table name.

  2. 02

    Read

    Each statement is parsed in its own dialect: Snowflake, SQL Server, PostgreSQL, BigQuery, MySQL, Databricks or Redshift.

  3. 03

    Analyze

    Lexega works out what the SQL does: which rows a write touches, how joins and filters combine, where an input value ends up, which grants and policies change.

  4. 04

    Compare

    On a pull request, each changed statement is compared with its version on the base branch, so the review says what changed in behavior: a filter removed, a join changed, a policy dropped.

  5. 05

    Decide

    Your policy turns findings into allow, warn or block, and the run writes a decision record and an exit code.

Reading, rendering and analyzing each statement, and enforcing a policy, are free. Comparing with the base and analysis across statements need a trial or Team key.

Where it runs

On every pull request

The changed SQL is reviewed against your policy. Findings land as a comment on the pull request, and the check fails when a change trips the policy. SARIF output goes to GitHub code scanning; GitLab gets its own security report format.

Set up your first review

In front of an AI agent

Every query an agent writes is checked against the same policy before it executes, through an MCP server or by piping SQL to the program. The agent gets a decision it cannot change.

AI agents

A complete GitHub Actions workflow

name: SQL review
on: [pull_request]

jobs:
  lexega:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Install Lexega
        run: |
          curl -sSL -O https://github.com/Lexega/lexega/releases/download/v3.0.0/lexega-sql-linux-x64
          curl -sSL https://github.com/Lexega/lexega/releases/download/v3.0.0/CHECKSUMS.sha256 | grep ' lexega-sql-linux-x64$' | sha256sum -c -
          sudo install -m 755 lexega-sql-linux-x64 /usr/local/bin/lexega-sql

      - name: SQL review
        env:
          LEXEGA_LICENSE_KEY: ${{ secrets.LEXEGA_LICENSE_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          lexega-sql ci --dialect snowflake --policy .lexega/policy.yml --env prod --decision-out .lexega/decisions/${{ github.run_id }}/ --pr-comment

This workflow enforces a policy and needs no key; with a trial or Team key in the LEXEGA_LICENSE_KEY secret, the review also compares each change with its base. Set --dialect to your SQL, and --env to the environment the change deploys to. The same command works on GitLab, Azure DevOps and Bitbucket: CI/CD Integration.

What makes it a control

Same answer every time

The same SQL and policy always give the same findings and verdict, so it can block a merge.

Runs inside your environment

One program. No account, no telemetry, works without internet access.

Never touches your data

It reads SQL text and never connects to run a query.

A record for every decision

With a policy, each run writes a decision record per file, hashed over the SQL, the policy and the result.

Your rules, same engine

Write your own checks in plain YAML, or tune any built-in one. They run on the same engine, free.

Lexega analyzes SQL text and never reads the rows it touches. Whether a deployment brings anything into GDPR, HIPAA or PCI scope depends on what you enable and where its outputs go; the data-flow boundaries are in Security & Privacy.

Run it on your repository today

Install free and analyze plain SQL in a minute. dbt rendering and policy enforcement need no key. A 30-day trial key adds the comparison of each change with its base and analysis across statements.