# CLI
URL: https://docs.clearly-ai.com/docs/cli
Description: Use the Clearly AI command line client to create projects, upload sources, start reviews, and fetch results.
The Clearly AI CLI is the `clearly` command for the Clearly AI HTTP API. Use it when you want to script common review setup without clicking through the web app.

## What you need [#what-you-need]

* A Clearly AI tenant URL, usually `https://{tenant}.clearly-app.com`.
* A personal API key from **Settings > Manage > Personal API Keys**.
* The Clearly AI CLI package provided by your Clearly AI contact.

## Configure the CLI [#configure-the-cli]

Run the interactive setup:

```bash
clearly configure
```

Enter:

* **Base URL**: your tenant URL, for example `https://acme.clearly-app.com`
* **API Key**: your personal API key

The CLI stores profiles in `~/.clearly/config`.

Use named profiles when you work across tenants:

```bash
clearly configure --profile staging
clearly configure list
clearly configure show --profile staging
```

## Run a review [#run-a-review]

Create a project:

```bash
clearly projects create "Production API Security Review" \
  --description "Scope: public API, backend workers, and deployment config."
```

Upload a file or directory of sources:

```bash
clearly sources upload PROJECT_ID ./sources
```

List review templates:

```bash
clearly questionnaires list
```

Start a review:

```bash
clearly reviews create PROJECT_ID threat-model-v0.yaml
```

Fetch review status and results:

```bash
clearly reviews get REVIEW_ID
```

Poll until the review status is generated. The response is JSON and includes review metadata and answer blocks.

## Project commands [#project-commands]

```bash
clearly projects list
clearly projects get PROJECT_ID
clearly projects create "Project name" --description "Short scope"
clearly projects update PROJECT_ID --name "New name"
clearly projects update PROJECT_ID --description "Updated scope"
clearly projects delete PROJECT_ID
```

Deletion prompts for confirmation. Use `--yes` only in scripts where you already have a separate confirmation step.

## Source commands [#source-commands]

```bash
clearly sources upload PROJECT_ID ./architecture.pdf
clearly sources upload PROJECT_ID ./source-directory
```

When you pass a directory, the CLI uploads all files under that directory.

## Review commands [#review-commands]

```bash
clearly reviews create PROJECT_ID review-template-file.yaml
clearly reviews get REVIEW_ID
```

Use the review template filename returned by `clearly questionnaires list`.

## Example project [#example-project]

If your account has access to the Clearly AI example repositories and the required review templates are installed in your tenant, you can list and run bundled examples:

```bash
clearly example --list
clearly example maestro
```

The bundled `maestro` example creates a project, downloads example sources from GitHub, uploads them, and starts the configured reviews.

## FAQs [#faqs]

<Accordions>
  <Accordion title="What should I do if an API key is required?">
    Run `clearly configure` and confirm the profile has an API key.
  </Accordion>

  <Accordion title="What should I do if a base URL is required?">
    Run `clearly configure` and enter the full tenant URL.
  </Accordion>

  <Accordion title="What should I do if the review template is not found?">
    Run `clearly questionnaires list` and use the exact `filename` value.
  </Accordion>

  <Accordion title="Why does the example fail before review creation?">
    Confirm the required review templates are installed and your GitHub account can access the example source repository.
  </Accordion>
</Accordions>