Gemini CLI with Persistent Memory

Google's Gemini CLI brings Gemini's capabilities to your terminal, but each session starts fresh. This guide shows how to pair Gemini CLI with REM Labs to create a memory-augmented terminal workflow where context persists across every session.

The Setup

Gemini CLI supports extensions and tool use. We will use the REM Labs CLI alongside Gemini to create a memory-augmented workflow. Install both tools:

# Install Gemini CLI npm install -g @google/gemini-cli # Install REM Labs CLI npm install -g @remlabs/cli # Set your REM Labs API key export REMLABS_API_KEY="your-api-key"

Method 1: MCP Server Configuration

Gemini CLI supports MCP servers. Add REM Labs to your Gemini CLI settings file:

// ~/.gemini/settings.json { "mcpServers": { "remlabs": { "command": "npx", "args": ["@remlabs/mcp-server"], "env": { "REMLABS_API_KEY": "your-api-key" } } } }

After restarting Gemini CLI, it will have access to remember, recall, and forget tools.

Method 2: Shell Wrapper

For a lighter approach, create a shell function that pre-loads context before each Gemini CLI session:

#!/bin/bash # Add to ~/.bashrc or ~/.zshrc gemini-mem() { # Recall relevant context local context=$(remlabs recall "$*" \ --namespace "$(basename $PWD)" \ --limit 5 --format text 2>/dev/null) if [ -n "$context" ]; then echo "--- Loaded memories ---" echo "$context" echo "--- End memories ---" echo "" fi # Start Gemini CLI with context gemini --system-instruction \ "Previous context from memory: $context" "$@" }

Using Memory with Gemini CLI

With MCP configured, interact naturally:

# Session 1 You: "We are using Firestore for the main database and Cloud Functions for the API layer. Remember this architecture decision." Gemini: [stores via REM Labs] # Session 2 (new terminal, days later) You: "What database are we using?" Gemini: [recalls] "You decided on Firestore for the main database with Cloud Functions for the API layer."

Gemini + REM Labs for Google Cloud Projects

This combination is especially powerful for Google Cloud workflows. Store GCP-specific context that Gemini can use:

# Store project config remlabs remember "GCP Project: my-app-prod, Region: us-central1, Cloud Run service: api-v2, Cloud SQL instance: main-postgres-14" \ --tags "gcp,infrastructure" \ --namespace "my-app" # Store deployment conventions remlabs remember "Deploy flow: push to main triggers Cloud Build, which runs tests, builds container, deploys to Cloud Run with --no-traffic, then gradually shifts traffic over 10 minutes" \ --tags "gcp,deploy,ci-cd" \ --namespace "my-app"

Namespace tip: Use your GCP project ID as the namespace to keep memories organized per cloud project.

Give Gemini CLI a lasting memory

Free tier. Works with MCP or shell wrapper. Memory across sessions.

Get started free →