Gemini CLI Configuration

GEMINI.md Guide

Configure Google's Gemini CLI with context files. Learn about hierarchical loading, memory commands, and best practices for AI-assisted development.

Understanding GEMINI.md

GEMINI.md is a context file for Gemini CLI, Google's open-source AI coding assistant that brings Gemini directly into your terminal. Instead of repeating instructions in every prompt, you define them once in GEMINI.md and Gemini references them automatically.

The format is nearly identical to CLAUDE.md, making it easy to maintain configurations for both tools if you use multiple AI assistants.

File Locations

Gemini CLI loads context files from multiple locations in a hierarchical system:

  • Global ~/.gemini/GEMINI.md provides default instructions for all projects
  • Project-level — CLI searches for GEMINI.md in your current directory and each parent up to the project root (.git folder)
  • All found files are concatenated and sent to the model with every prompt

GEMINI.md Format

GEMINI.md
# Project Context

This is a Next.js 14 application using App Router, TypeScript, and Tailwind CSS.

## Tech Stack
- Next.js 14 (App Router)
- TypeScript strict mode
- Tailwind CSS + shadcn/ui
- Prisma with PostgreSQL
- NextAuth.js for authentication

## Project Structure
```
src/
├── app/           # Next.js App Router pages
├── components/    # React components
├── lib/           # Utility functions and configs
├── hooks/         # Custom React hooks
└── types/         # TypeScript type definitions
```

## Code Style
- Use functional components with hooks
- Prefer Server Components by default
- Use async/await over Promise chains
- Keep components under 150 lines
- No 'any' types allowed

## Commands
- `npm run dev` - Start development server
- `npm run build` - Build for production
- `npm run test` - Run tests
- `npm run db:push` - Push Prisma schema

Memory Commands

Gemini CLI provides commands to interact with loaded context:

/memory show

Displays the full, concatenated content of the current hierarchical memory

/memory refresh

Forces a re-scan and reload of all GEMINI.md files from all configured locations

/memory add <text>

Appends your text to the global ~/.gemini/GEMINI.md file for persistent memories

AGENTS.md Alternative

Gemini CLI also supports AGENTS.md files. If you have both GEMINI.md and AGENTS.md in the same directory, GEMINI.md takes precedence.

AGENTS.md is useful if you want to share instructions across multiple AI tools (Gemini, Claude Code, etc.) since the format is compatible with several tools.

Best Practices

  • Modularize for large projects — Prevent context bloat by splitting into focused files
  • Use hierarchical files — Global settings in ~/.gemini/, project-specific in repo root
  • Keep it concise — The model receives all context with every prompt
  • Include commands — Document common shell commands so Gemini can execute them
  • Use /memory refresh — After editing GEMINI.md during a session

Related Guides

CLAUDE.mdCLAUDE.md Guide.cursorrulesCursor Rules GuideComparisonCompare All Tools

Frequently Asked Questions

Manage Your GEMINI.md Files Visually

ClaudeMDEditor lets you browse, edit, and organize GEMINI.md files across all your projects. Plus it handles CLAUDE.md, .cursorrules, and more.

Claude CodeCursorCopilotWindsurfGeminiCodexAider
Get ClaudeMDEditor — $13

One-time purchase for macOS Tahoe (26+)