Skip to content

Google Antigravity

Antigravity support is in beta. The adapter installs a user-level plugin at ~/.gemini/config/plugins/token-optimizer/, wires PreInvocation / PreToolUse / Stop hooks, and records the R20 consent flag. Data collection stays off until that consent record exists.

  • The agy CLI, Antigravity 2.0 app, or Antigravity IDE.
  • Python 3.9+ on your PATH; repository CI covers 3.11-3.14.
  • For the fresh clone path: git.

Run from any folder. The clone creates a token-optimizer/ folder, then you move into it and install.

Terminal window
git clone --depth 1 https://github.com/alexgreensh/token-optimizer.git
cd token-optimizer
bash install.sh --antigravity

The install is idempotent. It writes only ~/.gemini/config/plugins/token-optimizer/ (the plugin payload, hooks.json, plugin.json) and records consent in ~/.gemini/token-optimizer/config.json. It never touches your own ~/.gemini/config/hooks.json, config.json, or settings.json.

Terminal window
TOKEN_OPTIMIZER_RUNTIME=antigravity python3 skills/token-optimizer/scripts/measure.py antigravity-doctor

Confirm Antigravity accepts the plugin:

Terminal window
agy plugin validate ~/.gemini/config/plugins/token-optimizer

To preview the install without writing anything:

Terminal window
bash install.sh --antigravity --dry-run

All require the TOKEN_OPTIMIZER_RUNTIME=antigravity prefix.

Terminal window
measure.py antigravity-install # wire the plugin and record consent
measure.py antigravity-doctor # readiness check
measure.py antigravity-summary # per-surface session summary
measure.py antigravity-rollup # ingest sessions into trends.db (auto on Stop)
measure.py antigravity-uninstall # remove only what was installed
measure.py antigravity-home # print the resolved Antigravity home

Collection is opt-in. The installer records antigravity_consent: true in ~/.gemini/token-optimizer/config.json; the hooks and rollup are no-ops until that record exists.

TOKEN_OPTIMIZER_ANTIGRAVITY_HOME (default ~/.gemini)
TOKEN_OPTIMIZER_ANTIGRAVITY_BIN (override the agy binary the doctor probes)
TOKEN_OPTIMIZER_BASH_COMPRESS (set 0 to disable command-output compression)

See Configuration for the full variable list.

Re-run the install after a git pull:

Terminal window
bash install.sh --antigravity
Terminal window
TOKEN_OPTIMIZER_RUNTIME=antigravity python3 skills/token-optimizer/scripts/measure.py antigravity-uninstall

antigravity-uninstall removes only ~/.gemini/config/plugins/token-optimizer/. Conversation data under ~/.gemini/ and Token Optimizer’s collected data and trends are left in place by design.