website/src/content/docs/index.md
title: Get started description: Install xpd, lint a pandas file, run a unified repository audit, and explore guides for ledgers, libraries, editors, and coding agents.
Run uvx xpd check . in any Python project to find slow or broken library calls without importing or running your code, or run uvx xpd audit . for a read-only summary across linter rules, static review workflows, --since regression deltas, and recorded ledger debt.
| 1 | flowchart LR |
| 2 | A["xpd check . or xpd audit ."] --> B["Parse source files statically"] |
| 3 | B --> C["Detect imported libraries and structure"] |
| 4 | C --> D["Run matching packs and static workflows"] |
| 5 | D --> E["Report issues, deltas, and optional fixes"] |
Install
xpd requires Python 3.13 or newer. Install it once with uv, or replace xpd with uvx xpd in any command to run without installing.
| 1 | uv tool install --python '>=3.13' xpd |
Check a sample file
Save bad.py in an empty folder. You do not need pandas installed because xpd never executes your script.
| 1 | import pandas as pd |
| 2 | |
| 3 | df = pd.DataFrame({"a": [1, 2], "k": [1, 2]}) |
| 4 | other = df.copy() |
| 5 | for i, row in df.iterrows(): |
| 6 | df["a"][i] = row["a"] * 2 |
| 7 | df.dropna(inplace=True) |
| 8 | m = pd.merge(df, other, on="k") |
| 9 | out = pd.DataFrame() |
| 10 | for f in ["x.csv"]: |
| 11 | out = pd.concat([out, pd.read_csv(f)]) |
Run xpd check bad.py. Terminal runs print text, and piped runs print JSON (pass --format text in scripts when you want text).
| 1 | $ xpd check bad.py --format text |
| 2 | bad.py:5:15: warning [pandas/row-loop] iterrows() builds a Series for every row. Compute on whole columns instead, such as df["a"] * df["w"]. When each row has to become a Python object, loop over itertuples() or to_dict("records"). |
| 3 | 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. |
| 4 | bad.py:7:1: info [pandas/no-inplace] inplace=True gives no speedup and blocks chaining. Reassign instead. |
| 5 | bad.py:8:5: warning [pandas/merge-without-validate] This merge can silently duplicate rows. Prove the key unique first, or pass validate=. |
| 6 | bad.py:11:5: warning [pandas/concat-in-loop] out grows by one concat per pass, and each concat copies every earlier row. Collect the frames in a list and concat once after the loop. |
| 7 | xpd: 5 issues, 2 more with --fix --unsafe-fixes |
Read diagnostics and apply fixes
Each diagnostic line names the location, severity, rule identifier, and replacement guidance.
| Severity | Meaning | Exit code |
|---|---|---|
error | Code produces a wrong result or raises an exception | 1 |
warning | Code is slow or fragile | 0 |
info | A shorter or cleaner idiom exists | 0 |
Safe fixes (--fix) preserve runtime behavior. Unsafe fixes (--fix --unsafe-fixes) can change behavior, so review the diff after applying them.
| 1 | $ xpd check bad.py --fix --unsafe-fixes --format text |
| 2 | ... |
| 3 | xpd: fixed 2, 3 issues |
| 1 | for i, row in df.iterrows(): |
| 2 | - df["a"][i] = row["a"] * 2 |
| 3 | -df.dropna(inplace=True) |
| 4 | + df.loc[i, "a"] = row["a"] * 2 |
| 5 | +df = df.dropna() |
Line 6 now mutates df in place under pandas copy-on-write, and line 7 returns a new DataFrame instead of mutating shared references. No errors remain, so xpd check exits with 0.
Where to go next
| Area | Start with |
|---|---|
| Unified repository health and CI gating | Audit a repository |
| Claude Code, Codex, MCP, and editors | Claude Code and other agents, MCP, and Editors |
| Code quality ledgers | Untangle, Optimize, Harden, and Discover |
| Data, ML, and visualization ledgers | Data prep, Time series, Features, Models, Optimization, and Charts |
| Custom rules | Write a rule |
| Complete reference | Rules, Commands, and MCP server |