CLI: CI Integration

Use the Keito CLI in GitHub Actions, GitLab CI, or any CI environment to track agent work that happens in automated pipelines.

GitHub Actions

name: Agent Code Review
on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    env:
      KEITO_API_KEY: ${{ secrets.KEITO_API_KEY }}
      KEITO_ACCOUNT_ID: ${{ secrets.KEITO_ACCOUNT_ID }}
    steps:
      - uses: actions/checkout@v4

      - name: Install Keito CLI
        run: npm install -g @keito/cli

      - name: Start tracking
        run: keito time start --project ${{ vars.PROJECT_SLUG }} --task code-review --source agent --agent-id "gh-actions-reviewer"

      - name: Run AI code review
        run: ./scripts/ai-review.sh

      - name: Stop tracking and log cost
        if: always()
        run: |
          keito time stop --notes "AI code review for PR #${{ github.event.number }}"
          keito expense log --project ${{ vars.PROJECT_SLUG }} --quantity $TOKEN_COUNT \
            --notes "Code review tokens for PR #${{ github.event.number }}"

GitLab CI

ai-review:
  stage: review
  variables:
    KEITO_API_KEY: $KEITO_API_KEY
    KEITO_ACCOUNT_ID: $KEITO_ACCOUNT_ID
  before_script:
    - npm install -g @keito/cli
    - keito time start --project myproject --task code-review --source agent
  script:
    - ./scripts/ai-review.sh
  after_script:
    - keito time stop --notes "AI review for $CI_COMMIT_SHORT_SHA"
    - keito expense log --project myproject --quantity $TOKEN_COUNT

Environment Variables Reference

VariableRequiredDescription
KEITO_API_KEYYesAPI key for authentication
KEITO_ACCOUNT_IDYesYour workspace ID

Tips

  • Use if: always() (GitHub Actions) or after_script (GitLab) to ensure tracking stops even if the agent step fails.
  • Store KEITO_API_KEY in your CI secrets — never commit it to source control.
  • Use a dedicated agent user for CI pipelines so the work is clearly attributed.
  • Consider logging the PR number or commit SHA in the notes for traceability.