GEMINI.md: context files for Gemini CLI
Gemini CLI loads instructional context from GEMINI.md files: a global one in ~/.gemini/, one at the project root and others in subfolders. To share rules with other agents, set "context": { "fileName": ["AGENTS.md", "GEMINI.md"] } in .gemini/settings.json so it reads AGENTS.md as well.
Where the file goes
GEMINI.mdat the project root (and optionally in subfolders).~/.gemini/GEMINI.mdfor global rules..gemini/settings.jsonto change which file names are loaded.
How it works
- Gemini CLI concatenates the context files it finds and sends them with every prompt.
- Use
/memory showto see what is loaded.
Tips for a good GEMINI.md
- If you already maintain AGENTS.md, just add the settings file instead of duplicating rules.
Example: Go + Docker
GEMINI.md
# GEMINI.md - this project
Project context for Gemini CLI.
## Project
A Go + Docker project.
Stack: Go, Docker.
## Commands
- Run: `go run ./cmd/<app>`
- Tests: `go test ./...`
- Vet: `go vet ./...`
- Format: `gofmt -w .`
- Local services: `docker compose up -d`
## Project structure
- Entrypoints in `cmd/<app>/main.go`, private packages in `internal/`.
## How to work in this repo
- Read the relevant files before editing. Follow the patterns already in the codebase over these generic rules.
- Make the smallest change that solves the task. Do not refactor or reformat unrelated code.
- Before saying a task is done, run the type-check, lint and tests listed under Commands and fix what you broke.
- If requirements are ambiguous, ask one clear question instead of guessing.
- Never commit secrets, API keys or `.env` files. Use env vars and keep `.env.example` up to date.
- Do not add a new dependency when the standard library or an existing dependency already covers it.
- Ask before adding, removing or upgrading any dependency.
- Ask before changing database schemas, auth, payments or CI configuration.
- Never delete files, drop data or run destructive commands (`rm -rf`, `git push --force`, `DROP TABLE`) without explicit approval.
- Keep each change under ~200 changed lines where possible; split larger work into steps.
## Go
- Code must be `gofmt`-formatted and pass `go vet`.
- Return errors, do not panic. Wrap with context: `fmt.Errorf("load user %d: %w", id, err)`.
- Pass `context.Context` as the first parameter to anything doing I/O and respect cancellation.
- Use Go 1.22+ `http.ServeMux` patterns (`mux.HandleFunc("GET /items/{id}", h)`, `r.PathValue("id")`) before adding a router dependency.
- Keep interfaces small and define them where they are consumed.
- Write table-driven tests with `t.Run` subtests.
- Use `log/slog` for structured logging.
## Docker
- Use multi-stage builds and slim, pinned base images.
- Run the app as a non-root user in the final image.
- Keep a `.dockerignore` that excludes `.git`, `node_modules`, `.env` and build output.
- Never bake secrets into images; pass them at runtime.
## Reference docs
- [Effective Go](https://go.dev/doc/effective_go)
- [Dockerfile best practices](https://docs.docker.com/build/building/best-practices/)
FAQ
Does Gemini CLI read AGENTS.md?
Not by default. Add AGENTS.md to context.fileName in .gemini/settings.json.
GEMINI.md templates by stack
- Next.js (App Router) + Tailwind CSS v4 + shadcn/ui + Supabase + Zod validation GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 + Prisma + Stripe payments + Zod validation GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 + Drizzle ORM + Clerk auth + Zod validation GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 + shadcn/ui + Vercel AI SDK + Zod validation GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 + Supabase + Stripe payments + Zod validation + Vitest GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 + Firebase GEMINI.md
- Next.js (App Router) + Tailwind CSS v4 + Vitest + Playwright E2E GEMINI.md
- React + Vite + Tailwind CSS v4 + TanStack Query + Vitest + Zod validation GEMINI.md
- React + Vite + Tailwind CSS v4 + Supabase + Zustand GEMINI.md
- React + Vite + Tailwind CSS v4 + Firebase + Vitest GEMINI.md
- Astro + Tailwind CSS v4 GEMINI.md
- SvelteKit (Svelte 5) + Tailwind CSS v4 + Supabase + Zod validation GEMINI.md
- SvelteKit (Svelte 5) + Tailwind CSS v4 + Drizzle ORM + Vitest GEMINI.md
- Nuxt (Vue 3) + Tailwind CSS v4 + Zod validation GEMINI.md
- Nuxt (Vue 3) + Tailwind CSS v4 + Supabase GEMINI.md
- Expo (React Native) + Supabase + Zod validation + Jest GEMINI.md
- Expo (React Native) + TanStack Query + Zustand + Jest GEMINI.md
- Node.js + Express + Prisma + Zod validation + Vitest + Docker GEMINI.md
- Node.js + Express + Drizzle ORM + Zod validation + Docker GEMINI.md
- Python + FastAPI + SQLAlchemy 2 + Alembic + pytest + Docker GEMINI.md
- Python + FastAPI + LLM / agent SDKs (Python) + pytest GEMINI.md
- Python + FastAPI + Supabase + pytest GEMINI.md
- Python (scripts, agents, libraries) + LLM / agent SDKs (Python) + pytest GEMINI.md
- Python + Django + pytest + Docker GEMINI.md
- Python + Django + Tailwind CSS v4 + pytest GEMINI.md
- Ruby on Rails + Tailwind CSS v4 + Docker GEMINI.md
- PHP + Laravel + Tailwind CSS v4 + Stripe payments GEMINI.md
- Go + Docker GEMINI.md
- Rust + Axum + Docker GEMINI.md
- Java + Spring Boot + Docker GEMINI.md
- Flutter (Dart) + Firebase GEMINI.md
- Flutter (Dart) + Supabase GEMINI.md
- Swift + SwiftUI GEMINI.md
- Unity (C#) GEMINI.md
- Godot 4 (GDScript) GEMINI.md
- Phaser (TypeScript web games) + Vitest GEMINI.md
- Chrome Extension (MV3) + Tailwind CSS v4 + Zustand + Vitest GEMINI.md
Official docs: Gemini CLI docs. Last reviewed 2026-10-21.