# Commands

> Reference for the abstr CLI commands.

## Ask a question

Running `abstr` with a question asks Astrid directly:

```bash
abstr "how does auth work in this repo?"
```

You can also pipe input, or scope the question to a GitHub pull request:

```bash
echo "explain this module" | abstr
abstr --pr https://github.com/org/repo/pull/42 "summarize this diff"
```

| Flag                       | Description                                     |
| -------------------------- | ----------------------------------------------- |
| `-w`, `--workspace <slug>` | Workspace to query                              |
| `--pr <url>`               | Scope the question to a GitHub pull request URL |
| `--config <path>`          | Config file to use                              |

## Interactive session

Run `abstr` with no question in a terminal to open an interactive session:

```bash
abstr
```

Inside the session, use slash commands:

| Command             | Description                                                             |
| ------------------- | ----------------------------------------------------------------------- |
| `/pr [url]`         | Scope the conversation to a PR (or run `/pr` alone to pick from a list) |
| `/pr clear`         | Remove the PR scope                                                     |
| `/workspace [slug]` | Switch workspace                                                        |
| `/new`              | Start a fresh conversation                                              |
| `/help`             | Show available commands                                                 |
| `/exit`             | Quit the session                                                        |

## `abstr review`

Review the branch you're on before you open its pull request, or review a
pull request by URL. The command follows the review and lists its findings.

```bash
abstr review                                        # pre-review the current branch
abstr review --base develop                         # compare against another branch
abstr review https://github.com/org/repo/pull/42    # review a pull request
```

See [Pre-review](https://docs.abstraction.dev/code-review/pre-review.md) for every flag and what happens
when you open the pull request.

Each finding is listed with its id, such as `#4211`, the same number the app
and Astrid use. `--json` includes it as `commentId`.

### `abstr review resolve`

Rule on a finding from the terminal, as you would on the review page.

```bash
abstr review resolve 4211 --as fixed
abstr review resolve 4211 --as invalid --reason "the caller checks for nil"
abstr review resolve 4211 --as duplicate --duplicate-of 4200
abstr review resolve 4211 --as open                  # reopen it
```

| Flag                  | Description                                                        |
| --------------------- | ------------------------------------------------------------------ |
| `--as <verdict>`      | `fixed`, `invalid`, `wont_fix`, `duplicate` or `open`              |
| `--reason <text>`     | Why. Required for `invalid` and `wont_fix`                         |
| `--duplicate-of <id>` | The finding this one repeats. Only for `duplicate`                 |
| `--report <id>`       | The review the finding is in (default: the newest review of the current branch) |
| `-w`, `--workspace`   | Workspace to use                                                   |

The ruling is yours, exactly as a click in the app: on a pull request its
GitHub thread follows it. You need to be an editor or admin of the workspace.
The command prints the finding as the ruling left it and exits non-zero when
the ruling is refused.

## `abstr login`

Store your API key and pick a workspace. See [Installation](https://docs.abstraction.dev/cli/installation.md).

```bash
abstr login
```

## `abstr workspace`

Manage the active workspace (alias: `abstr ws`).

```bash
abstr workspace list        # list workspaces; current is marked with *
abstr workspace use my-team # switch to a workspace
abstr workspace             # interactive picker
```

## `abstr config`

Inspect your configuration.

```bash
abstr config show   # workspace, redacted API key, resolved API URL
abstr config path   # print the config file path
```
