# GEMINI.md template

> GEMINI.md is the context file Gemini CLI loads at the start of every session, so the agent knows your commands, layout and rules. Save the example below as GEMINI.md at the root of your repository, replace the commands and rules with your own, and run /memory show to check what Gemini loaded.

Updated November 30, 2026. Canonical: https://sniptide.com/templates/gemini-md
Open it in the Sniptide editor: https://app.sniptide.com/new?template=gemini-md
Files as JSON: https://sniptide.com/templates/gemini-md.json

## Files

### GEMINI.md

```markdown
# Project context

This is a FastAPI service with a Postgres database. Python 3.13, dependencies managed with uv.

## Commands

- Install: `uv sync`
- Start the database: `docker compose up -d --wait`
- Run the API: `uv run fastapi dev app/main.py`, then open `http://127.0.0.1:8000/docs`
- Check your work: `uv run ruff check .`, `uv run ruff format --check .` and `uv run pytest`

Run all three checks before you say a task is done, and report any that fail.

## Layout

- `app/routers/` holds one module per resource. Routes stay thin and call services.
- `app/services/` holds business logic. Services take a database session as an argument.
- `app/models.py` holds SQLAlchemy models. Schema changes need an Alembic migration.
- `tests/` mirrors `app/`.

## Rules

- Type every function signature. Use Pydantic models for request and response bodies.
- Read configuration from `app/settings.py`, never from `os.environ` directly.
- Create migrations with `uv run alembic revision --autogenerate -m "<change>"` and read the
  generated file before you keep it.
- Do not edit files in `alembic/versions/` that are already on the main branch.
- Ask before adding a dependency, deleting files or running commands that change the database
  outside the test container.

## Style

@docs/style.md
```

## How Gemini CLI loads it [#how-gemini-cli-loads-it]

Gemini CLI combines every context file it finds and sends the result with each prompt. It reads them in this order:

| Location | Scope |
| --- | --- |
| `~/.gemini/GEMINI.md` | Your own preferences, in every project. |
| `GEMINI.md` in the project root and its parent folders | Rules for the whole repository. Commit it. |
| `GEMINI.md` in a subfolder | Rules for that part of the codebase, such as `frontend/GEMINI.md`. |

Start `gemini` in the repository and run `/memory show` to print the combined context. After you edit a file, run `/memory refresh` to reload it. [Gemini CLI repository](https://github.com/google-gemini/gemini-cli)

## What each section does [#what-each-section-does]

**The opening line** names the stack and package manager, so the agent doesn't reach for `pip` in a uv project.

**Commands** lists the exact commands to install, run and check the project. The line after them asks the agent to run the checks itself and report failures.

**Layout** says where each kind of code lives, so new code lands in the right module.

**Rules** covers what the code can't show, such as where configuration comes from and which files never change. The last rule names the actions that need your approval.

**`@docs/style.md`** imports another file into the context. Use imports to keep GEMINI.md short and to share one style guide between several files. Paths are relative to the file that imports them.

## Variant: share AGENTS.md with other agents [#variant-share-agentsmd-with-other-agents]

If your repository already has an [AGENTS.md](/templates/agents-md) for other coding agents, point Gemini CLI at it instead of keeping two copies. Add this to `.gemini/settings.json` in the project:

```json title=".gemini/settings.json"
{
  "context": {
    "fileName": ["AGENTS.md", "GEMINI.md"]
  }
}
```

Gemini CLI then loads both names in every folder it searches. Keep shared rules in AGENTS.md and put Gemini-specific notes in GEMINI.md.

## Variant: a personal context file [#variant-a-personal-context-file]

Put rules that are about you rather than the project in `~/.gemini/GEMINI.md`, so they follow you into every repository:

```md title="~/.gemini/GEMINI.md"
# Personal preferences

- Explain a plan in a few bullet points before editing more than three files.
- Use British English in comments and documentation.
- Never run `git push`. I push myself.
```
