Using Optibot CLI with CI/CD Pipelines

The Optibot CLI was created for both use in typical development environments for engineers and for use within CI/CD pipelines and fully autonomous agent environments like Claude Code, Codex, and others.

Install

npm install -g @optimalai/optibot

Getting API Keys (For Agents & CI/CD)

Best for non-interactive/virtual environments such as agentic coders and CI/CD pipelines:

  1. First, authenticate via the CLI:

    optibot login
  2. Create an API key:

    optibot apikey create ci-github-actions

    The output includes the key (starts with optk_). Copy it immediately — it is only shown once.

  3. Set the key as an environment variable:

    export OPTIBOT_API_KEY=optk_your_key_here

You can also list and delete your keys directly from the CLI:

# List all API keys
optibot apikey list

# Delete a key by ID
optibot apikey delete KEY_ID

Environment Variables

VariableDescription
OPTIBOT_API_KEYYour API token (for automation/CI/CD)
OPTIBOT_API_URLBackend URL (defaults to https://agents.getoptimal.ai)

Usage

# Review local uncommitted changes
optibot review

# Review against the auto-detected base branch (origin/main, origin/master, or origin/develop)
optibot review -b

# Review changes against a specific branch
optibot review --branch origin/main

# Review an arbitrary diff file
optibot review --diff changes.patch

CI/CD Integration

Setup

  1. Generate an API key (see above).
  2. Add it as a repository secret (e.g., OPTIBOT_API_KEY in GitHub → Settings → Secrets).

GitHub Actions

name: Code Review
on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Install Optibot CLI
        run: npm install -g @optimalai/optibot
      - name: Run code review
        env:
          OPTIBOT_API_KEY: ${{ secrets.OPTIBOT_API_KEY }}
        run: optibot review --branch origin/${{ github.base_ref }}

GitLab CI

code-review:
  image: node:18
  script:
    - npm install -g @optimalai/optibot
    - optibot review --branch origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
  variables:
    OPTIBOT_API_KEY: $OPTIBOT_API_KEY
  only:
    - merge_requests

Review Output

After each review, the CLI displays:

  • Review Summary — general comments about the changes
  • File Comments — per-file feedback with line numbers
  • Rate limit info — reviews used, remaining quota, and time until reset (color-coded: dim → yellow → red as quota depletes)