{"slug": "17841-lines-changed-3-things-you-actually-need-to-look-at", "title": "17,841 Lines Changed. 3 Things You Actually Need to Look At.", "summary": "A developer released Lenscheck, a deterministic semantic pull-request reviewer for Python web apps (Django/Django REST Framework) that parses code with Python's standard library rather than an LLM. The tool converts a diff into a ranked set of findings and a flow graph tracing route, auth, database tables, external calls, cache, async and PII, and can discover, confirm and enforce codebase-specific rules on every PR; on a real 17,841-line PR it surfaced three items to review. It ships as a zero-dependency pip package with a GitHub Action and a local web UI, and never runs the reviewed code.", "body_md": "*Git shows you what **lines** changed. Lenscheck shows you what they **mean**, where to look, and whether\n\nthey broke a rule. It's a semantic PR reviewer for Python web apps. This guide starts from zero —\n\nevery idea, command, and setting in plain English — then shows you how to set Lenscheck up **once** and\n\nrun it across **all your repos** (personal, team, or organization).*\n\n`No LLM`  ·  `Deterministic`  ·  `Never runs your code`  ·  `Nothing leaves your network`\n\n**Try it on a repo you already have** — see the review right in your terminal:\n\n```\npip install lenscheck-semantic-reviewer\ncd your-django-repo\nlenscheck review          # your current branch vs. main → the few things that actually matter\n```\n\n**Turn it on for a team — one command** (drops a GitHub Action that reviews every PR, advisory only):\n\n```\nlenscheck init            # writes .github/workflows/lenscheck.yml (comments, never blocks)\ngit add .github/workflows/lenscheck.yml && git commit -m \"add lenscheck\" && git push\n```\n\n**Prefer to click around?** `lenscheck serve` opens a local web UI with the flow graph.\n\nThat's the whole tool: a **flow graph** of what a PR does, and **rules** it can enforce. Everything\n\nbelow is depth for when you want it.\n\nWhen you open a Pull Request (PR), the reviewer sees a **diff** — red lines removed, green lines\n\nadded. But a diff tells you *what text changed*, not **what it means**. Did this PR add a new way\n\ninto your app? Did it start writing to your database without a login check? Did someone's email\n\naddress just start leaving your server?\n\n**Lenscheck reads your PR and tells you what it *means*** — in a few high-signal findings, each pointing\n\nat the exact line to look at. It's built for Python web apps (Django / Django REST Framework today).\n\nIt is **not** an AI that guesses. It reads your code with Python's own parser and reports **facts**.\n\nWhen it isn't sure, it says so (you'll see a ⚠). It never dresses up \"I didn't see it\" as \"it's safe.\"\n\nLenscheck has a lot of features, but they exist to serve **two** that matter most. If you remember\n\nnothing else from this guide, remember these two.\n\n**The problem.** A git diff shows you *text* — hundreds of red and green lines. It doesn't tell you\n\nthat one of them opened a new endpoint, started writing to the database, or sent a user's email out\n\nof the building. On a big (often AI-generated) PR, the reviewer skims — and the risky change ships.\n\n**What Lenscheck does.** It reads the code *before* and *after* the PR and turns the diff into\n\n**meaning**: *what changed → how it flows → where to look*. A huge diff becomes a short, ranked list\n\nplus a **flow graph** of each change (route → auth → DB tables → external → cache → async → PII). On a\n\nreal 17,841-line PR, that came out to **3 things to look at.**\n\nGit tells you what *lines* changed. Lenscheck tells you what those changes *mean*.\n\n**The problem.** Every codebase has rules everyone \"knows\" — *auth before any DB write*, *personal data never leaves without a login* — but nothing actually enforces them. A PR quietly breaks one, and\n\n**What Lenscheck does.** It **discovers** those rules from your git history, lets you **confirm** the\n\nreal ones, then **enforces** them on every PR — flagging (and optionally blocking) a *new* violation\n\nwhile ignoring existing debt. This is the part that compounds: over time Lenscheck learns the rules\n\n*your* codebase cares about, and no competitor has that knowledge.\n\n**Everything else is in service of these two.** Intent-vs-behaviour contradictions, traced PII leaks,\n\ndependency-capability scanning, SARIF, inline comments, labels, the org roll-up — all of it makes the\n\ntwo features above sharper. The rest of this guide explains each one, but if the list ever feels like\n\na lot: it's a **flow graph** and **enforced rules**. That's the product.\n\n```\npip install lenscheck-semantic-reviewer\n```\n\nThat's it — Lenscheck has **zero dependencies** (it only uses Python's standard library). You now have a\n\n`lenscheck` command. Check it:\n\n```\nlenscheck --help\nLenscheck Semantic Reviewer\n\nUsage: lenscheck <command> [options]\n\nCommands:\n  init       Add the GitHub Action to this repo (one-command setup)\n  review     Run a semantic review of a PR or commit range\n  post       Post a review to a PR (sticky comment, inline comments, label)\n  serve      Start the Lenscheck web UI\n  invariants Discover baseline invariants from a repository's history\n  digest     Org-wide roll-up from the labels Lenscheck applies to PRs\n```\n\nYou can use Lenscheck in whichever way fits:\n\n`lenscheck serve`, open your browser, click around. Best for `lenscheck review …`. Best for They all share the same engine, so they find the same things.\n\nStart it inside any repo:\n\n```\nlenscheck serve\n```\n\nIt prints a URL (like `http://127.0.0.1:8765/`) and opens your browser. If you run it inside a git\n\nrepo, it auto-detects that repo for you.\n\nAlong the top you pick **what** to compare. You have four ways:\n\n`main` → `my-feature`).\nOnce a review runs, you read it top-to-bottom. Using the screenshot above:\n\n**The one-line summary** — *\"This PR adds 1 endpoint, 1 new DB write to `AuditLog`, 1 new\nexternal call… and 4 new PII signals.\"* A plain-English sentence of everything that changed,\n\nbuilt from facts. (the intent summary)\n\n**🎭 Intent vs. behavior** — the red panel. The PR called itself a *\"refactor / no behavior change,\"* but Lenscheck found it \n\n**📦 Dependency capability changes** — bumped libraries and whether the new version can *do* more\n\nthan the old one. (dependency scanning)\n\n**The tally** — 🔴 1 — how many findings at each severity.\n\n**The change list** (left) — one row per changed endpoint, worst first. Click a row to see…\n\n**The flow graph** (right) — a live picture of what that endpoint does. In the screenshot,\n\n`ExportUsers` → reads **User** (SQL table `auth_user`), writes **AuditLog** (` audit_log`), calls\n\n**hooks.example.com**, reads and writes the **cache**, and dispatches two **async** jobs\n\n(`reindex_users`, a thread) — every edge colored by kind, with the new parts highlighted. This is\n\nthe same picture Lenscheck can also draw as a\n\nMermaid diagram inside a GitHub comment.\n\n**The \"Where to look\" tab** — switch the detail pane from the graph to a flat, ranked list of\n\nevery fact with its exact `file:line` — the **WHERE** of the review, including the traced leak.\n\nClick any block in the graph (or a line here) and Lenscheck shows you the **source**, with the exact\n\nline highlighted:\n\nClick **⚖ Invariants** in the top bar:\n\nLenscheck samples your git history and shows **candidate rules** it noticed your codebase following. In\n\nthe screenshot:\n\n`[boundary]` — holds `ExportUsers` change dangerous: the new endpoint would send an email to a\nThis is the **moat** — over time you teach Lenscheck the rules *your* codebase cares about, and no\n\ncompetitor has that knowledge. (invariants)\n\n**Note:** the **Confirm** buttons only appear if you started the server with a place to save them:\n\n`lenscheck serve --invariants my-rules.json`. Without that, the panel is read-only (Lenscheck never writes\n\na file you didn't ask for).\n\n`http://…/?open=0` — deep-link that opens the review with the first change already selected.`http://…/?invariants=1` — deep-link that opens the Invariants panel automatically.`lenscheck init` — one-command setup\nDrops a ready-to-run GitHub Action into the current repo — the fastest way to adopt.\n\n```\nlenscheck init            # writes .github/workflows/lenscheck.yml in advisory mode (comments, never blocks)\nlenscheck init --gate     # start it blocking on a confirmed-rule violation instead\nlenscheck init --force    # overwrite an existing workflow\n```\n\nIt refuses to clobber an existing workflow unless you pass `--force`, and prints the two remaining\n\nsteps (commit, open a PR). Start advisory; switch to `--gate` once your rules are confirmed and trusted.\n\n`lenscheck review` — the main event\nAnalyze a PR / branch / commit and print a review.\n\nThe same review as a **self-contained HTML file** (`--html`) you can send to anyone — no install\n\nneeded:\n\n```\nlenscheck review                       # no args: review THIS branch vs the default branch\nlenscheck review /path/to/repo --base main --head my-feature\nlenscheck review https://github.com/owner/repo --pr 123\n```\n\n**Positional argument:**\n\n| Argument | Meaning | \n|---|---|\n| `repo` | A local folder **or** a GitHub URL.**Optional** — leave it out and Lenscheck uses the repo you're standing in. | \n\n**Flags — how to pick what to compare** (choose one; or none to auto-detect):\n\n| Flag | What it does | \n|---|---|\n| *(nothing)* | Review the **current branch vs. the default branch** . The zero-effort mode. | \n| `--pr 123` | Review a real GitHub Pull Request by number (needs a GitHub URL as the repo). | \n| `--base X --head Y` | Review the difference between two refs (branches, tags, or commit SHAs). | \n| `--commit SHA` | Review a single commit (compares it against its parent). | \n| `--merge SHA` | Review a merge commit (compares its two parents). | \n\n**Flags — what to produce:**\n\n| Flag | What it does | \n|---|---|\n| `--out FILE` | Where to write the Markdown report. Default: `pr_review.md` . | \n| `--json FILE` | Also write the full review as structured JSON (for tools/automation). | \n| `--html FILE` | Also write a **self-contained HTML** viewer you can open in a browser. | \n| `--sarif FILE` | Also write **SARIF** — the format GitHub reads to show findings in its Security tab. (SARIF output) | \n| `--invariants FILE` | Enforce a confirmed rules file: flag any endpoint in this PR that breaks a rule. | \n| `--fail-on violation` | **Exit with an error** if the PR breaks a confirmed rule. (Use in CI to block merges.) | \n| `--fail-on crit` | Exit with an error on **any** 🔴 finding. | \n\n`lenscheck post` — put the review on the PR\nTakes a review you already generated and posts it to a GitHub PR.\n\n```\nlenscheck post 123 pr_review.md --json pr_review.json --inline --label\n```\n\n| Argument / flag | What it does | \n|---|---|\n| `123` | The PR number. | \n| `pr_review.md` | The Markdown body to post as a **sticky comment** (it updates in place on re-runs). | \n| `--json FILE` | The structured review (needed for `--inline` and`--label` ). | \n| `--inline` | Post each finding as a comment **pinned to the exact changed line** . (inline comments) | \n| `--label` | Put one `lenscheck:*`**label** on the PR based on its worst finding. (auto-label) | \n| `--dry-run` | Print what *would* be posted, without touching GitHub. Great for testing. | \n\n*(Needs a `GITHUB_TOKEN` env var and the `gh` CLI, which GitHub's runners already have.)*\n\n```\nlenscheck serve --repo /path/to/repo --port 8765\n```\n\n| Flag | What it does | \n|---|---|\n| `--repo` | Repo to preload (default: the git repo of the current folder). | \n| `--invariants FILE` | The rules file to enforce **and** the file the Confirm buttons write to. | \n| `--port` /`--host` | Where to serve (default `8765` on`0.0.0.0` ). | \n| `--pr` /`--commit` /`--merge` /`--base` /`--head` | Open straight into a specific review on load. | \n| `--no-open` | Don't auto-open a browser window. | \n\nUseful **environment variables** for a hosted deployment:\n\n| Env var | What it does | \n|---|---|\n| `PORT` /`HOST` | Where to bind (hosts like Render set `PORT` ; default`HOST` is`0.0.0.0` ). | \n| `LENSCHECK_TOKEN` | Require `?token=…` on API calls —**set this on any public deployment.** | \n| `LENSCHECK_ALLOWED_REPOS` | Comma-separated allow-list; only matching repos may be reviewed. | \n| `LENSCHECK_BASE_PATH` | Serve under a sub-path (e.g. `/lenscheck` ) behind a reverse proxy. | \n| `LENSCHECK_DEFAULT_REPO` | The repo shown by default in the UI. | \n| `LENSCHECK_INVARIANTS` | Default invariant corpus path to enforce in the UI. | \n| `LENSCHECK_CACHE` | Where cloned repos are cached (default `~/.cache/lenscheck/repos` ). | \n| `LENSCHECK_GIT_TIMEOUT` | Seconds before a `git clone` /`archive` is aborted (guards huge repos). | \n| `GITHUB_TOKEN` | For private repos / to avoid GitHub rate limits. | \n\nTo host one shared Lenscheck UI: run `lenscheck serve --no-open` behind your usual reverse proxy, set\n\n`LENSCHECK_TOKEN` (so the API isn't open), and optionally `LENSCHECK_ALLOWED_REPOS` to fence it to just your\n\nrepos. To run Lenscheck across *all* your repos from one place, see\n\n§9 — Set up Lenscheck for all your repos.\n\n`lenscheck invariants` — discover, confirm, and blame rules\nThree jobs in one command.\n\n**Discover** — look through git history and propose candidate rules:\n\n```\nlenscheck invariants /path/to/repo --snapshots 8\n```\n\n| Flag | What it does | \n|---|---|\n| `--snapshots N` | How many points in history to sample (more = slower but more confident). | \n| `--out FILE` | Where to write the discovered candidates (JSON). | \n| `--report FILE` | Where to write a human-readable report (Markdown). | \n\n**Confirm** — turn candidates into a rules file *without hand-editing JSON*:\n\n```\nlenscheck invariants --confirm                       # interactive: press c / f / s / q per rule\nlenscheck invariants --confirm --id auth-before-write --owner security   # scripted\n```\n\n| Flag | What it does | \n|---|---|\n| `--confirm` | Enter confirm mode. Interactive unless you pass `--id` or`--all` . | \n| `--in FILE` | The discovered candidates to read from. | \n| `--corpus FILE` | The confirmed rules file to create/update. | \n| `--id NAME` | Confirm a specific rule (repeatable). | \n| `--all` | Confirm every candidate. | \n| `--owner NAME` | Record who owns the rule. | \n| `--drop-baseline` | Treat today's exceptions as **bugs to fix** , not as accepted. | \n\nIn interactive mode you press one key per rule: **c** onfirm · **f** ix (confirm, but the current\n\nexceptions are bugs) · **s** kip · **q** uit.\n\n**Blame** — find the commit that first broke a rule (semantic blame):\n\n```\nlenscheck invariants /path/to/repo --blame auth-before-write --exact\n```\n\n| Flag | What it does | \n|---|---|\n| `--blame NAME` | Which rule to investigate. | \n| `--route R` | Only blame a specific endpoint. | \n| `--exact` | **Pinpoint the precise commit** (binary-searches history; a bit slower). Without it, you get the window between two sampled snapshots. | \n\n`lenscheck digest` — the org-wide roll-up for leadership\nEvery other command answers *\"is **this** PR risky?\"*. `digest` answers the question a manager\nactually asks: *\"across **all** our repos, how much risk is sitting in review right now?\"* — in one\n\nshort message, with **no re-analysis** and **no GitHub Advanced Security**.\n\nIt works by counting labels. Each PR review applies exactly one `lenscheck:*` triage label\n\n(auto-label); the digest just searches an org for the **open** PRs still\n\ncarrying each one:\n\n```\nlenscheck digest --org my-org --slack \"$SLACK_WEBHOOK\"\n*Lenscheck digest — my-org*  (open PRs by risk)\n🔴  4  security / PII / unauth write\n🟠  9  money path\n🟡 12  new DB write / external\n```\n\nWith `--slack`, that lands in your channel every morning — one number the whole team (and leadership)\n\ncan read without opening a single PR:\n\n| Flag | What it does | \n|---|---|\n| `--org ORG` | The GitHub org/owner to summarize ( **required** ). | \n| `--repos FILE` | Optional file of `owner/repo` lines → adds an adoption line: how many repos have the workflow live and a confirmed invariants file. | \n| `--slack URL` | Post the digest to a Slack incoming webhook (otherwise it just prints). | \n\nNeeds a `GITHUB_TOKEN` with **org read** access (the default per-repo token can't search the org).\n\nAn honesty rule carries over from the analyzer: a tier it couldn't fetch shows `?`, never a\n\nfake `0`. Run it on a schedule (a weekly cron in a central repo) and it becomes the standing\n\nanswer to \"is Lenscheck worth keeping on?\" — because the labels feed it, keep `label: true` and\n\n`issues: write` on your review workflow.\n\nEach heading below is **the problem the feature solves**. The first two are the headline features from\n\n§2; everything after them is supporting cast that sharpens those two.\n\nSkim to what's relevant — you don't need to read all eleven.\n\n**The semantic diff, severity & flow graph — headline feature ①.** Lenscheck analyzes your code\n\n**before** and **after** the PR and reports the change in **behavior**. Renaming a function with no\n\nbehavior change? Silence (that's a good thing). Adding an unauthenticated database write? 🔴. Every\n\nfinding is ranked 🔴/🟠/🟡/🟢, points at a `file:line`, and gets a **flow graph** of what the endpoint\n\ndoes (route → auth → DB tables → external → cache → async → PII).\n\n**Invariants: discover, confirm, enforce, blame — headline feature ②.** The compounding asset. Four steps:\n\n```\n   ⚠ NEAR-MISS — Authenticated access before any DB write\n   - holds: 3/4 endpoints (75%)  ·  persistence: 100% → 100% → 100% → 75% across 4 snapshots\n   - exceptions — look here (1):\n       - api/users/export — open (AllowAny)  (shop/views.py:40)\n```\n\n**Confirm** (`lenscheck invariants --confirm`, or the web button) — mark the ones that are real. Saved\n\nto a rules file. No JSON editing.\n\n**Enforce** (`lenscheck review --invariants rules.json`) — every future PR that breaks a confirmed\n\nrule gets a 🔴, and `--fail-on violation` can block the merge.\n\n**Blame** (`lenscheck invariants --blame … --exact`) — find exactly which commit broke a rule:\n\n```\n   🩸 auth-before-write first broke at e23c96a (exact, in window 3e9817b..e23c96a)\n      holds 3/4 at the snapshot.\n      offending endpoint(s):\n        - api/users/export — open (AllowAny) (shop/views.py:40)\n```\n\n**Bootstrap (turn it on everywhere, no human):** confirming rules per repo doesn't scale to 20\n\nrepos. `lenscheck invariants <repo> --bootstrap --baseline org-baseline.json` discovers the rules,\n\nauto-confirms the safe ones, and **freezes today's state as the baseline** — so the rule file is a\n\n*ratchet*: it only fires on a **new** violation a PR introduces, never on existing debt. Seed it\n\nwith a shared org baseline (the universal rules) and every repo inherits the same policy; each\n\nrepo's own exceptions are filled in automatically. Auto-confirmed rules are tagged\n\n`owner: auto-bootstrap` so a human can review them later. This is what makes the moat adoptable\n\nacross a whole org instead of one repo at a time.\n\n*Everything below supports the two above.*\n\n**The intent summary.** One plain-English sentence at the top of every review, built from verified facts:\n\n*\"This PR adds 1 endpoint, 1 new DB write to `AuditLog`, 1 new external call to\n`hooks.example.com/export` and 4 new PII signals.\"*\n\nOther tools generate this with an AI that reads the diff and sometimes makes things up. Lenscheck counts\n\nreal facts, so every number traces to a line.\n\n**Intent vs. behavior.** Your PR title/description is a **promise**. Lenscheck checks it against the facts.\n\nFrom the demo, the PR titled *\"refactor: tidy up user views\"* got caught twice:\n\n```\n🎭 Intent vs. behavior — PR describes itself as \"refactor / no behavior change\", but the facts disagree\n🔴 claims refactor / no behavior change, but adds an endpoint — api/users/export @ shop/views.py:40\n🔴 claims refactor / no behavior change, but new PII signal: email → log.info — api/profile @ shop/views.py:32\n```\n\n**PII taint — the precision feature.** Old tools say *\"personal data and an external call are both in this function — maybe it leaks.\"* Vague. Lenscheck \n\n`email → requests.post @ line 46`. The exact field, the exact exit, the exact line.\nIt also resolves fuzzy database writes: `for order in Order.objects.filter(...): order.save()` is now\n\nunderstood as writing the **Order** table, not a vague `<instance>`.\n\n**Dependency capability-delta.** When a PR bumps a library, Lenscheck downloads the **old** and **new**\n\nversions and compares what each can *do* — checking for **network / subprocess / native code / file writes / reading secrets**. It reports only the \n\n`requests 2.28→2.31: no new capabilities` 🟢`leftpad 1.0→2.0: now spawns a subprocess` 🔴\nIf it can't fetch a version (offline, or the package has no source), it says **⚠ unresolved** — never\n\n\"safe\":\n\n```\n📦 Dependency capability changes\n⚠ requests 2.28.0→2.31.0 — capabilities not statically resolved (offline or no sdist)\n⚠ six 1.15.0→1.16.0 — capabilities not statically resolved (offline or no sdist)\n```\n\nTurn the network scan off with `LENSCHECK_SCAN_DEPS=0` (or the Action's `scan_deps: false`) and you'll\n\nalways get the fast ⚠ mode.\n\n**Mermaid flow diagram.** Every review's Markdown includes a **Mermaid sequence diagram** of the\n\nbefore→after flow. GitHub renders it right inside the PR comment — a real picture of your endpoint's\n\nbehavior, drawn from facts, not by an AI:\n\nmermaid\nsequenceDiagram\n    participant Client\n    participant NExportUsers as ExportUsers\n    Client->>NExportUsers: 🆕 POST api/users/export\n    NExportUsers->>Database: write AuditLog\n    NExportUsers->>Database: read User\n    NExportUsers->>External: https://hooks.example.com/export\nGitHub renders that right inside the PR comment — a real picture of the endpoint's behavior, drawn\n\nfrom facts:\n\n**Inline PR comments.** `lenscheck post … --inline` pins each finding as a comment **on the exact line**. The honest guard: it only pins a comment where it can prove the line is in the diff (GitHub\n\n**Auto-label.** `lenscheck post … --label` puts **one** triage label on the PR based on its worst\n\nfinding: `lenscheck:🔴security` / `lenscheck:🟠payment` / `lenscheck:🟡new-write` /\n\n`lenscheck:🟢safe-refactor`. Makes a queue of PRs scannable at a glance.\n\n**SARIF output.** `--sarif pr_review.sarif` writes a standard file GitHub understands. Upload it and\n\nyour findings show up **on the exact changed lines** in the PR's \"Files changed\" tab and in the repo's\n\n**Security** tab — native, official, high-visibility.\n\n**Smart default target.** Running `lenscheck review` with **no arguments** inside a repo just does the\n\nobvious thing: reviews your **current branch vs. the default branch**. If you're *on* the default\n\nbranch, it tells you to switch to a feature branch instead of guessing.\n\nAdd this workflow and Lenscheck reviews every PR automatically:\n\n```\n# .github/workflows/lenscheck.yml\nname: Lenscheck Semantic Review\non: pull_request\npermissions:\n  contents: read\n  pull-requests: write     # to post comments\n  issues: write            # to apply the label\n  security-events: write   # to upload SARIF\njobs:\n  lenscheck:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: AnkushSinghGandhi/lenscheck-semantic-reviewer@v1\n        with:\n          fail_on: none          # or: violation | crit\n```\n\nEvery input:\n\n| Input | Default | What it does | \n|---|---|---|\n| `github_token` | auto | Token for reading the PR and posting back. | \n| `fail_on` | `none` | `violation` fails the build on a broken rule;`crit` fails on any 🔴. | \n| `invariants` | *(none)* | Path to a confirmed rules file to enforce. | \n| `comment` | `true` | Post the sticky summary comment. | \n| `inline` | `true` | Also post inline comments on changed lines. (inline) | \n| `label` | `true` | Apply one `lenscheck:*` label. (label) | \n| `scan_deps` | `true` | Scan bumped dependencies against PyPI. Set `false` to skip the network (findings become ⚠). (deps) | \n| `upload_sarif` | `true` | Upload SARIF to code scanning. Set `false` on private repos**without** GitHub Advanced Security so the step is skipped and the check stays green. | \n\nThe Action uploads SARIF (when `upload_sarif` is on), so findings appear in the Security tab —\n\nthat surface needs GitHub Advanced Security on private repos. Without GHAS, the same findings still\n\narrive as the PR comment, inline comments, and label, and an org-wide roll-up is available via\n\n`lenscheck digest` (below).\n\nSection 8 put Lenscheck on **one** repo. This section turns it on across **every repo you own** —\n\npersonal projects, a team's services, or a whole company — from **one place**, with almost no\n\nper-repo work.\n\nThe trick: **host the workflow once, and have every repo point at it.** Then you switch Lenscheck on (or\n\nchange how it behaves) by editing a single file, not twenty. It's the same steps whether you have 1\n\nrepo or 100.\n\nMake a repo — call it `lenscheck-workflows` (under your username or org) — and add the real workflow\n\nthere **once**, as a **reusable workflow**:\n\n```\n# lenscheck-workflows/.github/workflows/lenscheck.yml\nname: Lenscheck\non: { workflow_call: {} }\npermissions: { contents: read, pull-requests: write, issues: write }\njobs:\n  lenscheck:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n        with: { fetch-depth: 0 }\n      - uses: AnkushSinghGandhi/lenscheck-semantic-reviewer@v1\n        with:\n          comment: 'true'\n          fail_on: none          # observe mode — never blocks a merge (yet)\n          upload_sarif: false    # set true only if you have GitHub Advanced Security\n```\n\nThen every repo gets a tiny **3-line caller** that just points at it:\n\n```\n# any-repo/.github/workflows/lenscheck.yml\nname: Lenscheck\non: { pull_request: {} }\njobs:\n  lenscheck:\n    uses: your-name/lenscheck-workflows/.github/workflows/lenscheck.yml@v1\n    permissions: { contents: read, pull-requests: write, issues: write }\n```\n\nNow updating Lenscheck *everywhere* means editing **one** file in `lenscheck-workflows`. That's the\n\n\"centralised\" part — and it's identical for a personal account, a team, or an org.\n\nNotice `fail_on: none` above. That's **observe mode**: Lenscheck posts its review on every PR but\n\n**can never block a merge**. Zero risk — you and your team see the value for a week or two before it\n\ncan ever get in the way. You turn on blocking later, once you trust it (Step 5).\n\nKeep `issues: write` + `label: 'true'` on. Lenscheck puts one `lenscheck:*` label on each PR, and Step 4's\n\nroll-up counts those labels — no label, no roll-up.\n\n**Adding the caller to many repos:** for a handful, paste it in by hand. For a lot, a small script\n\nthat loops your repo list and opens the 3-line PR on each (using the `gh` CLI) does it in one go — or,\n\non GitHub Enterprise, an org \"required workflow\" applies it automatically.\n\nThis is the part that makes Lenscheck *yours*: enforcing the promises **your** code already keeps\n\n(\"always log in before writing to the DB\", \"personal data never leaves without auth\"). Normally you'd\n\ndiscover rules, confirm each by hand, and commit a file — fine for one repo, tedious for many.\n\n`lenscheck invariants --bootstrap` does it with **no human**:\n\n```\nlenscheck invariants <repo> --bootstrap --baseline org-baseline.json --out lenscheck-invariants.json\n```\n\nIt finds the repo's rules, auto-confirms the safe ones, and **freezes today's state** as the starting\n\nline — so it only ever complains about a **new** violation a future PR introduces, never your existing\n\ncode. Zero noise.\n\nWrite your shared rules once in an `org-baseline.json` (start from\n\n[`org-baseline.sample.json`](//../org-baseline.sample.json)) — the universal ones like *auth before any DB write* and \n\n`lenscheck-invariants.json`, and the workflow enforces it from then on.\nPer-PR comments help whoever's on that PR. For the **big picture** — *how many risky PRs are open right now* — \n\n`lenscheck:*` label:\n\n```\nlenscheck digest --org your-github-org --slack \"$SLACK_WEBHOOK\"\n🔴  4  security / PII / unauth write\n🟠  9  money path\n🟡 12  new DB write / external\n```\n\nNo re-analysis, and **no GitHub Advanced Security needed** — it just reads the labels. Run it on a\n\nweekly schedule and pipe it to Slack. (This one aggregates a whole GitHub **org**; for personal repos\n\nthe per-PR labels already give you the same signal on each PR.)\n\nOnce people trust the reviews, flip the switch in your **one** central file — and only for the\n\nhighest-confidence signal:\n\n```\n      - uses: AnkushSinghGandhi/lenscheck-semantic-reviewer@v1\n        with:\n          fail_on: violation     # block only when a PR breaks a confirmed rule\n```\n\nNever block on \"any 🔴\" from day one — that's how a tool gets switched off. Block only on a **new rule violation**, once your rules are confirmed and trusted.\n\nIf other people will depend on this, **mirror the Action into your own account/org and pin a commit SHA** instead of pointing at a public \n\n`@v1` tag — the reusable workflow means you fix that in one\nHere's the exact scenario from the screenshots. A developer opens a PR titled\n\n**\"refactor: tidy up user views.\"** It claims to be a harmless cleanup. In reality it:\n\n`POST /api/users/export` with `AllowAny`),` AuditLog` table and `GET /api/profile` to `requests` and `six`.\nRun it:\n\n```\nlenscheck review /path/to/repo --commit <sha> --sarif out.sarif\n```\n\nLenscheck produces, in one pass:\n\n`api/users/export`:` email → requests.post @ shop/views.py:46`.\nEvery single item points to a line you can click. Nothing was guessed.\n\nLenscheck's whole value is that you can **trust** it. So it follows strict rules:\n\n`file:line`.\n\n```\n# review\nlenscheck review                                  # this branch vs default branch\nlenscheck review . --base main --head feature     # two refs\nlenscheck review URL --pr 123                      # a GitHub PR\nlenscheck review . --commit <sha>                  # one commit\nlenscheck review . --sarif out.sarif --html r.html # extra outputs\nlenscheck review . --invariants rules.json --fail-on violation   # enforce + block\n\n# post to a PR\nlenscheck post 123 pr_review.md --json pr_review.json --inline --label\nlenscheck post 123 pr_review.md --dry-run          # preview, no posting\n\n# web UI\nlenscheck serve                                    # this repo\nlenscheck serve --repo . --invariants rules.json   # + enable Confirm buttons\n\n# invariants (rules)\nlenscheck invariants .                             # discover candidate rules\nlenscheck invariants --confirm                     # confirm interactively\nlenscheck invariants --confirm --id auth-before-write --owner security\nlenscheck invariants . --bootstrap --baseline org-baseline.json   # auto-confirm + ratchet (no human)\nlenscheck invariants . --blame auth-before-write --exact   # who broke it\n\n# digest (org-wide roll-up for leadership)\nlenscheck digest --org my-org                       # open PRs by lenscheck:* label\nlenscheck digest --org my-org --repos repos.txt --slack \"$SLACK_WEBHOOK\"  # + adoption, to Slack\n\n# env vars\nLENSCHECK_SCAN_DEPS=0     # skip the dependency network scan\nLENSCHECK_TOKEN=…         # lock down a hosted `lenscheck serve`\nLENSCHECK_CACHE=…         # where cloned repos are cached (default ~/.cache/lenscheck/repos)\nLENSCHECK_GIT_TIMEOUT=…   # seconds before a git clone/archive is aborted\n```\n\nYou'll meet these terms everywhere. Here they are in plain English.\n\n**Endpoint** — a single \"door\" into your web app. A URL + the code that runs when someone hits it.\n\nExample: `POST /api/users/export` runs the `ExportUsers` function. Lenscheck reviews your PR one\n\nendpoint at a time.\n\n**The 7-edge lens** — for each endpoint, Lenscheck asks seven simple questions (these are the \"edges\"):\n\n| Edge | The question it answers | \n|---|---|\n| **Route** | What URL is this, and which function handles it? | \n| **Auth** | Do you need to be logged in? (or is it open to anyone?) | \n| **DB** | Does it read or **write** the database? Which tables? | \n| **External** | Does it call the outside world? (Stripe, a webhook, an API…) | \n| **Async** | Does it kick off a background job? (Celery, a thread…) | \n| **Cache** | Does it read or invalidate the cache? Which keys? | \n| **PII** | Does it touch **personal data** (email, phone, address…)? | \n\n**Severity colors** — Lenscheck ranks every finding by how much it should worry you:\n\n**PII** — \"Personally Identifiable Information\": personal data like an **email, phone number, address, password, card number**. Leaking it is a legal and trust problem.\n\n**PII egress** — \"egress\" just means *leaving*. **PII egress** = personal data **leaving your server** — sent to an external API, written to a log, or returned to the browser. That's the moment\n\n**Taint** — following a piece of data as it moves through the code. If an email is \"tainted,\" Lenscheck\n\nwatches whether that exact value **reaches an exit** (an external call, a log, a response). If it\n\ndoes, that's a confirmed leak.\n\n**Invariant** — a rule your codebase has *always* followed, whether or not anyone wrote it down.\n\nExample: *\"every endpoint that writes to the database first checks you're logged in.\"* Lenscheck can\n\n**discover** these from your git history, let you **confirm** the real ones, and then **enforce**\n\nthem on every PR.\n\n**Semantic diff** — a normal diff compares *text*. A **semantic diff** compares *meaning*: Lenscheck\n\nanalyzes your code before and after the PR and reports the difference in **behavior** (new\n\nendpoints, new DB writes, new calls…), ignoring cosmetic changes like renaming a function.\n\nEverything above happens **before merge** — the reviewer *discovers* the rules your code follows and\n\nflags a PR that breaks one. Its companion, [lenscheck-contract](https://github.com/AnkushSinghGandhi/lenscheck-contract)\n\n(a tiny, MIT-licensed runtime library), closes the loop **at runtime**: your app keeps a declared list\n\nof what each endpoint is allowed to do — write these tables, call these hosts — and **can't lie about it**. An undeclared DB write or a new external call is blocked (or logged) the moment it happens.\n\nSo a rule you confirmed here — *\"auth before any DB write,\" \"personal data never leaves without auth\"* — can be \n\n*Lenscheck is source-available (Elastic-2.0). Built by [Ankush Singh Gandhi](https://warriorwhocodes.com). Questions,\nstars, and sponsorships welcome on [GitHub](https://github.com/AnkushSinghGandhi/lenscheck-semantic-reviewer).*", "url": "https://wpnews.pro/news/17841-lines-changed-3-things-you-actually-need-to-look-at", "canonical_source": "https://dev.to/ankushsinghgandhi/17841-lines-changed-3-things-you-actually-need-to-look-at-1k22", "published_at": "2026-11-16 09:42:19+00:00", "updated_at": "2026-11-16 09:51:20.455389+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["Lenscheck", "Django", "Django REST Framework", "GitHub"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/17841-lines-changed-3-things-you-actually-need-to-look-at", "markdown": "https://wpnews.pro/news/17841-lines-changed-3-things-you-actually-need-to-look-at.md", "text": "https://wpnews.pro/news/17841-lines-changed-3-things-you-actually-need-to-look-at.txt", "jsonld": "https://wpnews.pro/news/17841-lines-changed-3-things-you-actually-need-to-look-at.jsonld"}}