Skip to main content

Lenscheck Semantic Reviewer

Git tells you what lines changed. Lenscheck tells you what those changes mean.

Lenscheck reads a Python web codebase and, for any pull request, commit, or branch, turns a huge diff into a short, ranked list of the things that actually matter: new endpoints, new database writes, new external calls, and data that now leaves the system. It cuts through refactor noise and points you at the exact lines that matter — and it's honest about what it couldn't resolve.

Also: traced PII leaks (the exact field → where it leaves), dependency bumps that gain new powers (network/subprocess/native), PR descriptions that contradict the code, and the rules your codebase follows (discover, confirm, enforce, and blame the commit that broke one). Outputs to the terminal, a web UI, JSON, HTML, SARIF, inline PR comments, a triage label, and a Mermaid diagram. Full walkthrough: The Complete Guide in the repo (blog/lenscheck-complete-guide.md).

Install

pip install lenscheck-semantic-reviewer

Zero third-party dependencies. Needs Python 3.9+, plus git and tar on the PATH.

Commands

The repo argument can be a local path or a GitHub URL (URLs are cloned & cached).

lenscheck crossrepo — shared tables across services (new in 3.0)

lenscheck crossrepo ./orders ./billing --html crossrepo.html     # 2+ repos, PATH or PATH@BRANCH
lenscheck crossrepo ./orders ./billing --writes-only --schema schema.json
lenscheck crossrepo ./orders ./billing --changed ./orders --since main   # only what this change touches

Give it two or more repos that share a database. For every shared table it lists who writes and who reads, down to route → handler → file:line, across views and background jobs (Celery tasks, management commands, signal receivers), grouped worst-first:

  • 🔴 multi-writer: 2+ services write it → they must agree on schema and write logic
  • 🟡 producer → consumer: one writes, the others read → the writer owns the shape
  • read-only: a shared lookup, usually safe

It also lists cross-repo API calls (service A calls a route service B serves). --schema adds a column-level rule ("coordinate on unique key (order_id, user_id)"). Results are cached per repo by git HEAD. Also in the UI: lenscheck serve → Cross-repo tab. Details: CROSSREPO.md.

lenscheck map — every endpoint, worst-first

lenscheck map .                      # whole repo, grouped by app
lenscheck map . --risky --html map.html

lenscheck provenance — table → endpoint map as JSON

lenscheck provenance . --out facts.json   # facts only (table/endpoint names, no source) — safe to share

lenscheck init — one-command GitHub Action setup

lenscheck init            # writes .github/workflows/lenscheck.yml in advisory mode
lenscheck init --gate     # block merges on a confirmed-rule violation

lenscheck review — review a PR, commit, or range

lenscheck review https://github.com/owner/repo --pr 481      # a GitHub PR by number
lenscheck review /path/to/repo --commit 9cca6d24             # a single commit (vs its parent)
lenscheck review /path/to/repo --merge <merge-sha>           # a merge commit
lenscheck review /path/to/repo --base master --head feature  # any two refs / commits

Output formats and CI gating:

lenscheck review <repo> --pr 481 \
    --out review.md \                     # Markdown (default; used by CI to post a PR comment)
    --json review.json --html review.html # structured JSON + a self-contained clickable report

lenscheck review <repo> --pr 481 \
    --invariants lenscheck-invariants.json \  # enforce your confirmed rules
    --fail-on violation                   # exit non-zero on a new violation (or: crit)

Set GITHUB_TOKEN for private repos / to avoid GitHub API rate limits.

lenscheck post — put a review on a GitHub PR

lenscheck post 481 review.md --json review.json --inline --label

Posts a sticky summary comment, inline comments pinned to the exact changed lines, and one lenscheck:* triage label. Needs GITHUB_TOKEN + the gh CLI (present on GitHub runners).

lenscheck serve — interactive web UI (with graph view)

cd /path/to/repo && lenscheck serve      # auto-selects the current git repo, opens a browser

In the UI: paste a GitHub PR link, or type a PR #, commit sha, or base + head, or browse the repo's PRs. Each change gets an interactive flow graph (route → handler → tables / external / jobs) and a list of exact file:line locations.

Preload a review straight from the command line:

lenscheck serve --pr 481          # open a PR on load
lenscheck serve --commit <sha>    # open a commit's diff on load
lenscheck serve --base A --head B # open a range

Options: --repo <path-or-url> · --port 8765 · --invariants <file> · --no-open.

lenscheck invariants — discover rules from git history

lenscheck invariants /path/to/repo --snapshots 10

Ranks properties by how long they've held across history, writing invariants_report.md and invariants.discovered.json. Confirm the ones you want and feed them to lenscheck review --invariants.

Or bootstrap every repo at once: lenscheck invariants <repo> --bootstrap --baseline org-baseline.json auto-confirms the safe rules and freezes today's state, so it only flags new violations — turning the moat on across many repos with no hand-confirming.

lenscheck digest — org-wide roll-up for leadership

lenscheck digest --org my-org --slack "$SLACK_WEBHOOK"

Counts the open PRs across a whole org by the lenscheck:* triage label Lenscheck already applied — 🔴 security / 🟠 money / 🟡 new write. No re-analysis, and no GitHub Advanced Security needed. Needs a GITHUB_TOKEN with org read access.

What it detects (without running your code)

  • API routes (new / modified / removed) and their auth level (e.g. AllowAny vs Authenticated)
  • Database reads & writes — resolved to the real SQL table name
  • External API calls (Stripe, Twilio, PayTM, …)
  • Async task dispatches (Celery, threads, signals)
  • Cache reads & invalidations (Django cache: get / set / delete)
  • PII egress — personal data leaving the system

Each fact is marked ✓ verified / ⚠ potential / ? unknown — it never reports "safe" for something it didn't actually trace.

GitHub Action

# .github/workflows/lenscheck.yml
name: Lenscheck
on: { pull_request: {} }
permissions: { contents: read, pull-requests: write }
jobs:
  lenscheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: AnkushSinghGandhi/lenscheck-semantic-reviewer@v3
        with:
          fail_on: violation   # violation | crit | none

Inputs include fail_on, invariants, comment, inline, label, scan_deps, and upload_sarif (set false on private repos without GitHub Advanced Security so the SARIF upload is skipped and the check stays green).

Full documentation, the graph UI, and architecture details: GitHub repository.

License

Elastic License 2.0 — free to use, self-host, and modify; not to resell or offer as a hosted service.

Metadata

Release files for lenscheck-semantic-reviewer 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lenscheck-semantic-reviewer 3.1.0
File Size Uploaded Provenance Actions
lenscheck_semantic_reviewer-3.1.0.tar.gz 249.2 kB With provenance Details for lenscheck_semantic_reviewer-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lenscheck-semantic-reviewer 3.1.0
File Interpreter ABI Platform Actions
lenscheck_semantic_reviewer-3.1.0-py3-none-any.whl Python 3 none any Details for lenscheck_semantic_reviewer-3.1.0-py3-none-any.whl

Total release size: 458.1 kB

Release files / lenscheck_semantic_reviewer-3.1.0.tar.gz

Download URL lenscheck_semantic_reviewer-3.1.0.tar.gz
Size 249.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d0a3cf121d12baaade36007c42f90f196f5320f9e26a7b09b1e5a18f137112ec
BLAKE2b-256 checksum
How to use checksums
e3267048d49af0903b87e53fbe16f89e2f3a0b91d591e886f5ab6995ceb0b43f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / lenscheck_semantic_reviewer-3.1.0-py3-none-any.whl

Download URL lenscheck_semantic_reviewer-3.1.0-py3-none-any.whl
Size 208.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
742500a2fb6edb453f2cb5214d451131c4a94717ae9848272b6997edd46da518
BLAKE2b-256 checksum
How to use checksums
3b4df136c57e1968ee27b5936640125df418293755c5650852672a829996a1fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for lenscheck-semantic-reviewer 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lenscheck_semantic_reviewer-3.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page