Skip to main content

Pluvy

PyPI Python License

An engineering policy gate for code written by people and coding agents. Pluvy parses Python, Go, Java, JavaScript/JSX and TypeScript/TSX with tree-sitter and fails the build when a change erases type contracts, swallows errors, weakens or deletes tests, or crosses the architecture boundaries your repository declares.

Website: sectrend-cn.github.io/pluvy

$ pluvy --all
src/orders.py:4:25: type.broad: Do not erase contracts with typing.Any
tests/test_orders.py:5:5: test.tautology: Assertion in test_load cannot fail because it restates the same expression or a literal true. Assert an independently produced value or outcome instead.
tests/test_orders.py:6:5: warning: unused.return: Return value from 'load' is discarded
Diagnostic scope: full_files.
Usage reference scope: 2 files.
Architecture all: 2 files; 3 findings.

Why Pluvy

  • One policy, five languages. A single committed .pluvy/pluvy.json drives the same checkers across every supported language.
  • Architecture as data. Declare owners, placements and forbidden import directions; the gate enforces them on every change.
  • Built for agent-written code. It catches shortcuts that keep CI green without doing the work: tautological or assertion-free tests, deleted tests and eroded assertions, swallowed exceptions, literal fallback chains, casts and Any.
  • Change-aware. --base and --staged report only the definitions and statements a change touches, so existing debt does not block new work.
  • Read-only. No mode modifies, stages, stashes, restores or deletes source files, and none changes Git configuration. It is safe to run in CI, in hooks and inside agent sessions.

What it checks

22 checkers, all enabled by default:

Area Checkers
Type contracts type.broad, type.annotation, type.signature, type.boundary, type.assertion, type.contract
Test integrity test.integrity (tautological and vacuous tests), test.deletion (removed tests, assertion erosion, changed snapshots)
Error handling flow.handling (swallowed handlers, long ?? literal fallbacks)
Architecture architecture.owner, architecture.structure, architecture.import, architecture.dispatch, architecture.object_model
Dead code unused.parameter, unused.function, unused.field, unused.return
Structure and size function_size, structure.guarded_projection, imports.wildcard
Suppression hygiene type.suppression (foreign and malformed suppression directives)

Options, defaults, per-language coverage and known limits are listed in Checker configuration.

Quick start

Python 3.12 or newer is required. Install the published command line from PyPI:

uv tool install pluvy

Without uv, use python -m pip install pluvy. To try it once without installing, run uvx pluvy --all.

Add a policy to the repository you want to check and commit it:

mkdir -p .pluvy
echo '{"version": 2, "include": ["src/*", "tests/*"], "checkers": {}}' > .pluvy/pluvy.json

Then run one of the three modes:

pluvy --all                 # audit every selected file, including existing debt
pluvy --base origin/main    # audit only what changed since a commit
pluvy --staged              # audit the Git index before committing

Add --root /path/to/project to run from another directory and --format json for machine-readable output.

Exit code Meaning
0 No error findings; warnings may be present
1 At least one error finding
2 Configuration, encoding, filesystem or Git failure

Getting started covers installation options, building up a policy, triaging the first audit of an existing repository and per-task gating. A Chinese translation is available.

Adopting on an existing repository

The first --all on an existing codebase usually exits 1. That is the baseline reading, not a failure of the tool. A practical path:

  1. Gate pull requests with --base so new changes are held to the policy.
  2. Work through the --all findings over time: fix the code first.
  3. Treat threshold, exclusion and owner changes as architecture decisions, each with its own full audit and review. A staged policy change is refused until that audit passes.

Exceptions use an approved next-line suppression that names one rule and a reason; see comment suppressions.

Policy

Each target repository owns .pluvy/pluvy.json; paths inside it are relative to the repository root. Start from the example policy, which declares owners, an import boundary and size limits:

{
  "version": 2,
  "include": ["src/*", "tests/*"],
  "exclude": [],
  "checkers": {
    "function_size": {"lines": 50, "complexity": 10},
    "architecture.import": {
      "boundaries": [
        {
          "name": "domain does not depend on adapters",
          "sources": ["src/domain/*"],
          "forbidden_imports": ["adapters", "adapters.*"]
        }
      ]
    }
  }
}

Specify "enabled": false only to turn a checker off; omitted checkers and options keep their defaults.

Integration

Coding agents

The bundled skill in .agents/skills/pluvy/ tells an agent when the gate applies, which mode to run after a task and how to report the result. The PyPI package contains the tool only, so copy the skill from this repository into the consuming project's skills directory, or point to it from AGENTS.md. See Agent integration.

CI

Any CI system that can install a Python package can run the same commands. This repository gates itself in GitHub Actions.

Pre-commit

Once the policy is committed, a pre-commit hook can run pluvy --staged. Install hooks yourself; Pluvy never changes Git configuration.

Extending

Language plugins own suffixes and grammar interpretation; rules implement RuleBundle over a shared TreeContext. See Plugin architecture.

Development

Set up a development environment from this checkout:

python -m pip install --no-cache-dir uv==0.8.22
uv sync --locked --group dev
. .venv/bin/activate

The required checks are listed in AGENTS.md and run in the engineering workflow. Shared code policy lives in Engineering standards.

License

MIT

Metadata

Release files for pluvy 0.0.3

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

Source distribution (sdist)

Source distribution for pluvy 0.0.3
File Size Uploaded Provenance Actions
pluvy-0.0.3.tar.gz 276.8 kB Without provenance Details for pluvy-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pluvy 0.0.3
File Interpreter ABI Platform Actions
pluvy-0.0.3-py3-none-any.whl Python 3 none any Details for pluvy-0.0.3-py3-none-any.whl

Total release size: 437.8 kB

Release files / pluvy-0.0.3.tar.gz

Download URL pluvy-0.0.3.tar.gz
Size 276.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c3bd7fec32ccb8c914c8e9d19bf127fc01ad24aac9efb7dd20b2732e61ce99f8
BLAKE2b-256 checksum
How to use checksums
5076cd3de72b307080d874d14cd9ea84e816a8fd98254918c738820bd4319d4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pluvy-0.0.3-py3-none-any.whl

Download URL pluvy-0.0.3-py3-none-any.whl
Size 161.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f21d46c7e13493fa87755cca757c0cda21c3b866784d3697dbd73332a2e46dd4
BLAKE2b-256 checksum
How to use checksums
5909acb0b412c20de1ff4f0bbf8af16dab2f532da5b756d10553b2c6c17da7cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pluvy 0.0.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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