Your CI review agent, now through Context Mode

CI8 min read

Thanks to the Anthropic team for claude-code-action, and to GitHub for Actions. Together they let Claude review every pull request. Today that review can run through Context Mode with two Context Mode commands, after one sign-in. One writes the workflow. One makes a CI key and stores it as a GitHub secret, with no browser and no key on screen. The CI turns get savings on large tool output. They do not get your personal memory, your writing style or the status line, and they stay apart from your own sessions.

TL;DR

How to add an AI PR review to GitHub Actions

This post answers one question: how do you add an AI PR review to GitHub Actions through Context Mode? Five steps, all in your terminal, inside the repository. Pick a step to see the exact command and what it prints.

Step
$ npx @context-mode/cli login
Opened your browser. Finish signing in there.
  <sign-in link>
Waiting…
Signed in as <you>.
# …
# in a terminal, it then shows the agent picker for the apps on this machine

Do this once. It uses your Claude Code or Codex login to sign in, and stores a device key for this terminal. The CI key in step 3 is made with this device key, so no browser opens there.

$ cd your-repo
$ npx @context-mode/cli ci init
Wrote .github/workflows/context-mode-review.yml: Claude reviews each pull request through Context Mode.
Add one secret to owner/name: CONTEXT_MODE_KEY.
  npx @context-mode/cli ci key create --repo owner/name --gh
  (--gh stores it with the GitHub CLI and never shows it. Without --gh the key is printed once;
  add it at https://github.com/owner/name/settings/secrets/actions)
The workflow also uses ANTHROPIC_API_KEY, your Anthropic key, as claude-code-action does today.
Then commit and push the file.

The file holds no key. --dry-run prints it and writes nothing.

$ npx @context-mode/cli ci key create --repo owner/name --gh
Created CI key "CI owner/name" for owner/name. Expires <date>.
Stored as the secret CONTEXT_MODE_KEY in owner/name with the GitHub CLI. It was not shown.
Revoke it any time on https://console.contextmode.ai under Profile > Devices.

--gh pipes the key into gh secret set. Without it, the key prints once and is never written to disk.

$ gh secret set ANTHROPIC_API_KEY --repo owner/name
# paste your Anthropic API key when asked
# or: Settings > Secrets and variables > Actions

The action's own secret, set the GitHub way, with the same gh secret set form the CLI prints. Context Mode never writes it.

$ git add .github/workflows/context-mode-review.yml && git commit -m "Claude PR review" && git push
# open a pull request: the review comment follows

The next PR you open, push to or mark ready gets one review comment.

1. The native parts stay native

Nothing here replaces GitHub's or Anthropic's way. The review is anthropics/claude-code-action@v1, as its makers ship it. It reads your Anthropic key from the ANTHROPIC_API_KEY secret, as it does today. The CI key goes in with the GitHub CLI, gh, signed in to your account. Context Mode adds a few lines to one workflow file, and one secret.

2. Write the workflow

npx @context-mode/cli ci init                                   # writes .github/workflows/context-mode-review.yml

It writes at the repository root, wherever you run it. If a different file is already at that path, it keeps yours and stops (exit 3). --force replaces it. Run it again with nothing to change, and it writes nothing.

3. Make the CI key without a browser

npx @context-mode/cli ci key create --repo owner/name --gh      # makes a CI key and stores it as the CONTEXT_MODE_KEY secret

The gateway returns the key once and stores only its hash. A CI key cannot make other keys. Revoke it on the Console under Profile > Devices.

4. Commit, push, open a PR

git add .github/workflows/context-mode-review.yml && git commit -m "Claude PR review" && git push

What ci init writes

The Context Mode lines sit in one marked block, in the job's env. Here are those lines as ci init writes them, with the comments cut:

    env:
      # --- Context Mode: start ---------------------------------------------
      ANTHROPIC_BASE_URL: https://gateway.contextmode.ai
      ANTHROPIC_CUSTOM_HEADERS: |
        x-cm-device-key: ${{ secrets.CONTEXT_MODE_KEY }}
        x-context-mode-banner: off
        x-cm-ci-repo: ${{ github.repository }}
        x-cm-ci-ref: pr-${{ github.event.pull_request.number }}
        x-cm-ci-run: ${{ github.run_id }}
      ENABLE_TOOL_SEARCH: "true"
      # --- Context Mode: end -----------------------------------------------

The rest is a plain review job:

The prompt is yours to change. It is plain YAML in your repo.

What it saves, measured

We ran Claude Code headless in GitHub Actions on real tasks from popular repositories, direct to Anthropic and through Context Mode. Same agent, same prompt, same model. The table counts warm runs, as a repo reruns a job every few minutes.

CI jobContext ModeDirectLower95% rangeSaved per 1,000 runs
CI-failure fix$0.0281$0.044233.9%25.1 to 43.6%$16
Issue triage and labels$0.0183$0.026229.6%21.1 to 38.8%$8
Release notes$0.0987$0.133325.7%7.2 to 42.7%$35
@claude fix (issue to PR)$0.0736$0.090223.7%11.4 to 35.7%$17

Method, 95% ranges and the rows we left out: Benchmarks. Run the same jobs in your own repo, with your own key: use the lab template.

Why a CI run costs less

The gateway does not change the model's answer or its thinking. That is why the saving differs per job.

Does claude-code-action work with a gateway?

Yes. The action runs Claude Code, and Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_CUSTOM_HEADERS from the environment. Context Mode uses only those two, plus ENABLE_TOOL_SEARCH, which turns tool search back on for a non-Anthropic base URL. There is no fork of the action and no wrapper. The gateway strips every x-cm-* header before it forwards the request, so CONTEXT_MODE_KEY never reaches Anthropic. Your ANTHROPIC_API_KEY goes on to Anthropic as it is.

What a CI turn gets, and what it does not

A review bot is not you. Its answer goes into a PR that your whole team reads. So the gateway treats a CI turn in a different way from your own sessions. Pick a feature to see what happens in CI.

Feature
$ git diff origin/main
# a long diff, a big log, a large file
# the model gets the part it needs
# the rest stays out of its context

Yes. CI turns get savings on large tool output. This post gives no number for CI yet.

Your rules, decisions, style, chat memory:
not sent to a CI turn
Scope of a CI turn:
project  github:owner/name
ref      pr-<number>

The CI key is yours, but the review does not speak as you. No personal memory goes in, and a CI turn writes no personal fact back.

Your imported skills:
off in CI
The review follows the prompt in the workflow file.

Skills stay for your own sessions. The CI job does what its YAML says, the same on every run.

// Console: Settings → Instructions
Keep answers short. No wall of text.
# CI turn: not added

Your standing instructions shape your own sessions, not the team's PR comments. Put review rules in the workflow prompt.

$ git push origin main
# Claude Code, Codex on your machine: blocked by your rule

In CI, the workflow itself keeps the agent to a short tool list.

Example review comment on a PR:
src/quota.ts:42  missing null check on plan. Fix: return early when plan is undefined.
# no "⏺ contextmode" line in the comment

Headless runs get no status line, and the workflow also sends x-context-mode-banner: off. The PR comment holds only the review.

FeatureIn a CI turn
SavingYes, on large tool output
Memory (yours)No. A scope per repo and PR instead
Recall and Search of your archiveNo. The tools that read your memory are not offered
SkillsNo
Instructions and writing styleNo
"⏺ contextmode" lineNo, by design

Memory in CI: the repo's scope, not yours

A CI key is a device key like any other. Without care, a CI answer would carry the key holder's own rules and style into a team PR. So the workflow tells the gateway which repo, PR and run sent each request (x-cm-ci-repo, x-cm-ci-ref, x-cm-ci-run). The gateway then:

Your own sessions in Claude Code, Codex and the other apps keep their Memory as before.

Tips

How to undo it

Delete .github/workflows/context-mode-review.yml and push. Then revoke the CI key on the console under Profile > Devices, and remove the CONTEXT_MODE_KEY secret from the repo. A CI key also ends by itself when it expires (90 days unless you set --expires).

Start now

Sign in once, then two commands in your repo. Open the Console to see your workspace and your CI keys.

npx @context-mode/cli login
npx @context-mode/cli ci init
npx @context-mode/cli ci key create --repo owner/name --gh

On your own machine, each app with its makers' own install: Claude Desktop, the ChatGPT desktop app, Pi, OpenCode and T3 Code, or all of them in one command. Context Mode is under the Elastic License 2.0 (ELv2).

Get started free

Your coding agent costs less and remembers your project.

Start free: 1,000 requests, every feature, no card. After you sign in, the console gives you one command to connect your coding agent.

Read the docs