v0.x pre-releaseA Lock of the Lock Family · open source · Apache 2.0

Your agent writes the query. You hold the key.

Any AI agent can query MariaDB, MySQL, PostgreSQL or SQLite through locksql. Personal data comes back masked, and connections and writes wait for you.

Install with Homebrew
brew trust davidgodefroid/tap
brew install davidgodefroid/tap/locksql davidgodefroid/tap/lox cosign

Needs Docker, lox v0.12.0+ and cosign v2.5.0+. Then lox add locksql and lox run. The whole family: brew install davidgodefroid/tap/lockfamily.

Part of the Lock Family: one hub (lox run) approves for every Lock.

locksql · profile devlox run · auto mode

Connect
askedonce per lox run sessionThe password is typed at your terminal, never by the agent.
Read
autoSELECT id, email FROM customers LIMIT 20The email column comes back <redacted>.
Write · DDL · unmask
askedevery timeRuns only on the hub’s signed decision.

Approved · y

Your rules, per profile

Each action is auto, ask or deny in .locksql/config.toml. These are the defaults.

What waits for you, and what does not, with the default rules.

See it run

An agent (here Claude Code, left) asks for the top Belgian customers. Its query waits as a ticket in lox run (right, in manual mode: every ticket is asked) until you press y; the agent then gets names and emails as <redacted>.

Why locksql?

Agent tools already ask before running a command. But that approval lives inside the agent’s own process: the agent holds the credentials, and the prompt can be configured away.

A long session also trains you to press “yes”. locksql moves the decision out of the agent.

In-agent approval compared with locksql
PropertyIn-agent approvallocksql
Agent never sees the DB passwordNoYes
Agent has no DB connectionNoYes
Approval cannot be switched off from the agent sideNoYes
Every read parsed down to its source columnsNoYes
EXPLAIN cost check before runningNoYes
PII masked on its source column, not its labelNoYes
k-anonymity warning on PII filters and aggregatesNoYes
Policy loosening needs a human confirmationNoYes
Append-only audit logNoYes

In-agent approval is a convenience; a separate approval process is a boundary.

See what you approve

Before a statement runs, the console prints its screen: the plan, the cost and the personal data it touches. The same screen goes to lockhub as a ticket, every literal masked.

With the default rules a read runs on its own. A write, a schema change or an unmasked read waits until you answer it in lox run.

╭─ DEV · 127.0.0.1 / app · user alice · tier read ─────
│ requested by uid 1000 (alice) · pid 48211 (claude)
│
│   SELECT id, email FROM customers WHERE country = 'BE' LIMIT 20
│
│ class READ · EXPLAIN: customers range ~410 · est. 410 rows examined · verdict OK
│ reads: app.customers
│ returns at most 20 rows
│ PII columns touched: customers.email (select)
│ masked outputs: email → redact
│ PII: masked (4 column rules; detectors: email, phone, iban, card)
╰─ pending: ticket 01J…
Once approved, the console runs the statement, masks PII, caps the output and hands the rows to the agent, framed as untrusted data.

Highlights

  • One key holder

    Credentials are typed at console start, read from the OS keychain, or fetched from HashiCorp Vault. The database password is never in argv, env, files, logs, the socket or error messages; a Vault token goes only to the vault child’s environment.

  • Human in the loop

    Each statement carries its plan, cost and PII footprint. Writes, schema changes and unmasked reads run only once you approve them.

  • Fail closed

    A dialect-aware classifier refuses anything it cannot classify with certainty. Reads are parsed in full; unknown syntax is refused.

  • PII masking

    Every output column is traced to its source through aliases, CTEs, unions and joins, then masked (redact by default, partial or email).

  • Weight check

    LIMIT is mandatory and EXPLAIN runs first. Plans that would scan too many rows are refused before they run.

  • OS separation

    The console runs as its own account in its own container, the agent’s MCP server in another. The kernel checks every peer on the socket they share.

  • No typed values

    Masked cells come back as <redacted>, with no reference to their value. Placeholders ('${...}') are refused at plan time.

  • Clear for you only

    Ctrl-O in the console prints the clear rows there while the agent gets them masked. Only --allow-unmask or :unmask lets an agent ask for raw PII.

  • Remote databases

    The tls settings go to the driver as they are; verify-full checks the certificate. An ssh table reaches a database behind a bastion, with no local port.

  • Writes analysed too

    A write that returns rows (RETURNING) or stores a query’s rows (INSERT ... SELECT) is parsed like a read, and its rows are masked by where they come from.

  • Refusals the agent can act on

    Every refusal carries a stable code, the place where the check stopped, a hint and a retry rule: rewrite, ask the user, or stop.

  • Tested for leaks

    The SQL analyzer is fuzzed nightly. A canary suite checks that seeded values never reach the agent unmasked, on six server versions and SQLite.

Quick start

  1. Install with Homebrew (the box above). Docker must be running.

  2. In your project, lox add locksql asks where your database is, sets up the lock and starts its console.

    cd your-project
    lox add locksql
  3. In a terminal of its own, outside any agent, keep lox run open. Every ticket shows up there for your decision.

    lox run
  4. Start your agent in the project (claude, codex, gemini, …) and ask: “how many orders were placed yesterday?”

lox add wires Claude Code. For Codex, Cursor or Gemini CLI, also run locksql init codex (or cursor, gemini).

Without Homebrew, or step by step: the install guide

Know the limits

The console is the enforcement point. Skills, rules and MCP tool descriptions only guide the agent; the console’s checks are the guarantee.

Masking is best effort, and k-anonymity is a warning: it does not stop differencing attacks.

Read the security model