# `npx @sanity/cli blueprints doctor`

Runs five checks: Host online, Authenticated, Manifest valid, Stack ready, User has access. Run this before changing files when another Blueprint command fails for an unclear reason.

## Diagnose

Run from the project directory:

```sh
npx @sanity/cli blueprints doctor
```

Use `--path PATH` when the Blueprint manifest is outside the current directory or cannot be discovered automatically. `SANITY_BLUEPRINT_PATH` provides the same path through the environment.

Read the reported diagnostics and warnings before proposing changes. Do not assume every warning requires a fix.

## Read the exit code, not just the JSON

The command exits non-zero unless every check passes; a check that cannot be determined also fails the run. `--json` suppresses the report: a clean run prints `{"diagnostics": {"online": true, "tokenValid": true, ...}}` with `true`, `false`, or `null` per check, and a failing run prints an error object with no diagnostics. Rerun without `--json` to see which checks failed and why.

## Fix

`--fix` prompts for scope and Stack, then writes `.sanity/blueprint.config.json`:

```sh
npx @sanity/cli blueprints doctor --fix
```

`--fix` cannot be combined with `--path`, including a path supplied through `SANITY_BLUEPRINT_PATH`. It also requires authentication and a readable Blueprint manifest; without either it reports what is missing and changes nothing.

Use `--fix` only when interactive input is available and the user has authorized configuration changes. Otherwise, apply a specific, reviewed fix and rerun the read-only diagnostic command.
