GeminiIntermediate

How to Give Gemini CLI Project Context with a GEMINI.md File

Create a GEMINI.md memory file so the Gemini CLI knows your project conventions on every run.

6 minIntermediate

The Gemini CLI reads a file named GEMINI.md and loads it as standing instructions, the same way Claude Code reads CLAUDE.md. Use it to record your stack, coding style, and rules so you do not repeat yourself in every prompt. This guide shows where to put it and what to write.

What you need

  • The Gemini CLI installed and signed in
  • A code project you work in regularly
  • A text editor
  • About 5 minutes

Step 1: Create GEMINI.md at the project root

Add a file named GEMINI.md in the top folder of your repository. The CLI picks it up automatically whenever you run gemini from that folder or any subfolder. Keep it short and specific, since every word counts against context.

GEMINI.md
# Project: Invoice API

## Stack
- Node 20, Express, TypeScript
- PostgreSQL via Prisma
- Tests with Vitest

## Conventions
- Use named exports, never default exports.
- All money values are stored in integer cents.
- Never edit files under prisma/migrations by hand.

## Commands
- Run tests: npm test
- Type check: npm run typecheck

Step 2: Confirm the CLI loaded it

Start the CLI and run the /memory show command. It prints the combined instructions currently in context, including your GEMINI.md. If it is empty, you are probably running from a folder above the file.

gemini - memory
> /memory show
Loaded memory from 1 file (GEMINI.md):
# Project: Invoice API
## Stack ...
## Conventions ...
Output of /memory show with the file loaded.

Step 3: Layer global and folder context

You can keep personal defaults in ~/.gemini/GEMINI.md and project rules in the repo file. Subfolders can have their own GEMINI.md too. The CLI merges them, with the most specific file taking priority, so a frontend folder can add UI rules on top of the root file.

Reload after edits
If you change GEMINI.md while a session is open, run /memory refresh to reload it without restarting the CLI.

Result

Every prompt now starts with your project context baked in. Instead of explaining your stack each time, you can ask Add a discount field to invoices and trust that the agent already knows to store money as integer cents and avoid editing migrations.

Watch related tutorials

Tags
#gemini-cli#context#gemini-md#config#memory