Skip to main content

Beginner-friendly codebase doctor: lint, format, type-check, security and tests.

Project description

CodeDoctor

CodeDoctor is a beginner-friendly Python CLI that runs common quality checks (linting, formatting, type checking, security scanning, and tests) against any Python repository or folder you point it at, and produces a readable report.

It’s designed to be simple to run, easy to understand, and safe by default.


Requirements

  • Python 3.12+
  • (Recommended) git available on PATH for best .gitignore support

Install

From PyPI:

python -m pip install codedoctor

Verify:

codedoctor --help
codedoctor scan --help

Setup (required)

Before running scans, initialize CodeDoctor once:

codedoctor setup

This creates a small config file in your user profile (JSON) that stores default behavior (e.g., whether to respect .gitignore, default report directory, etc.).

CI / no-config environments

If you’re running in CI or you don’t want CodeDoctor to create a config file, you can bypass the setup requirement with:

codedoctor scan . --assume-defaults

Quick Start

Scan the current folder:

codedoctor scan .

Scan a different path:

codedoctor scan /path/to/repo

On Windows:

codedoctor scan C:\path\to\repo

Apply safe auto-fixes + formatting:

codedoctor scan . --fix

Skip tests:

codedoctor scan . --skip-tests

Commands

codedoctor scan

codedoctor scan [PATH] [--fix] [--skip-tests] [--report-dir DIR] [--no-gitignore] \
  [--no-update-check] [--assume-defaults]

Options

  • PATH
    Repository/folder to scan (default: .)

  • --fix
    Apply safe auto-fixes (Ruff --fix) and format with Black.

  • --skip-tests
    Skip running pytest.

  • --report-dir DIR
    Directory (relative to the repo) to store reports. If omitted, uses the value from your CodeDoctor config.

  • --no-gitignore
    Disable best-effort .gitignore handling (useful for debugging).

  • --no-update-check
    Disable the non-blocking “update available” notice during scans.

  • --assume-defaults
    Allow scanning without running codedoctor setup (useful for CI).


codedoctor setup

codedoctor setup [--force]

Creates or updates the user config file.

  • --force overwrites an existing config file.

codedoctor update

codedoctor update [--yes]

Checks PyPI for the latest version and offers to upgrade CodeDoctor.

  • --yes updates without prompting.

Note: if CodeDoctor was installed into a locked or managed Python environment, codedoctor update may fail due to permissions. In that case, update using your environment’s normal package management approach (venv, pipx, etc.).


What gets run during a scan

CodeDoctor invokes the following tools (when installed/available):

  • ruff check . (and optionally ruff check . --fix)
  • black . --check (and optionally black .)
  • mypy .
  • bandit -r .
  • pytest -q (unless --skip-tests)

CodeDoctor runs tools in the target repo by setting cwd to the repo path.


Reports

Reports are written under the repository (default .codedoctor/):

  • report-latest.txt — newest scan
  • report-prev.txt — previous scan (rotated)
  • report-YYYYMMDD-HHMMSS.txt — timestamped snapshot

.gitignore behavior (best effort)

Different tools treat ignore rules differently:

  • Ruff and Black already respect .gitignore in typical setups.
  • MyPy and Bandit do not consistently honor .gitignore the same way.

To provide consistent behavior, CodeDoctor will attempt to use git’s ignore information when scanning a git repository by running:

git ls-files -ci --exclude-standard

Those ignored paths are then excluded from MyPy/Bandit runs.

If any of the following are true:

  • the target folder is not a git repo
  • git is not installed
  • the git command fails

…CodeDoctor falls back to excluding common junk directories like .venv, .git, caches, build/, and dist/.


Exit Codes

CodeDoctor returns an exit code that matches the overall result:

  • 0 — all checks passed
  • 1 — warnings (non-fatal issues)
  • 2 — failures (one or more checks failed)

Missing tools are treated as failures for that check (return code 127) so the report remains explicit and beginner-friendly.


Development

Clone and install editable:

git clone https://github.com/BigPattyOG/CodeDoctor.git
cd CodeDoctor
python -m pip install -e .

Run setup:

codedoctor setup

Run a scan:

codedoctor scan .

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codedoctor-0.2.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codedoctor-0.2.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file codedoctor-0.2.0.tar.gz.

File metadata

  • Download URL: codedoctor-0.2.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codedoctor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5503dc1a52a363f058e9b1f996107c955ba0f2fd0e50ccafa056145724930cc3
MD5 6961d4d3a4982a7c8ee913a2a5e6922f
BLAKE2b-256 c18c34c793767db2a4240f722e0ece7cecb15dc4b32a59bf742309ad518948e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for codedoctor-0.2.0.tar.gz:

Publisher: release.yml on BigPattyOG/CodeDoctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codedoctor-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: codedoctor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codedoctor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1784dfe815eb29808b83bc5fdc575b18d6d2c13bc33184f324bd6c877436aa67
MD5 d1bbf6cae0c6f46fc51dbd9bf153a9b4
BLAKE2b-256 904b88450eec96d9483bcbc8acfb8bc43363dcc02dfc2b1a05160f9599ab8cad

See more details on using hashes here.

Provenance

The following attestation bundles were made for codedoctor-0.2.0-py3-none-any.whl:

Publisher: release.yml on BigPattyOG/CodeDoctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page