> ## Documentation Index
> Fetch the complete documentation index at: https://www.greptile.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# TREX

> TREX is an end-to-end testing agent.

On each pull request, TREX:

1. Figures out which user flows your changes affect.
2. Starts your app in a sandbox built from your [environment](/docs/trex/environments).
3. Uses the app like a user would: clicking, typing, and observing what's on the screen.
4. Posts what it tested and what broke, with a [video of every flow](/docs/trex/results).

## Getting started

**1. Turn on TREX for your organization**

Open **Settings → Agent Config → TREX →** [**Settings**](https://app.greptile.com/-/settings/trex) and **Enable TREX**.

**2. Set up an environment**

Tell TREX how to set up and build all the dependencies that allow it to run your services. See [Environments](/docs/trex/environments).

**3. Open a pull request**

TREX runs with the next review and posts a [**TREX** comment](/docs/trex/results).

You should configure an environment before using TREX.

## Pricing

A TREX run will cost **3 credits**. This is distinct from the cost of the [code review](/docs/code-review/review-tiers). Check out [Billing](/docs/code-review-bot/billing-seats) for more information. Runs that do not have complete user flows tested will not be charged.

## When TREX runs

Once **Enable TREX** is on, choose **When TREX runs**:

| Mode | TREX runs on |
| - | - |
| **Always** | Every reviewed pull request. |
| **Sometimes** | Pull requests that match at least one of your **Rules**. |

A rule is a set of conditions such as branch, labels, authors, or file paths. All conditions in a rule must match. Rules inherited from a parent namespace show read-only under yours.

**Automatic TREX runs** sets which pull request events start TREX, the same way it works for reviews.

TREX also decides on its own when a pull request has nothing to test. For example, a change with no effect on how the app behaves. It skips testing, says why in its check, and doesn't charge credits.

### Run TREX on demand

You can also comment on a pull request to run TREX on it, even when **Sometimes** rules don't match:

```
@greptileai trex
```

### Opt out of your own pull requests

To opt out, open your account menu (top right) → **Review → TREX Settings → TREX on my PRs** and pick **Off**. **Default** follows the organization setting. Off also ignores on-demand requests on your pull requests.

### Auto-approve

If you want TREX results to be included in Greptile's auto-approval decision, turn on **TREX auto-approve**. You can do so in **Settings → Agent Config → TREX →** [**Settings**](https://app.greptile.com/-/settings/trex), below **When TREX runs**.

### Live progress

With **Live progress** on (the default), the TREX comment shows progress while TREX runs, then updates to the results when it finishes. Turn it off on the same settings page to post only the results.

## Next

> **[Environments](/docs/trex/environments)**
>
> Build and start your app.

> **[Custom flows](/docs/trex/custom-flows)**
>
> Pin the journeys TREX tests.

> **[Results](/docs/trex/results)**
>
> Read the comment and watch the video.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.