> ## Documentation Index
> Fetch the complete documentation index at: https://tashfiq.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# doctor

> Scan a repository, evaluate Charter's rules, and compute an AI-agent-readiness score.

`charter doctor` is the primary Charter command. It resolves the target repository, loads the effective score threshold from `charter.yaml` or the `--threshold` flag, evaluates the full rule set, renders the result, and exits with a code that is safe to use in local workflows, pre-commit hooks, and CI pipelines.

## Usage

<CodeGroup>
  ```bash Standard scan theme={null}
  charter doctor
  ```

  ```bash With explicit path and threshold theme={null}
  charter doctor --path /path/to/repo --threshold 90
  ```

  ```bash SARIF output for CI theme={null}
  charter doctor --format sarif --out charter.sarif
  ```

  ```bash Quiet mode for pre-commit hook theme={null}
  charter doctor --quiet --threshold 80
  ```

  ```bash Single-rule targeted scan theme={null}
  charter doctor --rule AE-SEC-001
  ```
</CodeGroup>

<Frame caption="charter doctor — styled terminal output with category scorecard and findings">
  <img src="https://mintcdn.com/tashfiq/JQQfhNhXhSPPRZxR/images/screenshots/doctor-tty.webp?fit=max&auto=format&n=JQQfhNhXhSPPRZxR&q=85&s=c788ee534316472f04e4e9c697524bfc" alt="charter doctor TTY output" width="1728" height="1242" data-path="images/screenshots/doctor-tty.webp" />
</Frame>

## Flags

<ResponseField name="--path" type="string">
  Explicit repository root to scan. Defaults to the current working directory.
</ResponseField>

<ResponseField name="--threshold" type="int">
  Minimum passing score. Overrides the threshold or profile value in `charter.yaml` when provided.
</ResponseField>

<ResponseField name="--format" type="text | json | markdown | sarif">
  Output format. Defaults to `text`. In a TTY, `text` renders styled terminal output; when piped or redirected, it falls back to a plain byte-stable stream.
</ResponseField>

<ResponseField name="--out" type="string">
  Write the rendered output to a file instead of stdout.
</ResponseField>

<ResponseField name="--rule" type="string">
  Comma-separated rule IDs for a scoped text-only view. Omits the overall score and exits `1` if any named rule fired. Incompatible with `--interactive`.
</ResponseField>

<ResponseField name="--quiet" type="boolean">
  Suppress non-failure output. Useful in hooks and CI. Applies to text output only — JSON, Markdown, and SARIF still emit the full payload.
</ResponseField>

<ResponseField name="--color" type="auto | always | never">
  Color output mode for text rendering. Defaults to `auto`.
</ResponseField>

<ResponseField name="--no-color" type="boolean">
  Disable color. Equivalent to `--color=never` and wins over `--color` when both are set.
</ResponseField>

<ResponseField name="-i, --interactive" type="boolean">
  Open the interactive TUI. Requires a real terminal.
</ResponseField>

## Output Formats

<Tabs>
  <Tab title="Text (default)">
    Styled terminal output with a category scorecard, per-finding evidence rows, and a score hero at the bottom. In a TTY, Charter renders color and box-drawing characters. When stdout is piped or redirected, it falls back to a plain, byte-stable stream safe for log capture.

    ```bash theme={null}
    charter doctor
    charter doctor --format text --out scan.txt
    ```
  </Tab>

  <Tab title="JSON">
    Machine-readable payload for scripts and tooling. The top-level shape includes:

    ```json theme={null}
    {
      "score": 87,
      "passed": true,
      "threshold": 80,
      "findings": [
        {
          "rule_id": "AE-ENV-001",
          "severity": "Medium",
          "category": "Environment",
          "summary": "No .env.example found",
          "evidence": "No .env.example detected in the repository root.",
          "locations": ["/.env.example"],
          "remediation": "Create a .env.example listing required environment variable names."
        }
      ]
    }
    ```

    ```bash theme={null}
    charter doctor --format json
    charter doctor --format json --out result.json
    ```
  </Tab>

  <Tab title="Markdown">
    Formatted for GitHub PR comments. Paste directly into a PR description or post it via a CI step.

    ```bash theme={null}
    charter doctor --format markdown
    charter doctor --format markdown --out charter-summary.md
    ```
  </Tab>

  <Tab title="SARIF">
    SARIF 2.1.0 format for GitHub Code Scanning. Upload the output file as a Code Scanning artifact to surface findings inline in pull requests.

    ```bash theme={null}
    charter doctor --format sarif --out charter.sarif
    ```

    In a GitHub Actions workflow:

    ```yaml theme={null}
    - name: Upload SARIF
      uses: github/codeql-action/upload-sarif@v3
      with:
        sarif_file: charter.sarif
    ```
  </Tab>
</Tabs>

## Interactive TUI

`charter doctor -i` opens a full-screen terminal UI over a single scan result. It is a browser over the findings, not a different scan engine.

<Frame caption="charter doctor -i — interactive TUI with filter, search, and drill-in">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/tashfiq/images/screenshots/doctor-tui.webp" alt="charter doctor interactive TUI" />
</Frame>

The TUI supports filter and search, drill-in on individual findings, rule-focused browsing, and in-place rescan. It is intentionally human-only — you cannot combine it with `--out`, `--quiet`, non-text `--format`, or `--rule`.

<Note>
  `-i` requires a real TTY. It exits with code `2` if stdin is not a terminal.
</Note>

## Exit codes

| Code | Meaning | When                                                                                                                         |
| ---- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `0`  | Pass    | Score ≥ threshold, or `--rule` view found no matching findings                                                               |
| `1`  | Fail    | Score \< threshold, or `--rule` view found at least one matching finding                                                     |
| `2`  | Error   | Invalid `--format`, unknown rule ID in `--rule`, `--interactive` on a non-TTY, malformed `charter.yaml`, or unreadable files |

## Related

<CardGroup cols={2}>
  <Card title="GitHub Action" icon="brand-github" href="/docs/ci/github-action">
    Gate pull requests on the Charter score in CI.
  </Card>

  <Card title="Scoring and caps" icon="calculator" href="/docs/concepts/scoring-and-caps">
    How the 0–100 score and severity caps are computed.
  </Card>

  <Card title="fix" icon="tool" href="/cli/fix">
    Apply diff-first auto-repair for supported findings.
  </Card>
</CardGroup>
