Teaching your coding AI to remember, and why a shorter note works better

Teaching your coding AI to remember: two kinds of memory, a short note you write (build and test commands, always and never rules, fixes you have said twice) and notes the AI saves about you.

.

During our first weeks and months using Claude code and codex we found that sometimes the same thing we told it in one chat wouldn’t carry over to others. That’s not to say we always want our tools to remember everything session/chat but what if we wanted it to always remember certain things. One thing was a certain we were working on an application that needed to stay Python 2 and it kept wanting to do it Python 3. So we put a memory on the application (project) to only write in Python 2.

Next thing was what could we do at a global level. Most time I use Claude to help figure out how to do things in Claude code, but just because you ask it to do something doesn’t mean you shouldn’t know how it is done. I added a global memory to always to write using a specific coding framework when we are building new applications.

We’ll go through the two kinds of memory, how the four tools most people use handle them (Claude Code, OpenAI’s Codex, Google’s Gemini CLI and GitHub Copilot), what a recent study found about what actually helps, and then a short file you can copy and use tonight.

Two kinds of memory

There are two ways you can make a memory, ones is a small note like “sticky note” another one is “notebook”. Instruction files are markdowns stored in project your working on, when others work on project their AI picks up what you left. Notebooks are really memories or instructions tied to your machine no one else sees them.

Here’s a breakdown

Instruction file (the sticky note)Auto memory (the notebook)
Who writes itYouThe AI
Where it livesUsually a plain text file in your projectA hidden folder on your computer, or on GitHub
Shared with your team?Usually, if you commit it to the projectUsually private to you
ExamplesCLAUDE.md, AGENTS.md, GEMINI.md, copilot-instructions.mdClaude Code auto memory, Codex Memories, Copilot Memor

The sticky note you write

ToolFile it readsPersonal file for all projectsSize advice
Claude Code (Anthropic)CLAUDE.md, or AGENTS.md if there’s no CLAUDE.md~/.claude/CLAUDE.md“Target under 200 lines”
Codex (OpenAI)AGENTS.md~/.codex/AGENTS.mdStops reading after 32 KiB
Gemini CLI and Antigravity CLI (Google)GEMINI.md, and AGENTS.md in Antigravity~/.gemini/GEMINI.mdNone given
GitHub Copilot.github/copilot-instructions.md, AGENTS.md, or one CLAUDE.md or GEMINI.md at the rootPersonal instructions in your settingsGitHub’s own template says “no longer than 2 pages”

The notebook the AI writes

This is the newer, more automatic kind. As you work, the assistant notices things worth keeping, like “this person wants tests run before every commit”, and saves them for next time. You can also directly ask it to remember globally.

ToolOn by default?Where it’s keptHow to look at it
Claude CodeYes, in local sessionsA memory folder on your computer, one small file per memory/memory in a session
CodexNo, you turn it on~/.codex/memories/ on your computer/memories in a chat, or Settings > Personalization
Gemini CLISaves when it decides a fact is worth keepingStraight into your GEMINI.md files/memory show
Antigravity CLIUnconfirmedNot documented yetNot documented yet
GitHub CopilotYes for individual Pro and Pro+ (public preview)On GitHub, per repository, plus your personal preferencesRepository Settings > Copilot > Memory

The interesting part is that each company made quite different choices.

Claude Code keeps one short index file, a bit like an index card on top of a stack, and only the first 200 lines of it load at the start of each session. The details sit in separate files it opens when it needs them. It all lives on your machine, though, so it won’t follow you to another laptop.

Codex is the cautious one. Memory is off until you switch it on, and then Codex summarizes finished chats once they go idle. OpenAI’s Memories page is refreshingly direct about it. “Don’t store secrets in memories.”

Gemini CLI doesn’t really have a separate notebook at all. Google’s memory tool writes straight into your GEMINI.md files, with team rules going into the project file and personal preferences into your home folder. It’s simple, but it does mean the AI is editing your notes, so look them over now and then.

Copilot has the cleverest answer to the obvious worry, which is what happens when a memory goes out of date. Every fact it saves about a repository carries citations pointing to the code that backs it up, and before it uses a memory, Copilot checks the code still says that. Memories nobody uses for 28 days get deleted.

Does a longer memory make a smarter assistant?

Not really, and this time there’s evidence.

In February 2026, researchers at ETH Zurich and LogicStar.ai published Evaluating AGENTS.md, which was updated in September and presented at the ICLR 2026 conference. They gave coding agents, including Claude Code and Codex, real tasks with and without an instruction file. According to the paper’s summary, the files “do not generally improve task success rates,” and they raised the cost “by over 20% on average” because the agents spent more time exploring and checking.

Anthropic says much the same thing in its own docs: “Longer files consume more context and reduce adherence.” Every line in your file gets read before every single task. A short note gets followed. A long one gets skimmed, and you pay for the skimming.

What to put in, and what to leave out

The best things to write down are the ones the AI can’t work out by looking. Start with the commands for running, testing and building your project, because that’s what AI gets wrong most often. Add your “always” and “never” rules, like “always run the tests before saying you’re done” or “ask before deleting files.” And if you’ve corrected the AI on the same thing in two different sessions, that correction belongs in the file. When you’ve got longer guidance somewhere else, point to it (“design rules are in docs/design.md“) instead of pasting it in.

Two habits help as well. Every so often, open your tool’s memory view and delete anything stale or wrong. And be careful with other people’s files. An AGENTS.md inside a project you download is a set of instructions you didn’t write, so read it before you let an AI follow it.

A small file you can copy

Say you have a small personal website. This is a complete AGENTS.md for it, saved in the project’s main folder.

# Notes for AI assistants

- This is a small personal website: plain HTML, CSS and JavaScript. No frameworks.
- Preview it with: npx serve .
- Pages must work on phones. Check a narrow screen before saying you're done.
- Ask before deleting or renaming anything in the photos folder.
- Keep the wording on pages plain and friendly. No jargon.
- When you finish, list the files you changed and say why in one line each.

That’s the whole thing. Seven lines, and every one is something the AI couldn’t have guessed.

Codex and Copilot will read it as it is. To make Claude Code read it too, even after you add some Claude-only notes later, put a CLAUDE.md next to it with just one line.

@AGENTS.md

That @ line tells Claude Code to pull in the other file, so you keep one set of rules for every tool. Antigravity CLI reads AGENTS.md without any help. In Gemini CLI, add AGENTS.md to the context.fileName list in its settings.json.

Then try the notebook side. In a session, correct the AI on something small, like “I prefer single quotes in JavaScript.” If you’re in Claude Code, open /memory afterwards and see whether it saved a note. Now you’ve watched both kinds of memory at work.

After After Dark To Try

  1. Read what your AI already knows about you. Open /memory in Claude Code, /memories in Codex, or Repository Settings > Copilot > Memory on GitHub, and delete anything that’s wrong.
  2. Write a five-line AGENTS.md for one project, using only the things the AI keeps getting wrong. Use it for a week and see whether the repeat mistakes stop.
  3. If you already have a long CLAUDE.md or AGENTS.md, cut it in half. Take out the project overview and anything the AI could figure out by looking, then compare a session before and after.

Sources

Official (primary sources)

Independent tests

News and explainers

Leave a Reply

Your email address will not be published. Required fields are marked *