> ## Documentation Index
> Fetch the complete documentation index at: https://docs.claude-mem.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Antigravity CLI Setup

> Add persistent memory to Antigravity CLI with claude-mem

# Antigravity CLI Setup

> **Give Antigravity CLI persistent memory across sessions.**

Antigravity CLI (`agy`) is Google's standalone successor to Gemini CLI — it reuses Gemini CLI's `~/.gemini/` config tree and, per Google, "keeps the most critical features of Gemini CLI: Agent Skills, Hooks, Subagents, and Extensions." Claude-mem changes what happens across sessions by capturing observations, decisions, and patterns — then injecting relevant context into each new session.

> [!NOTE]
>
> **How it works:** Claude-mem installs lifecycle hooks into Antigravity CLI's `~/.gemini/config/hooks.json` that capture tool usage, agent responses, and session events. A local worker service extracts semantic observations and injects relevant history at session start — via `GEMINI.md`, an MCP server, and a rules file.

> [!NOTE]
>
> Antigravity CLI is a different product from the Antigravity **desktop IDE** (`antigravity` binary) — both share the same `~/.gemini/antigravity` namespace, but the CLI's own binary is `agy`. Detection checks for `agy` in your `PATH` (or an existing `~/.gemini/antigravity` directory).

## Prerequisites

* [Antigravity CLI](https://github.com/google-antigravity/antigravity-cli) (`agy`) installed — `curl -fsSL https://antigravity.google/cli/install.sh | bash`
* [Node.js](https://nodejs.org/) 18+
* The `~/.gemini` directory must exist (created by Antigravity CLI / Gemini CLI on first run)

## Installation

### Step 1: Install claude-mem

```bash theme={null}
npx claude-mem install --ide antigravity
```

The installer will:

1. Auto-detect Antigravity CLI (checks for `agy` in `PATH`, or an existing `~/.gemini/antigravity` directory)
2. Install the Antigravity CLI lifecycle hooks into `~/.gemini/config/hooks.json`
3. Inject context configuration into `~/.gemini/GEMINI.md`
4. Register claude-mem's MCP server in `~/.gemini/antigravity/mcp_config.json` **and** `~/.gemini/config/mcp_config.json`
5. Write a rules/context placeholder to `~/.agents/rules/claude-mem-context.md`
6. Start the worker service

### Step 2: Configure an AI provider

Claude-mem needs an AI provider to extract observations from your sessions. Choose one:

> [tab] Gemini API
>
> The simplest option — use Gemini's own API for observation extraction:
>
> 1. Create an API key in [Google AI Studio](https://aistudio.google.com/apikey)
> 2. Add it to your settings:
>
> ```bash theme={null}
> mkdir -p ~/.claude-mem
> cat > ~/.claude-mem/settings.json << 'EOF'
> {
>   "CLAUDE_MEM_PROVIDER": "gemini",
>   "CLAUDE_MEM_GEMINI_API_KEY": "YOUR_API_KEY"
> }
> EOF
> ```
>
> > [!TIP]
> >
> > **No billing required:** You can create a Gemini API key without enabling billing. Enable billing for higher rate limits only after reviewing Google's current quota and billing terms.

> [tab] Claude SDK
>
> If you have a Claude API key:
>
> ```bash theme={null}
> mkdir -p ~/.claude-mem
> cat > ~/.claude-mem/settings.json << 'EOF'
> {
>   "CLAUDE_MEM_PROVIDER": "claude"
> }
> EOF
> ```
>
> Set your API key via environment variable:
>
> ```bash theme={null}
> export ANTHROPIC_API_KEY="your-key"
> ```

> [tab] OpenRouter
>
> For access to 100+ models:
>
> ```bash theme={null}
> mkdir -p ~/.claude-mem
> cat > ~/.claude-mem/settings.json << 'EOF'
> {
>   "CLAUDE_MEM_PROVIDER": "openrouter",
>   "CLAUDE_MEM_OPENROUTER_API_KEY": "YOUR_KEY"
> }
> EOF
> ```

### Step 3: Verify installation

```bash theme={null}
# Check worker is running
npx claude-mem status

# Check hooks are installed — look for claude-mem entries
cat ~/.gemini/config/hooks.json | grep claude-mem

# Check MCP registration in either candidate config path
cat ~/.gemini/antigravity/mcp_config.json | grep claude-mem
cat ~/.gemini/config/mcp_config.json | grep claude-mem
```

Open the worker URL printed on startup to see the memory viewer.

### Step 4: Start using Antigravity CLI

Launch Antigravity CLI normally. Claude-mem works in the background:

```bash theme={null}
agy
```

On session start, you'll see claude-mem context injected with your recent observations and project history.

## What gets captured

Claude-mem registers five of the lifecycle hooks Antigravity CLI (`agy` 1.2.1) fires:

| Hook | Internal event | Purpose |
| - | - | - |
| **SessionStart** | `context` | Injects memory context (via `injectSteps`) once when a session starts, so the prompt prefix stays cacheable |
| **PreInvocation** | `session-init` | Fires before every model call. Records your prompt once, on the first call of a turn (agy has no prompt-submit hook). On a later call in the same turn, if the last tool step read files that have history, injects that history once per file (via `injectSteps`) |
| **PostToolUse** | `observation` | Captures tool results after execution |
| **PostInvocation** | `observation` | Records the agent's response (from the transcript's `PLANNER_RESPONSE` node) |
| **Stop** | `summarize` | Captures the session summary at turn/session end |

> [!NOTE]
>
> These are the event names `agy` reads from `hooks.json`. Earlier releases mistakenly registered Gemini CLI names (`BeforeAgent`, `AfterAgent`, `BeforeTool`, `AfterTool`) into `~/.gemini/settings.json`, where `agy` never reads them, so hooks never fired and no observations were recorded (issue [#4057](https://github.com/thedotmack/claude-mem/issues/4057)). Installs before [#4911](https://github.com/thedotmack/claude-mem/issues/4911) injected context on `PreInvocation`, before every model call, which broke prompt caching; re-run `claude-mem install --ide antigravity` to move it to `SessionStart`. `PreInvocation` is back as `session-init`: it records the prompt and injects file history only after a file read, not on every call. Installs before [#5078](https://github.com/thedotmack/claude-mem/issues/5078) also registered `PreToolUse`, whose `allow` answer skipped agy's permission prompt for every tool; re-running the installer removes it.

## MCP registration

Antigravity CLI has native MCP support, but which config path it reads was genuinely ambiguous at the time of writing — two real candidate paths exist on disk with no definitive documentation resolving which one `agy` loads. Claude-mem writes to **both**, safely and idempotently:

* `~/.gemini/antigravity/mcp_config.json`
* `~/.gemini/config/mcp_config.json`

This gives claude-mem's search tools (`search`, `smart_search`, `timeline`, etc.) a chance to register correctly regardless of which path Antigravity CLI actually reads.

## Future enhancement (not implemented in this release)

Antigravity CLI ships a first-class plugin-marketplace subcommand system: `agy plugin {list,import,install,uninstall,enable,disable,validate,link}`. Notably, `agy plugin import gemini|claude` suggests native cross-tool plugin migration — structurally similar to Codex CLI's `.codex-plugin/plugin.json` marketplace mechanism. This could eventually be a cleaner, more idiomatic way to bundle claude-mem's hooks + MCP + skills registration than hand-editing `hooks.json`. It isn't implemented here because its manifest schema isn't discoverable without running `agy plugin import`/`install` against a real manifest, which would mutate a user's live local plugin state. Tracked as a candidate follow-up.

## Troubleshooting

### Hooks not firing

1. Verify hooks exist in the hooks config:
   ```bash theme={null}
   cat ~/.gemini/config/hooks.json
   ```
   Each top-level key is a **hook name**. claude-mem writes a single
   `"claude-mem"` key wrapping the event keys, with `PostToolUse`
   using the grouped `{ "matcher", "hooks" }` shape and
   `SessionStart`/`PreInvocation`/`PostInvocation`/`Stop` using a flat array of handlers:
   ```json theme={null}
   {
     "claude-mem": {
       "SessionStart": [ { "type": "command", "command": "...", "timeout": 30 } ],
       "PreInvocation": [ { "type": "command", "command": "...", "timeout": 30 } ],
       "PostToolUse": [ { "matcher": "*", "hooks": [ { "type": "command", "command": "...", "timeout": 30 } ] } ],
       "PostInvocation": [ { "type": "command", "command": "...", "timeout": 30 } ],
       "Stop": [ { "type": "command", "command": "...", "timeout": 30 } ]
     }
   }
   ```
   `timeout` is in **seconds** (agy's default is 30). If you see event names at
   the top level, handlers tagged with `"name": "claude-mem"`, or
   `"timeout": 10000`, you are on a pre-fix install — re-run the installer
   below, which migrates the old layout automatically.

2. Restart Antigravity CLI after installation.

3. Re-run the installer:
   ```bash theme={null}
   npx claude-mem install --ide antigravity
   ```

### Worker not running

```bash theme={null}
# Check status
npx claude-mem status

# View logs
npx claude-mem logs

# Restart worker
npx claude-mem restart
```

### No context appearing at session start

1. Ensure the worker is running (`npm run worker:status`)
2. You need at least one previous session with observations for context to appear
3. Check your AI provider is configured in `~/.claude-mem/settings.json`

### Raw escape codes in output

If you see characters like `[31m` or `[0m` in the session context, your claude-mem version may need updating — the Antigravity CLI adapter strips ANSI color codes automatically:

```bash theme={null}
npx claude-mem install --ide antigravity
```

## Uninstalling

```bash theme={null}
npx claude-mem uninstall
```

This removes claude-mem's hooks from `~/.gemini/config/hooks.json` (and any legacy entries from `~/.gemini/settings.json`), cleans up the context section in `~/.gemini/GEMINI.md`, removes claude-mem's entry from both MCP config files, and removes the rules context section — while preserving everything else in those files.

## Next Steps

* [Gemini Provider](https://docs.claude-mem.ai/usage/gemini-provider.md) — Configure the Gemini AI provider for observation extraction
* [Configuration](https://docs.claude-mem.ai/configuration.md) — All settings options
* [Search Tools](https://docs.claude-mem.ai/usage/search-tools.md) — Search your memory from within sessions
* [Troubleshooting](https://docs.claude-mem.ai/troubleshooting.md) — Common issues and solutions


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.