# LeanGate

LeanGate sits inside your coding agent's loop. It checks every change against your whole repo, for reimplemented
helpers, missing error handling and security holes, and won't let the agent call the task done until they're
fixed. Python codebases today, on Python 3.11 or newer. Private beta.

## Install

### Ask your agent

Paste this into Claude Code, Codex or Cursor:

```
Install LeanGate by following https://leangates.com/agents.md
```

The agent runs the installer. You approve the machine once in your browser; nobody copies an API key.

### One command

- Windows (PowerShell): `irm https://leangates.com/install.ps1 | iex`
- macOS / Linux: `curl -fsSL https://leangates.com/install.sh | sh`

It signs the machine in (approve in the browser), downloads the build for your computer, installs it into
~/.leangate/app, puts `leangate` on the PATH, and connects your AI tools (Claude Code, Codex, Cursor, VS Code,
Gemini CLI and others). Run it again to update.

### By hand

Sign in at https://leangates.com, request access, download the build for your computer under "Get started", `pip install` it,
and run `leangate login`.

## What it checks

- Bloat: duplicates of code the repo already has, dead code, unused imports, redundant checks, pass-through
  wrappers, hand-rolled standard-library functions, unneeded dependencies.
- Error handling: swallowed exceptions, missing timeouts, unchecked subprocesses, unclosed files, imports of names
  that don't exist.
- Security: injection (SQL, shell), hard-coded secrets, verify=False, unsafe deserialization, unknown or vulnerable
  packages.

## How it works

1. Before it writes: the repo's own helpers, and the ones earlier changes used for similar tasks, arrive with the
   task.
2. After every edit: problems on the lines it just changed are flagged in milliseconds.
3. When it wants to finish: it can't call the task done while a blocking issue is open. Only a person can waive a
   security finding.
4. Every run: it learns the repo (which helper does which job, which rules hold here). Per repo, nothing shared.

## Results

Claude Code, the same tasks with and without LeanGate, on PostHog, Dagster, frappe, JumpServer and addons-server,
five runs per task, each reviewed blind by a separate model:

- Shipped the unsafe code a prompt pushed for: 19 of 25 runs without LeanGate, 0 with it.
- Used the helper the repo already has: 40% without, 64% with.
- Once LeanGate had learned the repo: 18 of 19 reused the right helper, in 5 turns instead of 8.

## MCP tools

- `verify_lean`: check the change when you finish it; returns gate=pass|block and findings.
- `check_dependency`: before adding a package (exists on PyPI, known vulnerabilities, already covered).
- `check_reuse`: before writing a general-purpose helper your own search didn't find.
- `record_feedback`: say a finding was wrong (security findings need a person: `leangate waive`).
- `minimize` / `prove_equivalent`: a smaller module with the same behavior (tests run only if the user allows it).
- `show_report`: open the local live report, when the user asks.

## Privacy

- Your repo stays on your machine: the index of every file, what LeanGate learned, its memory.
- To judge a finding, the changed snippet passes through https://leangates.com to the model providers (zero data retention);
  nothing is stored or logged, only a count of the calls.
- Run reports (rule, file, line, message; code blanked out) go to your dashboard. `LEANGATE_CLOUD=off` keeps them
  local.
- Details: https://leangates.com/privacy

## Beta

Free during the beta, with 1,000 model decisions a month per account. Past that, LeanGate keeps checking with its
own rules until the 1st. Sign in with GitHub and request access: https://leangates.com

## Links

- Setup instructions for agents: https://leangates.com/agents.md
- This page as Markdown: https://leangates.com/.md
- Index for LLMs: https://leangates.com/llms.txt
- Where your data goes: https://leangates.com/privacy
- Try it without installing: https://leangates.com/playground
