> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-cli/integrations/antigravity.md).

# Google Antigravity

Install secrets-detection hooks, the SonarQube MCP Server, and Vortex analysis for Google Antigravity with the SonarQube CLI.

`sonar integrate antigravity` configures the SonarQube CLI to work alongside [Google Antigravity](https://antigravity.google/). In an interactive terminal, the command prompts you to install each component:

* **A secrets-detection hook**: a `PreToolUse` handler on `view_file` that scans files for secrets before Antigravity reads them.
* **Prompt-secrets rules** that tell the agent to refuse working with exposed tokens: a workspace rule in `.agents/rules/sonar-prompt-secrets.md` for project installs, or a managed snippet in `~/.gemini/GEMINI.md` for global installs.
* **The** [**SonarQube MCP Server**](https://docs.sonarsource.com/sonarqube-mcp-server/) in your user-level Antigravity MCP configuration so Antigravity can fetch projects, issues, and rules directly.
* Vortex (when your connection has a Vortex subscription: SonarQube Cloud Team or Enterprise plan, or SonarQube Server 2026.5 Enterprise and Data Center editions): one prompt that installs [Vortex analysis](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-analysis.md) at project or `--global` scope. Project installs write an always-on rule in `.agents/rules/sonar-agentic-analysis.md`; `--global` installs write a managed snippet in `~/.gemini/GEMINI.md`. Both tell Antigravity to run `sonar analyze agentic` on files you modified before ending the turn. Antigravity has no session-start hook, so [Vortex context](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-context.md) is not installed.

Pass `--non-interactive` to accept every offered component without prompts (see [Non-interactive install](#non-interactive-install)).

## Prerequisites

* [The SonarQube CLI is installed and authenticated](/sonarqube-cli/quickstart-guide.md).
* [Google Antigravity](https://antigravity.google/) is installed.
* You're working inside a project directory (or you're installing globally with `--global`).

## Install

Run inside the project you want to integrate, with the project key:

```bash
sonar integrate antigravity --project <YourProjectKey>
```

Or install once for your whole machine:

```bash
sonar integrate antigravity --global
```

> **Note:** In an interactive terminal, if you omit both `--global` and `--project`, the CLI asks whether to install for this project or globally before continuing. See [Project versus global scope](/sonarqube-cli/integrations/integrations.md#project-versus-global-scope).

> **Warning:** `--project` and `--global` are mutually exclusive. Passing both causes the command to fail with an "invalid options" error (exit code `2`).

> **Note:** Vortex installs at either scope. With SonarQube CLI versions earlier than 1.8.0, Vortex is project-scoped: it's skipped when you run `sonar integrate antigravity --global`; rerun the command without `--global` from a project directory to install Vortex for that project.

### What the command does

The integrator runs in three phases:

1. Discovery and validation. It locates your project's config using the [project key auto-detection](/sonarqube-cli/integrations/integrations.md#project-key-auto-detection) chain, or the explicit `--project` flag, and verifies the token.
2. Health check and repair. It calls SonarQube to confirm the token, organization, and project are valid. If the token is broken and you're running interactively, it offers to refresh it.
3. Installation. For each component (secrets hook, prompt-secrets rules, MCP server, and Vortex when eligible), the CLI either prompts you to install it, skips it with an explanation, or accepts it automatically in non-interactive mode. Before writing files, it shows a [What will be installed](/sonarqube-cli/integrations/integrations.md#install-confirmation) summary of accepted features. In interactive mode, press Enter to confirm. Then it installs accepted components into either the project directory or your home directory, depending on `--global`.

   Common skip reasons include:

   * A global secrets hook is already configured (the project-level hook is skipped to avoid duplicate scans).
   * Your connection doesn't have a Vortex subscription (only available with SonarQube Cloud Team or Enterprise plan, or SonarQube Server 2026.5 Enterprise and Data Center editions), or you're on a CLI version earlier than 1.8.0 and used `--global` (Vortex was project-scoped before 1.8.0).

   If global Antigravity prompt-secrets rules already exist and you run a project install, the CLI asks whether you also want a project-local copy of the prompt-secrets workspace rule.

### Options

| Option              | Description                                                                                   |
| ------------------- | --------------------------------------------------------------------------------------------- |
| `--project`, `-p`   | SonarQube project key. Mutually exclusive with `--global`.                                    |
| `--global`, `-g`    | Install hooks and config globally under `~/.gemini/config/` instead of the project directory. |
| `--non-interactive` | Non-interactive mode (no prompts).                                                            |

### Where files are installed

Antigravity uses project-scoped files under `.agents/` and user-level files under `~/.gemini/config/`. The MCP server entry is always written to the user-level MCP configuration file, because Antigravity supports only one MCP config location.

| Scope             | Hook & config location                                                                                        |
| ----------------- | ------------------------------------------------------------------------------------------------------------- |
| `--global`        | `~/.gemini/config/` (hooks, MCP config); prompt-secrets and Vortex analysis snippets in `~/.gemini/GEMINI.md` |
| Project (default) | `.agents/` in the repository (hooks, rules); MCP config in `~/.gemini/config/mcp_config.json`                 |
| Shared binaries   | `~/.sonar/sonarqube-cli/bin/`                                                                                 |

State for installed integrations is recorded in `~/.sonar/sonarqube-cli/state.json`. See [State and storage](/sonarqube-cli/administration/state-and-storage.md).

## Restart Antigravity

Antigravity reads hooks, rules, and MCP configuration at startup. Restart Antigravity for the integration to take effect.

## Vortex analysis

When you run `sonar integrate antigravity`, the command writes Vortex analysis instructions that tell Antigravity to run `sonar analyze agentic --depth DEEP` on every file it modified that turn in a single command (repeat `--file` for each path, or fall back to the git change set). Project installs write an always-on rule in `.agents/rules/sonar-agentic-analysis.md`. A `--global` install writes the same instructions as a managed snippet in `~/.gemini/GEMINI.md`, because Antigravity has no global rules directory. The CLI auto-detects the project key, so the instructions omit `--project`. If analysis reports that no project is configured, the instructions tell the agent to stay silent for the rest of the session instead of repeating a skip notice. Antigravity's hook model doesn't support injecting analysis findings back into the conversation the way Claude Code and Codex hooks do, so the CLI uses the same rules-based pattern as GitHub Copilot CLI and Cursor.

Vortex context is not installed for Antigravity: it has no session-start hook. If an earlier CLI version wrote `.agents/skills/sonar-context-augmentation/SKILL.md`, update to SonarQube CLI 1.8.0 or later, then re-run `sonar integrate antigravity` from the project directory to remove that leftover file.

For an overview of Vortex analysis, see [Vortex analysis](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-analysis.md).

## Verify it works

### Test the secrets hook

1. Create a file in your project with a fake-looking but secret-shaped value:

   ```javascript
   // secrets.js
   const API_KEY = "sqp_1aa323ae0689cd4a1abd062a2ad0a224ae8a1d13";
   ```
2. Ask Antigravity to read it: *"Read secrets.js."*
3. Antigravity should block the read and explain that the file contains a secret.

Once you've confirmed the hook is active, delete the test file.

Run `sonar system status` to confirm the Antigravity integration reports **Secrets Hook: CONFIGURED**. If the hook entry exists but the backing script is missing or malformed, status shows **CONFIGURED / INVALID CONFIG** and recommends re-running `sonar integrate antigravity`. See [Check system status](/sonarqube-cli/administration/system-status.md).

### Test the MCP server

Ask Antigravity to list your SonarQube projects via the MCP server. If the call fails, run `sonar auth status` to confirm the underlying token is healthy and restart Antigravity.

### Test Vortex analysis

Make a code change through Antigravity (for example, ask it to edit a file). Before ending the turn, Antigravity should run Vortex analysis on the modified files per the installed rules. This requires a [Sonar Vortex](/agent-centric-development-cycle/inside-your-agent-the-agentic-loop/sonar-vortex-analysis.md) subscription.

## Non-interactive install

For provisioning scripts, dotfiles, and onboarding automation:

```bash
sonar integrate antigravity --global --non-interactive
```

In non-interactive mode, the CLI doesn't prompt for scope selection, feature selection, install confirmation, token repair, or feature removal. Scope defaults to project when you omit `--global`, and it installs every component that isn't explicitly skipped. When you authenticate with [environment variables](/sonarqube-cli/using-sonarqube-cli/environment-variables.md), integrate commands also run in non-interactive mode even without the flag. Run [`sonar auth status`](/sonarqube-cli/using-sonarqube-cli/commands.md#sonar-auth-status) afterward to confirm everything is configured correctly.

## Uninstall

Run `sonar integrate antigravity` again in an interactive terminal. For each installed feature, the CLI asks **Keep?**: answer No, confirm **Proceed with removal?**, and the CLI removes hooks, rules, and state for that feature. Vortex is removed as one unit (Vortex analysis rules). See [integrations/README.md](/sonarqube-cli/integrations/integrations.md#removing-installed-features) for the full flow.

For a manual cleanup or non-interactive environments:

1. Delete the SonarQube hook files and rules written under your Antigravity configuration directories.
2. Remove the SonarQube MCP server entry from your Antigravity configuration.
3. Remove the integration entry from `~/.sonar/sonarqube-cli/state.json` (under `integrations.installed`).

See [Uninstalling](/sonarqube-cli/administration/uninstall.md) for the full removal procedure.

## Migrate from Gemini CLI

Antigravity replaces Gemini CLI. If you previously used the SonarQube Gemini extension, migrate your platform configuration first, then run:

```bash
agy plugin import gemini       # converts legacy extensions and MCP config to native Antigravity format
sonar integrate antigravity    # adds hooks, rules, and Vortex analysis (new vs. Gemini)
```

`agy plugin import gemini` scans your existing Gemini directories and migrates the SonarQube MCP entry into `mcp_config.json`. After verifying Antigravity works, remove any duplicate legacy extension install if the import created a copy.

For a fresh install on a machine that never had Gemini, use the steps in [Install](#install) above.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [Analyzing local changes](/sonarqube-cli/analysis/analyzing-local-changes.md)
* [Commands reference](/sonarqube-cli/using-sonarqube-cli/commands.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-cli/integrations/antigravity.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
