# Gemini CLI Integration

> Gemini CLI 接入指南：一键配 MCP + continuity 规则，让 Gemini CLI 在新窗口里主动恢复稳定上下文。

## Quick Start

```bash
bash integrations/gemini-cli/setup.sh
```

## What It Does

- Adds RecallNest as an MCP server in `~/.gemini/settings.json` with `trust: true`
- Installs a managed RecallNest block in `~/.gemini/GEMINI.md`

## Continuity Rules

The managed block comes from [gemini-md-snippet.md](gemini-md-snippet.md) and tells Gemini CLI to:

- call `resume_context` at the start of fresh windows or continuity-sensitive tasks
- run lightweight `search_memory` on task pivots inside the same project before repo exploration drifts
- reuse known `scope` / `sessionId` and the resolved scope returned by `resume_context` in follow-up recall calls
- treat recalled or startup-hook repo state as unverified until this window explicitly checks the repo
- save `checkpoint_session` before leaving resumable work
- do not inspect repo state just to enrich a close-window checkpoint unless the user explicitly asked for repo state
- do not write unverified repo-state claims into `checkpoint_session`
- capture durable facts with `store_memory` and reusable workflows with `store_workflow_pattern`

## Shared Index

Gemini CLI shares the same LanceDB index as Claude Code and Codex. Memories ingested from any source are searchable by all three.

## Manual Setup

Add to `~/.gemini/settings.json`:

```json
{
  "mcpServers": {
    "recallnest": {
      "command": "bun",
      "args": ["run", "RECALLNEST_PATH/src/mcp-server.ts"],
      "trust": true
    }
  }
}
```

Replace `RECALLNEST_PATH` with your actual path.

Then copy [gemini-md-snippet.md](gemini-md-snippet.md) into `~/.gemini/GEMINI.md` if you are not using `setup.sh`.

## Verify

Start Gemini CLI and ask: "resume my context for RecallNest continuity work"

If `resume_context` or `search_memory` is called, you're set.
