Skip to main content

Developer recipe

Fail CI when AI visibility drops

Read the last seven days of monitored answers, require enough evidence, and stop a build when your brand mention rate falls past its allowed floor.

The Foglift CLI returns one period-wide visibility_rate, the completed result count, and separate engine totals. The workflow below reads that existing history, so each pull request does not trigger a paid model run.

GitHub Actions workflow
# .github/workflows/ai-visibility-gate.yml
name: AI visibility gate

on:
  pull_request:

permissions:
  contents: read

jobs:
  ai-visibility:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 22

      - name: Fail when AI visibility drops
        env:
          FOGLIFT_API_KEY: ${{ secrets.FOGLIFT_API_KEY }}
          AI_VISIBILITY_BASELINE: "20"
          MAX_DROP_POINTS: "5"
          MINIMUM_RESULTS: "5"
        run: |
          set -euo pipefail
          npx --yes foglift-scan@1.0.3 scan results --days 7 --json > foglift-results.json

          current="$(jq -er '.summary.visibility_rate' foglift-results.json)"
          total="$(jq -er '.summary.total_results' foglift-results.json)"
          minimum="$((AI_VISIBILITY_BASELINE - MAX_DROP_POINTS))"
          if (( minimum < 0 )); then minimum=0; fi

          if (( total < MINIMUM_RESULTS )); then
            echo "Only ${total} completed results; need ${MINIMUM_RESULTS} before judging a drop."
            exit 2
          fi

          echo "Current visibility: ${current}%"
          echo "Required floor: ${minimum}%"
          if (( current < minimum )); then
            echo "AI visibility fell past the allowed ${MAX_DROP_POINTS}-point drop."
            exit 1
          fi

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: foglift-ai-visibility-results
          path: foglift-results.json

What the gate measures

One rate, a sample floor, and an explicit failure

foglift scan results reads completed monitoring history. It does not infer that a pull request caused a movement. The gate simply prevents a release while the latest measured period is below the floor your team accepted.

summary.visibility_rate

Current mention rate

The percentage of completed prompt-engine results in the seven-day window that mention the tracked brand.

summary.total_results

Evidence floor

The workflow exits with code 2 when the sample is too small, keeping missing evidence distinct from a measured decline.

exit 1

Visibility regression

The job fails when the current integer rate falls below baseline minus the allowed percentage-point drop.

Before the workflow

Confirm the baseline locally

  1. 1. Create a Launch or higher API key. Store it as the masked FOGLIFT_API_KEY repository secret. Never commit the key.
  2. 2. Run the exact results command locally. Confirm the workspace, period, result count, total visibility rate, and engine split before choosing a floor.
  3. 3. Freeze an observed baseline. Use a stable multi-run window, not the highest single day. Set the allowed drop in percentage points, not percent change.
  4. 4. Make the job a required check. A non-zero exit then blocks the merge until the visibility evidence recovers or the team intentionally accepts a new baseline.
Inspect the source data
export FOGLIFT_API_KEY=sk_fog_your_api_key
foglift scan results --days 7 --json   | jq '{rate: .summary.visibility_rate, sample: .summary.total_results, engines: .by_model}'

Access and limits

The history read uses developer access, not model tokens

Developer access and all-five-engine monitoring begin on Launch. The results read counts against API request allowances, while the scheduled monitoring checks that create the history use the workspace's model-token balance.

Plans and API request allowances for the AI visibility CI recipe
PlanPriceRequests per dayRequests per month
Launch$49/mo501,000
Growth$129/mo2005,000
EnterpriseCustomCustomCustom

One scan results call is one API request. It reads history and does not debit a model token. Starting a new AI Visibility check is a separate operation.

CI recipe FAQ

Questions before making the gate required

Does this workflow run new AI queries on every pull request?

No. The results command reads monitoring history from the selected seven-day window. It does not start a new AI Visibility check, so the gate does not spend model tokens on every pull request.

What does visibility_rate measure?

It is the percentage of completed prompt-engine results in the selected period where the tracked brand was mentioned. The response also returns total_results, brand_mentions, and separate aggregates by engine.

Why does the recipe require a minimum sample?

A rate based on one or two results can move sharply because of a single answer. MINIMUM_RESULTS makes missing or sparse evidence fail visibly instead of turning it into a false visibility regression.

Which plan supports this CI gate?

Developer access starts on Launch at $49 per month. Launch includes five-engine monitoring, 50 API requests per day, and 1,000 per month. Growth raises those limits to 200 per day and 5,000 per month.

Will the API key be available to pull requests from forks?

GitHub does not pass repository secrets to untrusted fork workflows. Keep the workflow on pull_request, let forked runs report the missing-secret failure, and use branch policy or a trusted follow-up run when needed. Do not switch to pull_request_target just to expose the key to untrusted code.

Tracked prompt

Alerts when my AI search visibility drops, including in CI

This recipe turns monitored answer history into a deterministic build result. Use the AI Visibility API when your application needs the same evidence as structured JSON.