Skip to content

xpd doctor

Run xpd doctor at a Python project root to diff pyproject.toml, tool configs, and lock files against xpd's strict Ruff, ty, pytest, packaging, and pre-commit profile. Add --apply to write the changes and lock files, or --check to exit 1 on drift in CI and the agent Stop hook.

Read pyproject.toml,configs, and locksCompare againstprofile.toml anddecisions.jsonlDefault: print unified diff,reasons, and conditionaladvice--apply: write files, run uvlock, record[tool.xpd.profile]--check: exit 0 if aligned, 1on drift, 2 on conflict
Terminal window
xpd doctor [OPTIONS]
Option Default What it does
--format <FORMAT> Output format. Default: text on a terminal, json otherwise. Values: text, json.
--check Exit 1 when the project drifts from the profile, including a missing or stale lock. Conflicts with --apply.
--apply Write the plan to pyproject.toml, refresh the lock files, and record the profile.
--kind <KIND> The kind of project: library, application, pipeline or script. The first apply needs it, and pyproject.toml records it.
--tools <TOOLS> Hold only the settings of these tools, with their pins and their lock: ruff, ty and pytest, such as --tools ruff,ty,pytest. pyproject.toml records them, and a project without them holds the whole profile. Repeatable.

Every setting in the profile has a pinned release, rationale, and upstream source in src/doctor/profile.toml and src/doctor/decisions.jsonl.

Area What the profile enforces
Ruff select = ["E4", "E7", "E9", "F", "I"], required-version = "==0.17.6"
ty error on blanket ignores, unused ignores, disjoint casts, and missing direct dependencies
pytest strict = true, -ra --import-mode=importlib -p no:doctest, filterwarnings = ["error"], no reruns
Packaging and locks requires-python, pinned dev tools in [dependency-groups], exclude-newer, and up-to-date uv.lock
Git hooks Creates a missing .pre-commit-config.yaml with pinned TOML and YAML checks through uvx. Existing hook configurations remain project-owned

Pass --tools ruff,ty,pytest to manage only tool settings without packaging or hooks, or pass --kind to select a project layout (library, application, pipeline, or script).

Doctor prints only the tables and files it owns, replacing unrelated lines in pyproject.toml (such as [tool.uv.index] or [tool.uv.sources]) with <hidden> in diffs. Credentials, queries, and fragments in URLs are replaced with **** across text, JSON, and hook output.

pyproject.toml
[project]
name = "example"
version = "0.1.0"
description = "An example project."
readme = "README.md"
requires-python = ">=3.12"
[project.urls]
Repository = "https://example.com/example"
[dependency-groups]
dev = [
"pytest>=9.2.0",
"pytest-rerunfailures",
"pytest-timeout",
]
[tool.pytest.ini_options]
addopts = "--reruns 2 --strict-markers"
Terminal window
$ xpd doctor --format text
Profile revision 9, kind application, suggested because [project] has no [build-system], so uv runs it without building it
A program that runs from its checkout or as an installed command, locked in uv.lock.
pyproject.toml records no profile yet.
...
--- pyproject.toml
+++ pyproject.toml
...
+[tool.ruff.lint]
+select = ["E4", "E7", "E9", "F", "I"]
...
+[tool.xpd.profile]
+revision = 9
+kind = "application"
...
Changes
ruff lint.select: unset -> ["E4", "E7", "E9", "F", "I"], tool.ruff.lint.select
...
Locks
uv.lock is missing. --apply runs uv lock.
...
xpd doctor --apply --kind application writes these changes.
...

Add an entry under [tool.xpd.profile.exceptions] in pyproject.toml with a reason when a project intentionally differs from a profile setting. Doctor keeps valid exceptions and reports stale ones.

[[tool.xpd.profile.exceptions]]
tool = "ruff"
id = "F401"
reason = "Importing the plugin registers it."

Run xpd doctor --format json for machine-readable output containing profile (revision, applied, kind, tools, changes, conflicts, exceptions, unverified, locks, diff), tools, suggestions, policies, and notes.

Exit code Meaning
0 Report printed, --check matched the profile, or --apply succeeded
1 --check found drift, an out-of-date lock, a conflict, or an invalid exception
2 Unreadable project, unsupported layout (such as a uv workspace or duplicate pytest tables), missing Ruff 0.17.6 check, or blocked --apply