CI and changed files
Add a check:doctor script to the project:
{
"scripts": {
"check:doctor": "vite-doctor . --max-warnings 0"
}
}
Don't name the script doctor. pnpm doctor and npm doctor run the package manager's own health check, so an agent that runs the obvious command sees a passing check without running Doctor. If the project already has a doctor script, call it with pnpm run doctor or npm run doctor.
Doctor reads source files, config, and installed packages, not build output, so run it before the build as a cheap early check. Nuxt projects that register vite-doctor/nuxt also need .nuxt/doctor.manifest.json, which nuxt prepare writes. Most Nuxt projects already run it from a postinstall or prepare script. See Nuxt in CI.
This GitHub Actions workflow installs dependencies, then runs the script:
name: Checks
on:
pull_request:
push:
branches: [main]
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
- run: corepack enable
- run: pnpm install --frozen-lockfile
- run: pnpm check:doctor
In CI, Doctor prints the complete text report: every Diagnostic in detail, with no Report Budget. Pass --max-chars to keep the log short, or --format sarif for code scanning. An agent running in CI still gets the agent report.
Doctor reads your code and never connects to a running server. To check an MCP server in the same job, run npx is-mcp-ok <url> once it listens; see the is-mcp-ok reference.
GitHub annotations
In GitHub Actions, Doctor also writes workflow commands to stderr. Errors and blockers become ::error annotations and warnings become ::warning annotations on the pull request diff. Each annotation has the Diagnostic Code as its title, the file relative to GITHUB_WORKSPACE with the line and column, and a link to the code's docs.
Info Diagnostics and Diagnostics without a source file get no annotation. GitHub shows 10 annotations of each kind per step, so Doctor prints the first 10 of each in report order. The report on stdout, its summary, and the exit code don't change, so a report redirected to a file holds no workflow commands. --format json, --format sarif, and the agent report print no annotations.
Changed files
pnpm dlx vite-doctor . --changed
pnpm dlx vite-doctor . --since origin/main
--changed covers staged, unstaged, and untracked files against HEAD. --since <ref> uses the merge base with that ref. A Git failure stops the run instead of returning a false clean result.
The report equals a full run filtered to Diagnostics with a primary or related location on a changed line, including lines in package.json and pnpm-lock.yaml:
- A project-scoped Rule's Diagnostic also qualifies through a changed manifest or lockfile entry it cites as evidence. A new required peer can bring
PKG0007into a dependent package's report, and a lockfile resolution that adds a second copy of a singleton can bringPKG0008. A package-local run can use this evidence from its workspace without reporting findings for sibling packages. - Ordinary file Rules stay limited to their own changed lines.
- A Diagnostic without a source range qualifies when the file it is anchored to changed. Manifest Rules anchor project-level findings to the first source file, as in a full run.
- Parser evidence gaps are reported for changed files only.
- The report has no workspace graph summary unless you pass
--analyses dead-codeorgraph.
File Rules that report only into the file they analyze, the default report scope, run on the changed files only. Rules with a project report scope, manifest and workspace Rules, and --analyses keep whole-project context, and Doctor parses unchanged files only for them. With the analysis cache, those project-wide results are recomputed only where a recorded Rule input changed.
Baselines
Record the current Diagnostic fingerprints, then report only findings absent from that baseline:
pnpm vite-doctor . --baseline doctor-baseline.json --update-baseline
pnpm vite-doctor . --baseline doctor-baseline.json --new-only
--update-baseline needs an explicit --baseline path and creates missing parent directories. It replaces the recorded set with the findings of the current run, so resolved findings drop out of the next baseline. It still reports findings and uses the usual exit codes. Combined with --new-only, it also keeps the fingerprints that are currently suppressed. Regenerate the baseline with a full run: --changed, --since, and --rules limit the recorded findings to that scope.
--new-only accepts:
- an array of fingerprint strings, or of objects with a
fingerprintfield; - an object with a
diagnosticsarray andversion: 2(or the older, optionalversion: 1); - a Doctor JSON report with
reportVersion: 4or3. In JSON reports,versionis the Doctor package version, not the baseline format.
Baselines and JSON reports record the fingerprintScheme their fingerprints use, and --update-baseline also records the Doctor version as doctorVersion. When --new-only reads a non-empty baseline from another scheme, or one with no scheme, Doctor applies the fingerprints that still match and reports DOC0032, which asks you to regenerate the baseline. An unreadable or malformed baseline stops the run with DOC0025 and exit code 2. A missing baseline counts as empty, so a first run can create it.
A full --new-only run reports resolved baseline entries as one info-level DOC0039 Diagnostic. Delete only the fingerprints listed in its evidence. Doctor needs the recorded Rule and file, which baselines from --update-baseline and saved JSON reports include, and checks that the file Rule covered the file or that the file is gone. It skips entries from workspace analyses and from Rules that run or report across files. Runs with --changed, --since, --rules, --analyses, --update-baseline, or a severity threshold above info never report DOC0039.