Stanch

Run your first check.

Try a Python diff in your browser, keep your code on your machine, or connect your editor to the hosted audit.

In the browser

Open the inspector and audit the prefilled patch. Each finding identifies a rule and the file and line to review. Paste your own unified diff to check another change.

Open the diff inspector

In your terminal

You need Python 3.11 or newer and Git. From the root of your project, save the Stanch CLI one directory above it. Compare the digest printed below with the published SHA-256 checksum before running the archive.

macOS and Linux
curl -fL "https://api.stanch.dev/downloads/stanch.pyz" -o ../stanch.pyz
python3 -c "import hashlib, pathlib; print(hashlib.sha256(pathlib.Path('../stanch.pyz').read_bytes()).hexdigest())"
Windows PowerShell
Invoke-WebRequest "https://api.stanch.dev/downloads/stanch.pyz" -OutFile ../stanch.pyz
(Get-FileHash ../stanch.pyz -Algorithm SHA256).Hash

Once the checksums match, audit your changes since HEAD. Use python3 if that is the name of your interpreter. Run check to include your project’s tests and configured probes, save the receipt outside the repo, then verify it against the working tree.

python ../stanch.pyz audit --repo .
python ../stanch.pyz check --strict --markdown --write-receipt ../stanch-receipt.json
python ../stanch.pyz verify-receipt ../stanch-receipt.json

In continuous integration

Pin the reviewed archive’s 64-character checksum in a CI variable named STANCH_CLI_SHA256. Update that value when you review a new CLI release. Fetch the target branch and its history. On a Linux runner targeting main, use the following shell step.

set -eu
curl -fL "https://api.stanch.dev/downloads/stanch.pyz" -o ../stanch.pyz
printf '%s  ../stanch.pyz\n' "$STANCH_CLI_SHA256" | sha256sum --check -
python ../stanch.pyz check --base origin/main --strict --markdown --write-receipt ../stanch-receipt.json

Publish the JSON receipt as a CI artifact. Strict mode exits unsuccessfully on a failed rule, a failed probe, or a run where no runtime checks executed. Configure this job as a required check to gate merges.

In your editor

The hosted MCP server exposes audit_diff for Python patches and distill_log for tool output. These configurations work anonymously under the hosted trial limit.

Cursor

Add the server to ~/.cursor/mcp.json.

{
  "mcpServers": {
    "stanch": {
      "url": "https://api.stanch.dev/mcp"
    }
  }
}
Claude Code

Add the server to your project’s .mcp.json.

{
  "mcpServers": {
    "stanch": {
      "type": "http",
      "url": "https://api.stanch.dev/mcp"
    }
  }
}
Codex

Add this entry to your Codex config.toml.

[mcp_servers.stanch]
url = "https://api.stanch.dev/mcp"

To keep tool calls local, configure a stdio server with command python and arguments ["/absolute/path/to/stanch.pyz", "mcp"]. The CLI also supplies a stop hook. Claude Code can block completion, Cursor can request a follow-up, and Codex can add context.

python ../stanch.pyz hook --harness claude --mode stop --require-receipt ../stanch-receipt.json

From any HTTP client

From a repository with uncommitted changes, stream the diff to the audit and read the JSON result. This example uses curl in a POSIX shell.

git diff HEAD | curl -sS -H 'Accept: application/json' --data-urlencode 'diff@-' 'https://api.stanch.dev/api/audit'

Working in a different language? The log digest works with plain-text build and test output across stacks. Send a saved log to keep its failure lines and file paths in a shorter response.

curl -sS -H 'Accept: application/json' --data-urlencode 'log@build.log' 'https://api.stanch.dev/api/digest'

With a free account key, send an Authorization: Bearer header containing your key. Keep keys in your environment or CI secret store.

Read the API documentation