Add a referral program with Gemini CLI

Google replaced Gemini CLI with Antigravity CLI (agy) for free and Google One users in June 2026. Both read GEMINI.md, but they name the URL field of an HTTP MCP server differently: httpUrl in Gemini CLI, serverUrl in Antigravity.

01Rules fileGEMINI.md

Give Gemini CLI the RefRef rules

The rules tell the agent where each part of a referral integration belongs: the landing script in the browser, one signup call where your backend creates the account, and the API key only on the server. Save it as GEMINI.md in the repository root, or add its text to your existing GEMINI.md.

Gemini CLI loads GEMINI.md from the project root, its parents, and the folders below, and joins them into the context of each session. Antigravity CLI reads GEMINI.md and AGENTS.md. Run /memory show in Gemini CLI to check that the RefRef rules are loaded.

GEMINI.md
# RefRef referral tracking

This app uses RefRef (https://refref.ai) for its referral program. Follow these rules when you add or change referral code.

## Configuration

- Server-only secrets: `REFREF_API_KEY` (a Workspace API key), `REFREF_PROJECT_ID`, and `REFREF_PROGRAM_ID`.
- `REFREF_API_URL` defaults to `https://api.refref.ai`, and `REFREF_ASSETS_URL` to `https://assets.refref.ai`. Read both from configuration, so that a Sandbox or local environment can change them.
- Never put `REFREF_API_KEY` in browser code, in a public variable (`NEXT_PUBLIC_*`, `VITE_*`), in a prompt, in a log, or in a commit.
- Every RefRef call is a backend `POST` with a JSON body that contains `projectId`, and the header `X-Api-Key`. The current schemas are at `GET $REFREF_API_URL/openapi`.

The start of the file. Open the whole file.

Or fetch it from the command line: curl -fsSL https://refref.ai/agents/gemini-cli/rules.md >> GEMINI.md (>> appends to an existing file)

02MCP serverConfiguration

Connect Gemini CLI to RefRef MCP

Optional. With the MCP server, Gemini CLI can read your Workspaces, Projects, and Programs, and prepare configuration changes for you to approve in the Console. It never sends signups: that is the app code from the rules. See the MCP reference for scopes and approvals.

Configuration: .gemini/settings.json for Gemini CLI; .agents/mcp_config.json for Antigravity CLI

.gemini/settings.json for Gemini CLI; .agents/mcp_config.json for Antigravity CLI
// Gemini CLI: .gemini/settings.json
{
  "mcpServers": {
    "refref": {
      "httpUrl": "https://mcp.refref.ai/mcp"
    }
  }
}

// Antigravity CLI: .agents/mcp_config.json
{
  "mcpServers": {
    "refref": {
      "serverUrl": "https://mcp.refref.ai/mcp"
    }
  }
}

Or with the CLI

Add command
gemini mcp add --transport http refref https://mcp.refref.ai/mcp
agy mcp add --type http refref https://mcp.refref.ai/mcp

Sign in

In Gemini CLI, run /mcp auth refref and sign in with your RefRef Console account. Antigravity starts the sign-in by itself when it first connects. The connection uses your Console sign-in, never a Workspace API key.

Check it

gemini mcp list, or agy mcp list

  • In Gemini CLI, "url" means an SSE server. Use "httpUrl" for the RefRef server.
  • Antigravity does not accept url or httpUrl. Use serverUrl.
03PromptsPaste in order

1. Configure the Program through MCP

Optional. Needs the refref MCP server and a Console account with the owner or admin role.

Configure the Program through MCP
Use the refref MCP server. Call get_workflow with workflow="configuration", then list_workspaces. Ask me to choose the Workspace, and use only the Sandbox Project that I confirm. Read its Programs and rules. Propose a referral Program that gives the referrer a reward when a referred person signs up. Ask me for the reward, the currency, and the limits; do not assume them. Return the proposal and its review link. Do not approve or apply it.

2. Add referral tracking to the signup

The rehearsal ran this prompt with "the project instructions" in place of the rules file name, on a Node app whose tests use node --test.

Add referral tracking to the signup
Add RefRef referral tracking to the signup of this app. Follow the RefRef rules in GEMINI.md. Configuration comes from environment variables. Do not add dependencies. Add focused tests and run them.

3. Review the change before you merge it

Run it in a new session, so that the agent reads the diff with fresh context.

Review the change before you merge it
Review the RefRef integration in the current diff against GEMINI.md. Check each item of "Tests to write" and "Do not". Confirm that the signup is sent once, only where the account is created, and that REFREF_API_KEY never reaches the browser. List each problem with its file and line. Change nothing.

Set REFREF_API_KEY, REFREF_PROJECT_ID, and REFREF_PROGRAM_ID in your backend environment. The integration reference has each call, and the auth recipes cover email verification, magic links, and hosted login.

04Rehearsal recordChecks open

What we ran, and what happened

Some checks have not run yet. Treat the open steps as a guide to verify yourself, and record your own results.

passed · 2026-10-20The Antigravity configuration is the one that agy writes
agy mcp add --type http refref https://mcp.refref.ai/mcp (Antigravity CLI 1.3.6, in a scratch home directory) wrote mcpServers.refref.serverUrl, as shown above, and agy mcp list showed it enabled.
pendingConfigure the MCP server and sign in with Gemini CLI or Antigravity
Not run: Gemini CLI is not installed on the rehearsal machine, and the Antigravity sign-in was not exercised.
pendingPrompt 2 and the rules file produce a working signup integration
Not run. Run prompt 2 with GEMINI.md on a test app, then follow A's link as B and check the referral, a repeated sign-in, and the browser bundle.
05QuestionsFAQ
01

Can Gemini CLI read AGENTS.md instead?

Yes. Set "context": { "fileName": ["AGENTS.md", "GEMINI.md"] } in .gemini/settings.json. Antigravity reads both files without a setting.

02

Why does the MCP snippet differ between Gemini CLI and Antigravity?

Gemini CLI names an HTTP server's address httpUrl, and reads url as an SSE server. Antigravity accepts only serverUrl. Use the snippet of the CLI that you run.

Official references

Start with a Sandbox Project

Create a RefRef account, add a Project, and get the keys that the Gemini CLI prompts need. Sandbox data never mixes with live data.

Get Started