> ## 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.

# Codex Plugin

> Install and use the Greptile plugin for Codex

Use Greptile in Codex to inspect pull requests, run local reviews, and fix review feedback.

<Note>
  **Prerequisites:** Install Codex and `git`. Create a [Greptile account](https://app.greptile.com/signup) and connect your repositories. Install `gh` for GitHub or `glab` for GitLab.
</Note>

## Installation

<Steps>
  <Step title="Set your Greptile API key">
    Create a key in [Settings > Organization > API Keys](https://app.greptile.com/settings/organization/api). Export it in the shell that starts Codex:

    ```bash theme={}
    export GREPTILE_API_KEY="your-api-key"
    ```

    Add the export to your shell profile if you want it available in new terminals. Do not commit the key.
  </Step>

  <Step title="Add the Greptile marketplace">
    ```bash theme={}
    codex plugin marketplace add greptileai/greptile-codex-plugin
    ```
  </Step>

  <Step title="Install the Greptile plugin">
    ```bash theme={}
    codex plugin add greptile@greptile-codex-plugins
    ```

    The plugin configures Greptile MCP and installs the `$check-pr`, `$cli-review`, and `$greploop`
    skills. Start a new Codex task after installation.
  </Step>

  <Step title="Authenticate your code-host CLI">
    Sign in to your code-host CLI:

    ```bash theme={}
    gh auth login
    ```

    Use `glab auth login` for GitLab.
  </Step>

  <Step title="Verify the installation">
    Check the marketplace, plugin, and MCP server:

    ```bash theme={}
    codex plugin marketplace list
    codex plugin list
    codex mcp list
    ```

    The output should include the `greptile-codex-plugins` marketplace, the enabled `greptile`
    plugin, and the `greptile` MCP server with `GREPTILE_API_KEY` as its bearer token environment
    variable.

    Open a repository in a new Codex task. Test the skill and MCP connections:

    ```text theme={}
    Use $check-pr to inspect the pull request for this branch. Do not change files or resolve threads.
    ```

    ```text theme={}
    Use Greptile MCP to list my open pull requests.
    ```
  </Step>
</Steps>

## What You Can Do

Once installed, ask Codex to work with Greptile reviews and local changes.

### Check a Pull Request

```text theme={}
Use $check-pr on PR 42. Fix only actionable issues, then summarize the changes.
```

`$check-pr` checks a GitHub PR or GitLab MR for unresolved comments, failed checks, and an incomplete description. It can fix issues and resolve threads when asked.

### Review a Local Branch

<Note>
  `$cli-review` requires the [Greptile CLI](/docs/code-review/greptile-cli). Install it, then run
  `greptile whoami` to verify that `GREPTILE_API_KEY` is available.
</Note>

```text theme={}
Use $cli-review on this branch. List the highest-severity findings first.
```

`$cli-review` runs a Greptile CLI review against the current local branch and summarizes the findings.

### Run the Full Review Loop

```text theme={}
Use $greploop on this PR. Stop when the review is clean or after five iterations.
```

`$greploop` fixes feedback, triggers another review, and repeats until Greptile reaches 5/5 confidence with no unresolved comments. It stops after five iterations.

<Note>
  `$check-pr` and `$greploop` can change code, commit, push, and resolve review threads. Run them from the branch you want to update.
</Note>

## Example Prompts

```text theme={}
Use $check-pr on PR 42. Fix only actionable issues, then summarize the changes.
```

```text theme={}
Use $cli-review on this branch. List the highest-severity findings first.
```

```text theme={}
Use $greploop on this PR. Stop when the review is clean or after five iterations.
```

```text theme={}
Use Greptile MCP to list my open pull requests and summarize any blocking comments.
```

## Available Tools

The plugin gives Codex access to Greptile's [MCP server](/docs/mcp-v2/overview) and three public skills:

| Tool          | Use it for                                                                                      |
| ------------- | ----------------------------------------------------------------------------------------------- |
| Greptile MCP  | Read review data, comments, custom context, and reports. See all [MCP tools](/docs/mcp-v2/tools).    |
| `$check-pr`   | Inspect hosted reviews, checks, and PR descriptions. Fix issues and resolve threads when asked. |
| `$cli-review` | Review the current local branch with the Greptile CLI.                                          |
| `$greploop`   | Fix feedback and repeat reviews until the PR is clean or the five-iteration limit is reached.   |

## Troubleshooting

<AccordionGroup>
  <Accordion title="A skill is not found">
    Start a new Codex task after installation. If the skill is still missing, reinstall the plugin:

    ```bash theme={}
    codex plugin add greptile@greptile-codex-plugins
    ```
  </Accordion>

  <Accordion title="The MCP server cannot authenticate">
    Check that the key is available in the shell that launched Codex:

    ```bash theme={}
    test -n "$GREPTILE_API_KEY" && echo "GREPTILE_API_KEY is set"
    ```

    Create a new API key if the current key was revoked.
  </Accordion>

  <Accordion title="The MCP server is disconnected">
    Run `codex plugin list` and `codex mcp list`. Confirm the plugin is enabled, the MCP URL is `https://api.greptile.com/mcp`, and the bearer token environment variable is `GREPTILE_API_KEY`. Then restart Codex.
  </Accordion>

  <Accordion title="A hosted review workflow cannot read the PR">
    Confirm your code-host CLI is installed and signed in. Run `gh auth status` for GitHub or `glab auth status` for GitLab.
  </Accordion>

  <Accordion title="A local review cannot start">
    Run `greptile whoami` and `greptile --version`. The review must run from a Git repository with committed changes.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="MCP setup" icon="plug" href="/docs/mcp-v2/setup">
    Configure Greptile MCP in other coding tools.
  </Card>

  <Card title="Agent skills" icon="robot" href="/docs/mcp-v2/skills">
    Learn how the review skills work.
  </Card>

  <Card title="Greptile CLI" icon="terminal" href="/docs/code-review/greptile-cli">
    Install the CLI and run local reviews.
  </Card>

  <Card title="Skills source" icon="github" href="https://github.com/greptileai/skills">
    Review the public skill source.
  </Card>

  <Card title="Codex plugin source" icon="github" href="https://github.com/greptileai/greptile-codex-plugin">
    Review the marketplace package and installation instructions.
  </Card>
</CardGroup>
