# Swift Analyzer CLI quick start

The local CLI contract is advisory-only for the exact `apple-swift-6.3.3-macos-arm64` validated profile. Reading this guide requires no account. A public binary download is not provided in the current release documentation.

## 1. Prepare one exact snapshot

Build the selected SwiftPM executable or library product outside Swift Analyzer. Preserve the compiler-produced Index Store and create one validated manifest for the exact repository revision, product, target closure, build variant, and toolchain. The analyzer does not orchestrate the build.

## 2. Four commands, one evidence chain

`doctor` validates manifest structure, toolchain/build identity, compiler data, worlds, and capability quality. `stats` publishes admitted fact and symbol statistics without treating incomplete evidence as a closed world.

`scan` builds the advisory reachability view and publishes human or canonical JSON results. `why` explains one exact declaration or SCC identity from the same immutable manifest.

## 3. Run the shortest useful sequence

```sh
swift-analyzer doctor --manifest snapshot.json --format human
swift-analyzer scan --manifest snapshot.json --format json
```

Validate first and read the report before scanning. Preserve the JSON report and process exit code together.

## 4. Preserve every outcome

Exit 0 means the command completed and every requested capability was satisfied. Exit 3 means the command completed with incomplete capability; Exit 3 is not a clean scan.

Exit 1 is an explicitly requested findings-gate failure. Exit 2 is invalid grammar, an invalid option, or an invalid input document. Exit 4 means acquisition or toolchain input could not be used. Exit 5 is an internal invariant failure. Exit 130 is cancellation before committed publication.

## 5. Explain an exact result

```sh
swift-analyzer why --manifest snapshot.json \
  --scope repository \
  --subject '<copy-the-exact-identifier>' \
  --dimension code --format human
```

Take the subject identity from scan JSON and use the same manifest. Name, USR, and source-location selectors are not public substitutes for the exact canonical identity.

## 6. Keep uncertainty explicit

No known reference is not proof that code is unused. A mismatched toolchain, incomplete source/index/world evidence, or an unmodeled dynamic boundary keeps the affected conclusion `unknown`. Correct the snapshot or extend the evidence before relying on a negative result. The current contract does not authorize automatic deletion, autofix, or a default blocking findings gate.

## Current availability

This is documentation for a local advisory preview, not a download page. A hosted service and team workflows are planned but unavailable. The landing has no signup, billing, or source upload.

Source revision: `aaccde765dee97b46d111bd5f6493e17f55d086e`

Catalog revision: `4558458d`

Language: en
Canonical: https://docs.swift-analyzer.com/en/cli/
Source revision: 4558458d
