Skip to main content

codedoctor🩺

PyPI version CI Python 3.12+ License: Apache-2.0 Discord

Pre-commit gates that run each heavy check once per commit, sized to the machine and below interactive priority.

Quickstart

cd /path/to/your/repo
uvx codedoctor install
uv add --group pre-commit rekursiv-ai-typings
uv run --group pre-commit pre-commit run --all-files

Repository setup

codedoctor install adds a locked pre-commit dependency group and installs the pre-commit Git hook. It creates missing configuration, rewrites each of its own hooks to this release's definition, arguments included, and preserves each hook's exclude, the project's other hooks, comments, and Python support range. Running it again does not duplicate hooks. Notebook tooling is opt-in: codedoctor install --notebooks adds the notebook extra and the nbstripout and jupytext-sync hooks. Default installs add neither. Existing hooks are preserved, including previously added notebook hooks.

The installer writes Ruff, ty, basedpyright, and pyrefly settings from the package's bundled policy into pyproject.toml. It also configures pytest, coverage floors, and mutation source selection. That policy comes from Loop's canonical configuration, with checkout-specific paths removed. Existing project settings remain overrides; installation reports their names.

Codedoctor is development tooling, not an application dependency. Applications can use their own user-directory helpers or inline XDG handling. The installer uses the project name for userdirs-namespace.namespace; set it explicitly in [tool.codedoctor.lint] to choose another namespace. xdg-literal.helper is unset unless the project requires a shared helper.

The hooks come from the package's install_hooks.yaml. Commits autofix whitespace, spelling, Codedoctor lint, Ruff formatting, Biome formatting of TypeScript, JavaScript and CSS, and rustfmt; check types with ty, pyrefly, and basedpyright; run clippy once per touched crate; and run paired tests, coverage checks, and sampled mutation tests. A project without biome.json gets the package's Biome settings; an existing one is left alone. Pre-push checks are opt-in: install them with pre-commit install --hook-type pre-push to run repository-wide type checks and all test tiers. Dependency-graph setup precedes affected-file checks.

Tests may use either test_*.py or *_test.py; existing discovery settings and coverage thresholds are preserved. Hooks that rewrite files abort that attempt; review and stage the changes, then retry.

rekursiv-ai-typings is optional, not a Codedoctor dependency. The Quickstart adds it explicitly to the development-tools group. This also works for projects supporting Python below 3.12; those targeting 3.12+ can use uv add --dev instead.

Alternatively, install Codedoctor in the project's environment first:

uv add --dev codedoctor
uv run codedoctor install

Codedoctor requires Python 3.12 or newer. For projects supporting older Python, use the uvx route: its tools live in a Python 3.12+ dependency group without raising the application's runtime floor. Git and uv must already be installed.

Policy updates

Policy changes reach projects through a new Codedoctor release. Upgrade the locked dependency, then reinstall:

uv lock --upgrade-package codedoctor
uv run --group pre-commit codedoctor install
uv run --group pre-commit codedoctor check

[tool.codedoctor.managed] records the last generated defaults. Reinstallation updates unchanged managed settings and adds new defaults. It preserves project overrides and deliberately deleted settings. Lists are replaced as whole values; a customized list remains an override. Do not edit the recorded baseline.

codedoctor check exits nonzero when the installed package would refresh the project configuration. It does not write files or install dependencies. Preserved overrides do not make configuration stale.

pre-commit calls a hook once per chunk of file names, so --all-files starts a type checker or pytest several times over. Each heavy gate here is two hooks: a -spool twin collects every chunk, then the gate runs once over all of them, at this machine's worker count.

Example

A .pre-commit-config.yaml pair for ty:

repos:
  - repo: local
    hooks:
      - id: ty-check-spool
        name: ty-check-spool
        alias: ty-check
        language: system
        require_serial: true
        types_or: [python, pyi]
        entry: uv run codedoctor gate spool ty-check
      - id: ty-check
        name: ty-check
        language: system
        require_serial: true
        pass_filenames: false
        types_or: [python, pyi]
        entry: uv run codedoctor typecheck ty-check

This repository's own .pre-commit-config.yaml wires every gate and is the fullest example.

Gates

Command Runs
codedoctor gate spool, run and threaded: the shared machinery
codedoctor typecheck ty-check, pyrefly-check, basedpyright
codedoctor testing paired tests and whole-suite tiers
codedoctor coverage-floor per-source coverage from the pytest gate
codedoctor mutation changed-function mutation tests (codedoctor[mutation])
codedoctor lint AST rules configured in [tool.codedoctor.lint]; --explain RULE says why a rule exists; --suppressions counts the house-ignore markers for each rule
codedoctor assert-isinstance redundant assert isinstance removal
codedoctor affected files and tests reached through CodeGraph
codedoctor nbstripout notebook output stripping
codedoctor yamlcheck YAML validation, including Compose tags
codedoctor cargo cargo fmt or cargo clippy once per touched crate
codedoctor export-leaks exported-package leak checks
codedoctor codegraph-sync dependency-graph refresh
codedoctor check-pr-text pull-request text validation

Worker counts: WORKERS_<HOOK_ID> wins, then WORKERS_DEFAULT, then a count derived from the machine's cores and free memory.

Install

uv add --dev codedoctor

If you're missing uv,

  • Mac
    brew install uv
    
  • Linux
    sudo apt install -y curl
    curl -LsSf https://astral.sh/uv/install.sh | sh
    

Or with pip,

python -m pip install codedoctor

Metadata

Release files for codedoctor 0.1.11

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

Source distribution (sdist)

Source distribution for codedoctor 0.1.11
File Size Uploaded Provenance Actions
codedoctor-0.1.11.tar.gz 761.8 kB With provenance Details for codedoctor-0.1.11.tar.gz

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / codedoctor-0.1.11.tar.gz

Download URL codedoctor-0.1.11.tar.gz
Size 761.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9ef8a543c7b6a50d18d27e9cdc2d562e7b708b03d65373a568d99f47e890cd23
BLAKE2b-256 checksum
How to use checksums
5d18aacffdc5b1c2fbf964d8915a711ab526cce92e648ba85d93ef2ff3487f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / codedoctor-0.1.11-py3-none-any.whl

Download URL codedoctor-0.1.11-py3-none-any.whl
Size 333.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e193705209e2b43c7f18e9840ab34eafc2ee4b72f975eef6394b75010eca053
BLAKE2b-256 checksum
How to use checksums
ab04c72fa8c3ff97a8c4e0b7191563d8c7d4792d4cc957221e0f61ba896601d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for codedoctor 0.1.11

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codedoctor-0.1.11.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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