Learning how to write GEMINI.md well is less about prose style and more about deciding what must survive across sessions. A strong project-level GEMINI.md tells an agent how this repository works: toolchain, layout, verification commands, and hard boundaries. A weak one repeats generic “be careful” advice—or buries ticket-only notes that go stale the next day. This page mirrors the same engineering shape as how to write CLAUDE.md and how to write AGENTS.md, adapted for Gemini-oriented project memory.
01
Independence note
02
Why a project-level GEMINI.md exists
Coding agents forget your house style between chats. Humans also forget which command is canonical after a toolchain bump.GEMINI.md (when your tooling loads it) is a shared checklist: “here is how we build, test, and refuse unsafe help.” Put facts that are true for the whole repo—not the narrative of last week’s bug.
- Stack pin: Node/pnpm versions, package manager, SSG vs SSR assumptions.
- Source of truth: which file registers routes, sitemap, or feature flags.
- Done checks: the exact commands reviewers will run.
- Non-goals: deploy, DNS, secret files, out-of-scope packages.
Some Gemini-oriented hosts also read a shared AGENTS.md. A practical split: put cross-tool contracts in AGENTS.md, and Gemini-only preferences (host quirks, extra non-goals) inGEMINI.md—then keep overlapping facts in sync. Full choice notes live in AGENTS.md vs CLAUDE.md vs Cursor rules. For the broader delivery loop, see the coding agent workflow section in the agent engineering series.
03
Persistent project memory vs one-shot prompts
| GEMINI.md (project) | One-shot agent prompt |
|---|---|
| Stable across tickets and contributors | Scoped to this session’s objective |
| “Always register pages in pages[]” | “Add /good-gemini-md/ with FAQ this PR only” |
| Safe defaults and forbidden operations | Acceptance checks for the current change |
| Updated when the repo’s process changes | Discarded when the PR merges |
If you paste the entire ticket into GEMINI.md, you will fight stale instructions forever. If you omit repo contracts from every prompt and have no project file, every session re-learns your indent and build command the hard way. Use both layers. Session craft is covered in how to write a good agent prompt; Claude-oriented memory in how to write CLAUDE.md; editor rule files in cursor rules examples.
04
A GEMINI.md outline you can copy
Start from this skeleton. Delete sections you do not need; fill paths and commands with your repository’s reality. Treat it as examples / a template starter—not a product-mandated schema.
# GEMINI.md — project notes for Gemini-oriented coding agents
## Stack
- Node 22+, pnpm (see package.json packageManager if present)
- Hono JSX + Vite + Hono SSG → static dist/; no server runtime in prod
## Layout
- Routes + sitemap: src/index.tsx pages[]
- Pages: src/pages/*.tsx
- Static CSS/JS/images: public/
## Commands
- Dev: pnpm dev
- Typecheck: pnpm check
- Build: pnpm run build
- Do not deploy unless explicitly asked
## Conventions
- 4-space indent
- Mirror existing EN how-to pages for new docs
- Unique Title/Description; one H1 with the target phrase
- Bidirectional Related reading links to sibling guides
## Non-goals / safety
- No wrangler/Cloudflare/DNS changes unless requested
- No secrets in prompts, commits, or screenshots
- Do not invent indexed URLs beyond the task list
## When stuck
- Ask; do not invent a second router, package manager, or deploy path
- Prefer reading a sibling page before inventing a new layout
- Shared cross-tool facts live in AGENTS.md—do not fork a second novelIf your team also keeps Antigravity-style.agents/rules (or similar host rule packs), point those files at the same stack / non-goals instead of rewriting paragraphs. Compare packaging choices in AGENTS.md vs rules.
05
How to write GEMINI.md well
- Lead with verification. Put the build/test commands near the top so agents see them early.
- Name files, not vibes. “Edit
src/index.tsxpages[]” beats “update routing somehow.” - Write non-goals as hard stops. Deploy, DNS, and secret files are classic accidental “helpful” edits.
- Link exemplars. Point at one good page or PR; agents copy structure better than abstract essays.
- Keep it skimable. Short bullets over paragraphs; humans must maintain this file.
- Prefer AGENTS.md for shared facts. When multiple hosts load the same repo, put cross-tool contracts in AGENTS.md and keep
GEMINI.mdthin for Gemini-only notes.
06
Keep it alive
- After a toolchain change (Node, package manager, CI), update commands the same day.
- When the agent invents a wrong path twice, add an explicit pointer—then delete fluff elsewhere to stay short.
- Review
GEMINI.mdin PRs that change conventions, not only in “docs” PRs. - Do not paste entire API references; link or point at the file that owns the schema.
- Re-verify discovery paths after Gemini CLI / host upgrades—loaders evolve.
Related reading: How to write AGENTS.md · How to write CLAUDE.md · AGENTS.md vs CLAUDE.md vs Cursor rules · Antigravity rules examples · copilot-instructions.md examples · Cursor rules examples · Good agent prompts · Agent engineering notes · Context engineering
07
FAQ
Is GEMINI.md the same as a system prompt?
Conceptually it is project-scoped durable instruction, not a one-shot chat message. Product loading rules differ by tool; this guide treatsGEMINI.md as a committed project memory file you maintain like README conventions.
Should every detail go into GEMINI.md?
No. Ticket goals, temporary experiments, and “only for this customer” notes belong in the session prompt. Put durable contracts inGEMINI.md (or shared AGENTS.md); put acceptance for this change in the prompt.
How does GEMINI.md relate to AGENTS.md and CLAUDE.md?
All three can encode durable guidance. Multi-tool repos often use AGENTS.md as the shared human source of truth and keep thin tool-specific stubs (GEMINI.md, CLAUDE.md). Prefer one clear statement of each convention. Side-by-side notes: AGENTS.md vs CLAUDE.md vs Cursor rules. For Antigravity-oriented rule files, see antigravity rules examples.
Is this a Gemini CLI install guide?
No. This page only covers how to write project memory. Install paths, auth, and product UI belong in official Gemini / Google docs—re-check those after upgrades.
What length is “enough”?
Enough that a new agent session can build, find the route registry, and avoid forbidden actions without guessing—usually one to two screens of dense bullets, not a novel. If nobody wants to update it, it is too long.