Skip to content

CLI Reference

bash
astro-doctor [command] [options]

Commands

(no command) — scan

Scans the target directory for Astro issues and prints a health report.

bash
# Scan current directory
astro-doctor

# Scan a specific directory
astro-doctor --dir ./src

# Scan and write a JSON report
astro-doctor --json report.json

# Emit SARIF for code-scanning tools
astro-doctor --format sarif > astro-doctor.sarif

# Apply safe automatic fixes
astro-doctor --fix

# Cache repeated scans by file content
astro-doctor --cache

# Save and apply a persistent baseline
astro-doctor baseline create
astro-doctor --baseline .astro-doctor-baseline.json

# Report only diagnostics introduced since main
astro-doctor --scope changed --base main

# Scan without showing the health score
astro-doctor --no-score

install

Copies the agent skill files (.agents/skills/) into your project root. Run once per project.

bash
astro-doctor install

baseline create|update

Saves the current findings to .astro-doctor-baseline.json. Subsequent scans with--baseline report only findings that are not already recorded, making gradual adoption practical in existing projects.

bash
astro-doctor baseline create
astro-doctor baseline update --output ./config/astro-baseline.json

experimental-lsp

Starts the experimental language server in stdio mode (for editor integration without ESLint). This feature is a work in progress.

bash
astro-doctor experimental-lsp --stdio

Options

FlagDefaultDescription
-d, --dir <path>process.cwd()Directory to scan
--scope <scope>fullChoose full, changed files, or introduced diagnostics with changed
--base <ref>auto-detectedBase revision for files or changed scope
--json [path]offOutput JSON to stdout (no path) or to a file
--fixoffApply safe automatic fixes provided by rules
--preset <name>recommendedrecommended | strict | ci | all
--cacheoffCache ESLint results by file content at .astro-doctor/cache; add it to .gitignore
--baseline <path>offSuppress findings recorded in a persistent baseline
--format <format>consoleChoose console, github, or sarif
--no-scoreshow scoreOmit the health score from output
--fail-on <level>errorExit 1 on: error | warning | off
--changed-files-from <path>offScan only files listed in a file (one path per line) — used by the GitHub Action for PR diff mode
-h, --helpShow help message

JSON report schema

When using --json, the output conforms to this schema:

json
{
  "$schema": "https://doctor.santi020k.com/schema/report.json",
  "schemaVersion": 1,
  "version": "1.x.x",
  "scoreModel": 2,
  "timestamp": "2024-01-01T00:00:00.000Z",
  "directory": "/my-project",
  "scope": "full",
  "fileCount": 14,
  "errorCount": 1,
  "warningCount": 2,
  "score": 85,
  "scoreLabel": "B",
  "scoreBreakdown": {
    "performance": 90,
    "accessibility": 75,
    "security": 100,
    "best-practices": 90
  },
  "diagnostics": [
    {
      "ruleId": "astro-doctor/no-missing-alt",
      "severity": "error",
      "message": "img element is missing a non-empty alt attribute",
      "filePath": "/my-project/src/pages/blog.astro",
      "line": 12,
      "column": 5,
      "category": "accessibility"
    }
  ]
}

Exit codes

CodeMeaning
0Scan completed, no issues at or above the fail-on threshold
1Issues found at or above the fail-on threshold

Examples

bash
# CI: fail on any warning
astro-doctor --fail-on warning

# CI: never fail, just report
astro-doctor --fail-on off

# Output JSON for downstream tools
astro-doctor --json | jq '.score'

# Write JSON to a file and show console output
astro-doctor --json ./astro-report.json