Back to all articles
TutorialDecember 3, 2026·11 min read

Antigravity vs Codex - Where Each Keeps Your Rules, Memory, and Past Sessions (2026)

You use Antigravity for one repository and Codex for another, or you're trying both on the same codebase before settling on one. Each time you switch, the same questions come back. Where do I put the project rules so this agent follows them? Will it remember what I corrected yesterday? And if I close the terminal, how do I get back to the conversation?

Both tools answer these questions with files on your machine, but not the same files, and not in the same way. The short answer: Antigravity reads AGENTS.md or GEMINI.md files and .agents/rules/ from any directory it touches, and its documentation says plainly that "Agents don't remember conversations" unless a lesson is written down as a rule or skill. Codex reads AGENTS.md files from the project root down to your working directory, and it can also generate local memories from past chats, a feature that's off by default.

This guide covers where each tool keeps instructions, how each handles memory from past chats, how each resumes and forks sessions, where they differ, where they work the same way, and how to keep one set of project context steady if you use both.

Antigravity vs Codex at a glance

DimensionAntigravityCodex
Project instruction filesAGENTS.md or GEMINI.md in any directory, plus .agents/rules/*.mdAGENTS.override.md or AGENTS.md, one per directory from project root to working directory
Global instructions~/.gemini/AGENTS.md, ~/.gemini/GEMINI.md, or modular rules in ~/.gemini/config/rules/~/.codex/AGENTS.override.md or ~/.codex/AGENTS.md, first non-empty file
How layers combineCumulative; more specific directory rules take priorityConcatenated root-down; files closer to the working directory appear later and override
Size limits24,000 bytes per rule file; 20,000-token budget for global and always-on rules32 KiB combined by default, set by project_doc_max_bytes
Memory from past chats"Agents don't remember conversations"; /learn proposes a rule or skill for approvalLocal memories generated from eligible chats; off by default
Where learned context is storedRule and skill files you approveUnder ~/.codex, in memories/ or memories_v2/
Resuming in the CLIScoped to the working directory; agy -c or /resumecodex resume scoped to the current directory unless you pass --all
Reviewing and removingRename or delete conversations in the /resume picker; edit rule files/memories per chat; Delete Codex memories in the desktop app

Checked against each vendor's documentation on December 3, 2026.

How Antigravity keeps your context

Antigravity runs as an app, a CLI called agy, and an IDE. Its rules documentation applies to all three.

Instructions

Antigravity's rules page calls rules "persistent instructions, coding standards, and architectural constraints that shape how Antigravity behaves in your codebase." It looks for them in several places:

  • Directory files. An AGENTS.md or GEMINI.md file, or a .agents/rules/ folder, in any subdirectory. When the agent reads or edits a file, it walks up from that file's folder to the workspace root and loads rules at each level.
  • Global files. ~/.gemini/AGENTS.md or ~/.gemini/GEMINI.md apply to all projects on your machine, and modular global rules go in ~/.gemini/config/rules/.

Files in a rules/ folder need YAML frontmatter with a trigger value: always_on, model_decision, glob, or manual. The documentation warns that if a rule file omits frontmatter or uses an unrecognized trigger, "Antigravity silently discards the rule."

Memory from past chats

The /learn documentation starts with a clear statement: "Agents don't remember conversations." It continues that a lesson you teach the agent disappears when the conversation ends, "unless it's written down as a customization."

/learn is how you write it down. The agent reviews recent messages for corrections, decides whether the lesson is a rule or a skill, and drafts a learning_proposal.md file. The documentation says the agent "never edits configuration files immediately." It applies the change only after you approve it.

Past sessions

In the CLI, conversation history is scoped to your working directory. Run agy -c to resume the most recent conversation for that workspace, or /resume to open a picker. The picker lets you search, rename with F2, and delete with F4. A separate tab lists conversations started in the Antigravity App, which you can import into the CLI.

/fork copies the conversation into a new session. The documentation notes that it "clones the conversation thread, not your local Git checkout."

How Codex keeps your context

Codex runs in the ChatGPT desktop app, the Codex CLI, and an IDE extension. Its instruction and memory documentation covers all three.

Instructions

OpenAI's documentation says: "Codex reads AGENTS.md files before doing any work." It builds an instruction chain when it starts:

  • Global. In ~/.codex, Codex reads AGENTS.override.md if it exists, otherwise AGENTS.md, and uses only the first non-empty file.
  • Project. Starting at the project root, Codex walks down to your working directory and includes at most one file per directory: AGENTS.override.md, then AGENTS.md, then any fallback names you configure.

Files closer to your working directory appear later in the combined prompt, so they override earlier guidance. The documentation adds that "Codex stops searching once it reaches your current directory".

Memory from past chats

Codex can turn useful context from eligible past chats into local memory files. The documentation says it skips active or short-lived sessions, redacts secrets from generated memory fields, and updates memories in the background.

The feature starts off. The documentation says: "Local Codex memories are off by default." You turn it on in the ChatGPT desktop app under Settings > Personalization, or with a feature flag in config.toml. Memories are stored under ~/.codex, in memories_v2/ for a fresh profile or memories/ if that store already exists. For a longer walkthrough, see does Codex have memory.

Past sessions

codex resume reopens a saved chat. The documentation says it "scopes --last to the current working directory unless you pass --all." codex fork copies a previous session into a new chat, and /fork does the same inside a session.

Where they differ

Which instruction files each one reads

Antigravity reads AGENTS.md and GEMINI.md, plus .agents/rules/*.md files with frontmatter triggers. Codex reads AGENTS.override.md and AGENTS.md, plus any fallback filenames you list in its config. A shared AGENTS.md in the repository root is read by both. A file in .agents/rules/ is read by Antigravity. The Codex documentation doesn't list .agents/rules/ among the places Codex reads instructions from.

How far each one looks

Antigravity walks up from each file it reads or edits to the workspace root, so a rule in a deep subdirectory loads when the agent touches a file there. Codex walks down from the project root to the directory you start in, and stops there. In Codex, a rule file in a subdirectory below your working directory isn't part of the starting chain. The Codex documentation suggests placing overrides close to specialized work and starting Codex from that directory.

How conflicts resolve

Antigravity's rules are "cumulative rather than replacement-based", and when instructions conflict, more specific directory rules take priority. Codex concatenates files from the root down, and files closer to the working directory override earlier guidance because they appear later. Both favor the more specific location, through different mechanisms.

What happens to lessons from a chat

In Antigravity, a lesson persists only if it becomes a rule or skill file, and /learn drafts that file for your approval. In Codex, local memories, once enabled, are generated in the background from eligible chats, and you control them per chat with /memories. The Codex documentation also says to treat memories as "a helpful recall layer, not as the only source for rules that must always apply."

How each one limits size

Antigravity truncates any single rule file over 24,000 bytes and gives global and always-on rules a shared 20,000-token budget; over the budget, the largest files become pointers the agent reads on demand. Codex stops adding instruction files once the combined size reaches project_doc_max_bytes, 32 KiB by default.

Where they work the same way

Both read AGENTS.md. A root AGENTS.md is a shared starting point for either tool.

Both have a global layer. Each reads a personal file from its own home directory before project files.

Both scope CLI history to the working directory. Antigravity scopes conversation history to your working directory, and codex resume --last picks from the current directory by default.

Both can fork a conversation. Neither fork copies your files. Antigravity says so directly, and Codex offers a managed Git worktree option for isolation.

Both package workflows as skills. Antigravity stores workspace skills in .agents/skills/. In Codex, a skill packages instructions and supporting resources for a specific task.

Which one fits which job

If your repository already uses directory-level rule files with triggers, Antigravity reads them as written, including glob and model_decision rules.

If you want context from past chats to carry forward automatically, Codex's local memories do that once enabled, with per-chat control.

If you want every persistent lesson reviewed before it's saved, Antigravity's /learn drafts a proposal and writes only after approval.

If you work from many subdirectories of one repository, note that Antigravity loads rules as it touches files, while Codex builds its chain from where you start.

If you need team rules that always apply, both point to checked-in instruction files rather than memory.

Using both

If you use both tools on the same repository, your context ends up in several places:

  • A root AGENTS.md that both read.
  • Antigravity-only files: GEMINI.md, .agents/rules/, .agents/skills/, and your ~/.gemini global files.
  • Codex-only files and state: AGENTS.override.md, ~/.codex/AGENTS.md, and local memories in ~/.codex.
  • Conversation history in each tool, scoped to the working directory.

Nothing syncs between them. A lesson Antigravity saves through /learn goes into an Antigravity rule file, and a Codex memory stays in ~/.codex. To keep them aligned, put shared rules in the root AGENTS.md, and copy anything else by hand.

What people try first

Putting everything in .agents/rules/ and expecting Codex to read it. Codex reads AGENTS.md-style files per directory.

Starting Codex at the repository root and expecting subdirectory overrides. Codex stops at the directory you start in.

Using camelCase triggers in Antigravity. Values like alwaysOn are discarded without warning.

Expecting Codex memories to work out of the box. They're off by default.

Expecting Antigravity to remember yesterday's correction. Run /learn and approve the proposal.

The Fix: Keep one source of truth for project context

Step 1: Put shared rules in the root AGENTS.md

Write rules both tools must follow in the repository root AGENTS.md, without frontmatter.

Step 2: Keep tool-specific files small

Use .agents/rules/ for Antigravity triggers and AGENTS.override.md for Codex overrides, and keep each one focused.

Step 3: Review what each tool learned

Approve or edit /learn proposals in Antigravity, and check /memories settings in Codex before relying on them.

Step 4: Write the cross-tool context in your own words

Decisions, constraints, and reasons that aren't rules belong in a short note you maintain and can paste into either tool.

Setting this up in MemoryLake

Instruction files cover rules. The rest of your project context, such as why an approach was chosen, what's blocked, and what a reviewer asked for, ends up in chat when it isn't written down, and chat history stays with each tool.

MemoryLake is a memory layer for that context, kept in one place you maintain. It connects to ChatGPT, Claude Code, and Codex. For Antigravity, paste the same written context into a conversation yourself, or turn the parts that are rules into AGENTS.md entries.

You write the entries yourself. Nothing is read out of, written to, or deleted from Antigravity's rule files, skills, or conversations, or from Codex's AGENTS.md files, local memories, or sessions. Each tool works the way its vendor describes.

Step 1: Create an API key

Sign in and generate a key from the dashboard. Keep it somewhere private.

The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent
The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent

Step 2: Upload your first memories

Start with the note from Step 4 of the fix: decisions, constraints, and the reasons behind them.

The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory
The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory

Step 3: Connect your AI & agents

Connect Codex, Claude Code, and ChatGPT, so the same context is available in each one.

The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer
The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer

What this changes in practice

The first difference is fewer repeated explanations. The reasons behind your rules are written down once.

The second is easier switching. Moving a task from one tool to the other means pasting or connecting the same note, not reconstructing it from chat.

The third is cleaner instruction files. When background context lives elsewhere, AGENTS.md can stay short and rule-focused.

Best practices for using Antigravity and Codex together

Start with a root AGENTS.md. Both tools read it.

Use valid trigger values in Antigravity. Check spelling against the documented list.

Start Codex in the directory you're working in. That's where its instruction chain ends.

Decide whether you want Codex memories. Turn them on deliberately and review them.

Run /learn after a correction in Antigravity. Otherwise the lesson ends with the conversation.

Keep rule files under the size limits. Antigravity truncates large files, and Codex stops adding files at its cap.

Resume from the directory you started in. Both tools scope history to the working directory, so that's where your earlier sessions show up.

Conclusion

Antigravity keeps your context in rule and skill files. It reads AGENTS.md, GEMINI.md, and .agents/rules/ from any directory it touches, combines them cumulatively, and turns lessons into files only through /learn with your approval. Its CLI scopes conversations to your working directory, with resume, rename, delete, and fork.

Codex keeps your context in AGENTS.md files read from the project root to your working directory, and, if you turn them on, in local memories generated from past chats under ~/.codex. Its CLI scopes codex resume --last to the current directory unless you pass --all, with fork available too. A shared root AGENTS.md, plus a written note for everything that isn't a rule, keeps both tools working from the same context.

Frequently asked questions

Does Antigravity share memory with Codex?

No. Each tool keeps its own files and history. Both can read the same root AGENTS.md, but lessons and memories don't sync between them.

Is Antigravity or Codex better for keeping project rules?

It depends on how you organize them. Antigravity reads directory rules with triggers as it touches files. Codex reads one instruction file per directory from the project root to where you start.

Does Codex read GEMINI.md?

Not by default. Codex reads AGENTS.override.md, AGENTS.md, and any fallback filenames you add in its config.

Does Antigravity read AGENTS.md?

Yes. It reads AGENTS.md or GEMINI.md in any directory, without frontmatter, as always-active rules.

Does Antigravity remember past conversations?

Its documentation says agents don't remember conversations. Use /learn to turn a lesson into a rule or skill.

Are Codex memories on by default?

No. Local Codex memories are off by default. Turn them on in Settings > Personalization or with a feature flag.

How do I resume a session in each CLI?

In Antigravity, run agy -c or /resume. In Codex, run codex resume, adding --all to search beyond the current directory.