lawpatch

Docs

Lawpatch for engineers

Everything you need to scan a repository, read the report and let your coding agent fix what it finds.

Quickstart

  1. Sign in and create a project. Copy the API key (shown once).
  2. In the root of your repository run the init command from the dashboard. It writes lawpatch.config.json (safe to commit) and stores the key in ~/.lawpatch/credentials.json (never in the repo).
  3. Preview exactly what would be sent with --dry-run, then scan.
npx @lawpatch/sdk init --key olv_… --markets EU,UK,US,TR --model b2c
npx @lawpatch/sdk scan --dry-run   # prints the full payload, sends nothing
npx @lawpatch/sdk scan             # local scan → analysis → report link

How the analysis works

Nine steps, seven of them agents. Each one is instrumented, so every report carries a trace of what ran, for how long and at what token cost.

CartographerBuilds the processing model from your structure: activities, journeys, AI systems, transfers — plus the questions static analysis cannot answer.
Triage counselTurns signals into distinct legal issues, each with a neutral statement of facts and fact-pattern tags.
Precedent researcherHybrid retrieval: embeddings, fact-pattern overlap, statute overlap, authority weight (does it bind your markets?) and recency.
Precedent analystWalks each candidate decision element by element against your facts: met / likely-met / unclear / not-met, binding or persuasive, and what would distinguish you.
CounselScenarios with a sourced exposure figure, and an engineering fix plan that names your files.
Reviewing counselRed-teams the draft: unsupported premises, missed mitigations, disproportionate severity. Can downgrade or dismiss.
StrategistLooks across findings: how they compound into one incident, and the order to fix them in.
GuardrailsDeterministic: citations must exist, exposure figures must have a source, evidence caps severity.
ReconciliationMatches findings to your last scan so your triage decisions survive, and flags regressions.

The corpus is not prose: every decision carries its holding, the elements of the legal test as applied, the facts that would distinguish it, where it binds and whether it is still good law. That is what lets the analyst reason by analogy instead of by keyword.

CLI reference

lawpatch initConnect the repo to a project. Flags: --key, --markets, --model, --sector, --description, --api-url, --yes
lawpatch scanScan and analyse. Flags: --dry-run, --json, --share-snippets, --fail-on <severity>, --no-wait, --force
lawpatch findingsList findings from the latest scan (--status open|in_progress|resolved|accepted_risk)
lawpatch fix <id>Print the fix brief, or --tool cursor|claude|codex to hand it off
lawpatch connect <tool>Install the MCP server into cursor, claude, codex or vscode
lawpatch mcpRun the MCP server over stdio
lawpatch whoamiShow the project the current key belongs to

Environment variables: LAWPATCH_API_KEY (overrides the stored key — use it in CI), LAWPATCH_API_URL (self-hosted deployments).

lawpatch.config.json

{
  "projectId": "…",
  "context": {
    "markets": ["EU", "TR", "US"],
    "businessModel": "b2c",
    "sector": "fitness",
    "description": "Coaching app with AI-generated training plans",
    "audienceIncludesChildren": false
  },
  "exclude": ["legacy", "scripts/fixtures"],
  "shareSnippets": false,
  "failOn": "critical"
}

context matters: the same code can be low-risk for a B2B tool and high-risk for a consumer app used by teenagers. shareSnippets attaches a masked one-line snippet to each signal for sharper analysis — strings, numbers, e-mails and URLs are replaced before sending.

MCP server

The SDK includes an MCP server exposing six tools: list_findings, get_fix_brief, get_plan, search_precedents, mark_finding and scan_project — so an agent can check a precedent before making a change, implement a fix, mark it and re-scan to verify. Install it from Connect agents or:

claude mcp add lawpatch -- npx -y @lawpatch/sdk mcp
codex mcp add lawpatch -- npx -y @lawpatch/sdk mcp

CI / GitHub Actions

On a pull request Lawpatch leaves three things behind: inline annotations on the exact lines, a sticky comment that is edited in place on every push rather than piling up, and a job summary. Add --fail-on high and the build goes red before the merge.

# .github/workflows/lawpatch.yml
name: Lawpatch
on: [pull_request]
permissions:
  contents: read
  pull-requests: write        # needed for the sticky comment
jobs:
  legal-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 22 }
      - run: npx -y @lawpatch/sdk scan --comment --fail-on high
        env:
          LAWPATCH_API_KEY: ${{ secrets.LAWPATCH_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The comment carries the risk score, what changed since the last scan (new / regressed / fixed), the top findings with the precedent behind each one, and the recommended fix order. Annotations can be turned off with --no-annotations.

Programmatic API

import { analyze, scanProject } from "@lawpatch/sdk";

// Full round-trip: local scan → analysis → findings
const { findings, riskScore } = await analyze();

// Local only: inspect signals without sending anything
const { payload } = await scanProject({ root: process.cwd(), context });

Security model

Precedent corpus

A curated set of court decisions and regulator actions across the US, UK, EU, Türkiye and the ECtHR, each summarised as a holding and a concrete lesson for software teams and embedded for semantic retrieval. A weekly job ingests new appellate decisions from CourtListener and, where licensed, The National Archives' Find Case Law. Machine-summarised entries are labelled until an editor verifies them. The counsel agent can only cite decisions that exist in the corpus; a citation guard removes anything else.

Limitations