# greptile

AI code review in your terminal. Get the same review Greptile runs on your team's pull requests, right inside your editor's shell, before you push.

## Install

Pick whichever is easiest for you.

```sh
# macOS, via Homebrew
brew install greptileai/tap/greptile

# Any platform with Node 22 or newer
npm install -g greptile

# Direct install for macOS (also needs Node 22+)
curl -fsSL https://raw.githubusercontent.com/greptileai/cli/main/install.sh | bash
```

## Quick start

```sh
greptile login              # opens your browser to sign in
cd path/to/your/repo
greptile review             # review HEAD against the default branch
```

That's it. Comments appear in the terminal as they come in.

## Examples

**Review against a specific base branch:**

```sh
greptile review -b main
```

**Show findings next to the actual code lines:**

```sh
greptile review --diff
```

**Pipe to another tool or save the raw results:**

```sh
greptile review --json > review.json
```

**Re-open a previous review (pick from a list, or pass an ID):**

```sh
greptile review show
greptile review show abc123
```

**Keep going on a review that stopped halfway:**

```sh
greptile review --resume
```

## More than one Greptile organization?

If you belong to several, tell greptile which one to use:

```sh
greptile whoami                 # lists your organizations
export GREPTILE_TENANT=acme-corp
greptile review
```

## Diagrams

When a review's summary includes a Mermaid diagram, greptile renders it inline in kitty and Ghostty, and links the SVG file in other terminals. The first time a diagram needs to render, greptile downloads a small renderer ([mmdr](https://github.com/1jehuang/mermaid-rs-renderer)) into `~/.cache/greptile/`. To opt out, set `GREPTILE_NO_AUTO_INSTALL=1`.

## Reference

Full command surface:

```sh
greptile login | logout | whoami
greptile review [-b BRANCH] [--diff] [--resume] [--json | --text | --agent]
                [--context LINES] [--width COLUMNS] [--no-color]
greptile review show [ID]   # same review flags apply
```

Environment variables:

| Variable                   | What it does                                                               |
| -------------------------- | -------------------------------------------------------------------------- |
| `GREPTILE_TENANT`          | Which organization to use when you belong to more than one.                |
| `GREPTILE_INLINE_IMAGES`   | Force inline kitty diagrams on (`1`, `true`, `kitty`) or off (`0`, `off`). |
| `GREPTILE_NO_AUTO_INSTALL` | Skip the one-time mmdr download.                                           |
| `NO_COLOR`                 | Turn off ANSI color.                                                       |
| `FORCE_COLOR`              | Turn on ANSI color even when stdout is not a TTY.                          |
| `COLUMNS`                  | Override the output width.                                                 |

Exit codes (useful for scripting):

| Code  | Meaning                                                                           |
| ----- | --------------------------------------------------------------------------------- |
| `0`   | Review finished.                                                                  |
| `1`   | Review couldn't finish (sign-in expired, server error, repo not connected, etc.). |
| `2`   | Wrong invocation (not inside a git repo, invalid flag, etc.).                     |
| `130` | You hit Ctrl-C.                                                                   |

Credentials live at `~/.greptile/auth.json` and refresh themselves automatically.
