Skip to main content

xpd

xpd checks Python code for slow operations and wrong results. It checks code that uses pandas, NumPy, SciPy, scikit-learn or Apache Hamilton. xpd can rewrite many of the lines it reports, and a coding agent can run it after every edit.

What xpd reports

samples/bad.py holds slow loops and pandas assignments that write to a copy. The diff below shows what xpd check samples/bad.py --fix --unsafe-fixes changes. Each comment names the rule that reports the line.

 import pandas as pd

 df = pd.DataFrame({"a": [1, 2], "k": [1, 2]})
 other = df.copy()
 for i, row in df.iterrows():           # warning  pandas/row-loop
-    df["a"][i] = row["a"] * 2          # error    pandas/chained-assignment
+    df.loc[i, "a"] = row["a"] * 2
-df.dropna(inplace=True)                # info     pandas/no-inplace
+df = df.dropna()
 m = pd.merge(df, other, on="k")        # warning  pandas/merge-without-validate
 out = pd.DataFrame()
 for f in ["x.csv"]:
     out = pd.concat([out, pd.read_csv(f)])  # warning  pandas/concat-in-loop

Each message says what goes wrong and what to write instead.

samples/bad.py:6:5: error [pandas/chained-assignment] Chained assignment writes to a copy under copy-on-write, so the frame keeps its old values. Assign to df.loc[i, "a"] instead.

An issue has one of three severities, and a fix is either safe or unsafe.

Word Meaning
error The code gives a wrong result or raises. Fix it.
warning The code is slow or easy to get wrong. Fix it unless you can say why it is right here.
info A shorter or newer form exists.
safe fix Keeps what the code does. --fix writes it.
unsafe fix May change what the code does. --fix --unsafe-fixes writes it, so read the diff afterwards.

Rules

Each library has one pack of rules, written for the library's current version. A library's pack runs only on files that import the library. The Python pack runs on every file.

Pack One of its rules What the rule reports
pandas chained-assignment df["a"][i] = v writes to a copy, so the frame keeps its old values
NumPy append-flattens np.append without axis flattens both arrays
SciPy removed-keyword tol= on the sparse iterative solvers was removed and raises TypeError
scikit-learn fit-on-test A fit on the test rows makes the score on those rows useless
Hamilton node-mutates-input A node writes to one of its parameters, and Hamilton hands the same object to other nodes
Python dict-str-any dict[str, Any] in a signature hides the keys the function uses

xpd rules lists every rule, and the rules page shows each one with code before and after.

Install

uv tool install xpd

uvx xpd check . runs it once without an install.

Commands

xpd
├── check [paths]          lint files and folders, and rewrite with --fix
├── rules                  list every rule with its documentation
├── graph <files>          print the dataflow of step code or Hamilton modules
├── profile <data file>    print dtypes, nulls, unique counts and memory per column
├── equiv old.py new.py    run two scripts and compare the `result` each one leaves
├── hook                   lint the file that a Claude Code edit touched
├── mcp                    start the MCP server
└── skill                  print the agent skill for this version

check, rules and graph read the files and start no Python. profile and equiv run the project's Python and need pandas there. xpd <command> -h lists the flags of a command. The commands page explains the output and the exit codes.

Use with a coding agent

An agent can use xpd as a plugin, or through a hook, an MCP server and skills that you set up one at a time.

Way What the agent gets Setup
Plugin The hook, the MCP server and the skills together Load this repository in a client that supports Agent Plugins
Hook The issues of each file, right after the edit xpd hook in the Claude Code settings
MCP server Typed tools, the rules, the skills and prompts xpd mcp
Skills When to run each command, and Python style that a linter cannot check npx skills add bjoernaagaard/xpd

Plugin

This repository is a plugin in the Agent Plugins format, version 1.1.0. A client that supports the format loads the folder and gets everything below. The plugin starts xpd with uvx, so the machine needs uv.

xpd, loaded as a plugin
├── plugin.json    the name and version of the plugin
├── skills/        xpd, python-best-practices and python-review
├── mcp.json       starts the MCP server of this version with uvx
└── hooks.json     runs the hook of this version with uvx after each tool call

Hook

After each edit to a .py file, Claude Code sends the edit to xpd hook. When xpd finds issues, Claude Code shows them to the agent in the same turn.

Claude Code edits features.py
└── the PostToolUse hook runs xpd hook
    ├── no issues: exit code 0
    └── issues: exit code 2
        └── Claude Code shows the issues to the agent

Add the hook to .claude/settings.json in your project.

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [{ "type": "command", "command": "xpd hook" }]
      }
    ]
  }
}

MCP server

xpd mcp starts an MCP server, so an agent calls xpd through typed tools and needs no shell. The server comes with xpd, and the command below adds it to Claude Code.

claude mcp add xpd -- uvx xpd mcp
xpd mcp
├── tools
│   ├── check, fix                 lint, and write fixes after the user confirms unsafe ones
│   ├── graph, profile, equiv      the commands of the same names
│   ├── rules, rule                list the rules, and read one with its examples
│   └── show_issues, show_dataflow, show_columns    tables and a chart, in hosts that draw them
├── resources
│   ├── xpd://rules/{package}/{rule}    one rule's documentation
│   └── skill://<name>/SKILL.md         each skill that ships with xpd
└── prompts
    └── lint_and_fix, review, refactor_data_logic, add_to_dataflow

The server takes every rule and every result from the xpd binary, so it matches the installed version. The MCP page covers other clients, the settings and HTTP.

Skills

The repository includes Agent Skills in skills/. The Python skills work without xpd. They also run xpd when it is installed.

Skill What it does
xpd Says when to run each xpd command. xpd skill prints it for the installed version.
python-best-practices Holds the rules an agent follows when it writes or changes Python.
python-review Reviews a file, package or diff, and cites the rule for every finding.
npx skills add bjoernaagaard/xpd

Documentation

The full guide is at https://bjoernaagaard.github.io/xpd/. It also explains how to write a rule.

License

You may use xpd under the MIT license or the Apache-2.0 license.

Metadata

Release files for xpd 0.14.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 xpd 0.14.0
File Size Uploaded Provenance Actions
xpd-0.14.0.tar.gz 355.6 kB Without provenance Details for xpd-0.14.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for xpd 0.14.0
File Actions
xpd-0.14.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for xpd-0.14.0-py3-none-win_amd64.whl
xpd-0.14.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for xpd-0.14.0-py3-none-musllinux_1_2_x86_64.whl
xpd-0.14.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for xpd-0.14.0-py3-none-musllinux_1_2_aarch64.whl
xpd-0.14.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for xpd-0.14.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
xpd-0.14.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for xpd-0.14.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
xpd-0.14.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for xpd-0.14.0-py3-none-macosx_11_0_arm64.whl
xpd-0.14.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for xpd-0.14.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 18.7 MB

Release files / xpd-0.14.0.tar.gz

Download URL xpd-0.14.0.tar.gz
Size 355.6 kB
Tags Source
SHA-256 checksum
How to use checksums
489f44695ad1c9b0f81e4b44367b558cf034e428f3e18f9c73014bf7f0c9c65d
BLAKE2b-256 checksum
How to use checksums
c757ae0b787014e1998f8ef10d7c0ecd0052a1f92cea5f7ec5aea5e41f0198c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-win_amd64.whl

Download URL xpd-0.14.0-py3-none-win_amd64.whl
Size 2.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
6350ab53d35d3559152c6c7bd4488a5794f4bc838a292dd7ad1dc7e519565c98
BLAKE2b-256 checksum
How to use checksums
c69a4bdad91b4143cf7212ea5e0698876dae4aae9fc41c3c226cf2eb5eb238e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-musllinux_1_2_x86_64.whl

Download URL xpd-0.14.0-py3-none-musllinux_1_2_x86_64.whl
Size 2.8 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0026ba960eb3b7ed7c8499d1925014d2a60cba9dfe85aba2864ad6a3b8191818
BLAKE2b-256 checksum
How to use checksums
a230aa51d6a0d2cd028bbe88183b62492fe3e730e4b7861d472bbc371df85bdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-musllinux_1_2_aarch64.whl

Download URL xpd-0.14.0-py3-none-musllinux_1_2_aarch64.whl
Size 2.5 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
21a9d547ba71d5917fec54e3412ba0fd0ee094bc62a8f76a6e61652802847555
BLAKE2b-256 checksum
How to use checksums
9b735c7e358b563ed23dfce50b4049d2836952e442d7ace96c1c0a5c63215655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL xpd-0.14.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
fa2a3f37041192d6758f17fb6a2d99b67cacf9f761b182e5f36cca1590a2d66a
BLAKE2b-256 checksum
How to use checksums
f65003b0c95a99f7ce61567c842d23dd0ed12a53158fb54c6f1433770e4e827b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL xpd-0.14.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.5 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b578e957116dfe8f8dde8953b13dce8d2d30b5667afe560b7d4ceaca1a885e92
BLAKE2b-256 checksum
How to use checksums
197bfd9035d59e741008bd5e5e08174477bb7858b73db09de69bf635093a418f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-macosx_11_0_arm64.whl

Download URL xpd-0.14.0-py3-none-macosx_11_0_arm64.whl
Size 2.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9d74b2244e10e88ed9d4bdfd2b65123e6e97bdeacf4bbc615cc8fe47da885913
BLAKE2b-256 checksum
How to use checksums
be2d62950689ffe0047ec5afefc58619e8120042b260ce03bb07f3585b617795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / xpd-0.14.0-py3-none-macosx_10_12_x86_64.whl

Download URL xpd-0.14.0-py3-none-macosx_10_12_x86_64.whl
Size 2.6 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
8394637368f304fe6a4b8016e031923980019876fdd4d2cbfb9c9c7baf912af8
BLAKE2b-256 checksum
How to use checksums
2c08d77b53344d181420ff2a9c079b898e12e9fe03fde2fb4489c8c4d53de31f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for xpd 0.14.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.

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.

Release history Release notifications | RSS feed

This release

0.14.0 This release

8 release files No provenance

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