Project instructions and memory
Every session starts with an empty desk (Module 02). Project instructions are the notes your tool puts on that desk automatically, so the agent knows your commands, layout and rules without being told each time. Written well, they're the highest-leverage file in your repository.
1. The idea
There are three kinds of persistent context, and each has its place:
- Project instructions, committed to the repository and shared with the team: build and test commands, folder layout, conventions, and the traps you've hit. The open standard is AGENTS.md, now stewarded by the Agentic AI Foundation under the Linux Foundation and read by all five tools in this track. Some tools also have their own file (CLAUDE.md, GEMINI.md,
.github/copilot-instructions.md). - Scoped rules that load only when relevant: a file in a subfolder (
frontend/AGENTS.md), or a rule tied to file patterns ("apply to**/*.sql"). The nearest instructions win. - Memory: notes the agent writes for itself as it works ("this repo's tests need Docker running"). Useful, but review it, because it can be wrong or go stale.
The rule of thumb: if it's true for the team, it goes in the repository; if it's true only for you, it goes in your personal file or memory. Secrets go in neither.
2. How it works
Step through an agent working in a monorepo. Watch which instruction files are active, and which rule wins when two disagree.
3. Try it yourself: the AGENTS.md checker
Paste your AGENTS.md (or start from an example). The checker estimates what it costs every session and flags the most common problems.
4. Why it matters at work
What makes instructions actually get followed:
- Commands exactly as typed. Agents copy them literally:
BAZEL_TEST=1 pnpm test, not "run the tests". - Say why, briefly. "Never use
pnpm testalone: it silently runs 7 of 135 tests" is followed far better than a bare rule (Module 05). - Record traps you've actually hit. The most valuable lines are past mistakes. If you had to correct the agent twice, it belongs here.
- Keep it short. It's loaded into every session and costs tokens every time. A few hundred lines at most; move long procedures into skills (Module 11), which load only when needed.
- No history and no essays. "We migrated from X in 2023 because…" dilutes the rules that matter.
- Make it the team's file. Review changes to it like code; update it in the same pull request that changes the build or conventions.
A compact example:
# AGENTS.md
## Commands
- Build: `pnpm build`
- Test: `BAZEL_TEST=1 pnpm test` (plain `pnpm test` runs only 7 of 135 tests)
- Before every commit: `pnpm format && pnpm check`
## Layout
- `api/` Kotlin service · `web/` Angular app · `proto/` API contracts · `docs/` design notes
## Rules
- Never edit an applied migration; add a new `V{N}__name.sql` (others have already run them).
- Every colour comes from a `--bf-*` token; raw hex breaks dark mode.
## Never
- Commit to main, force-push, read `secrets/`, or paste customer data into prompts.
5. In your five tools
All five read AGENTS.md; each adds its own options. Checked October 2026.
| Tool | Project instructions | Scoped rules | Memory |
|---|---|---|---|
| Claude Code | CLAUDE.md; since v2.1.277 it reads AGENTS.md when there's no CLAUDE.md (or import it with @AGENTS.md) | Nested CLAUDE.md files; .claude/rules/ | Auto memory: notes Claude writes and reloads each session; /memory to view and edit |
| Antigravity CLI | AGENTS.md or GEMINI.md (always on for their folder); global ones in ~/.gemini/ | .agents/rules/*.md with modes always_on, glob, model_decision or manual | Use global rules for personal preferences |
| GitHub Copilot | .github/copilot-instructions.md, AGENTS.md (root and nested) | .github/instructions/*.instructions.md with an applyTo glob | Copilot Memory: repository-specific memories, validated against the code (public preview, on by default for Pro plans) |
| Cursor | AGENTS.md (root and nested) or project rules | .cursor/rules/*.mdc: Always, Apply Intelligently, Apply to Specific Files (globs), Manual | Memories were removed in Cursor 2.1; Cursor recommends turning them into rules |
| Codex CLI | AGENTS.md, merged from ~/.codex/, the repo root and each folder down to where you work | Nested AGENTS.md; AGENTS.override.md takes precedence in its folder | Global ~/.codex/AGENTS.md for personal defaults; combined files are capped at 32 KiB by default |
@AGENTS.md loads both.6. Remember it
How this hook works: what “Leave a note on the desk” means
What the slogan means, phrase by phrase
- “Leave a note”
- Write it down once, in a file, instead of repeating it in every chat. A rule said twice in chat is a rule that belongs in the note.
- “on the desk”
- The file is loaded into the context window at the start of every session (Module 02's desk). That's why it works, and why it must be short: it takes up space every time.
- Implied: a note, not a manual
- A contractor reads a sticky note; they skim a 40-page manual. Long procedures belong in skills that are fetched only when needed.
Why this picture fits: it links to the desk from Module 02, and it explains both halves of the advice: write things down (it's the only memory that reliably survives), and keep it brief (it competes for desk space).
The story → the concept
| In the story | In your tools |
|---|---|
| The note on the kitchen counter | AGENTS.md (or CLAUDE.md, GEMINI.md…) at the repository root |
| A note taped inside the garage | A nested frontend/AGENTS.md, or a rule scoped to **/*.sql |
| The contractor's own notebook | Memory: notes the agent writes itself |
| Your personal reminders | User-level files such as ~/.claude/CLAUDE.md or ~/.codex/AGENTS.md |
| The thick manual on the shelf | Skills and docs, read only when a task needs them |
Watch it on an example
- Monday: the agent runs
pnpm test, sees "7 passed" and says done. 128 tests never ran. - You add one line to AGENTS.md: "Test with
BAZEL_TEST=1 pnpm test; plainpnpm testruns only 7 of 135 tests." - Tuesday, a fresh session, a different tool: it reads the note first, runs the right command, and sees 135 tests.
- That one line now protects every session, for every teammate, in every tool that reads AGENTS.md.
The trap it saves you from
Two opposite ones: correcting the same mistake in chat every day, and writing a 2,000-line "everything about our system" file that buries the five rules that matter.
It still works when…
Your monorepo grows: each team leaves its own note in its folder (nested AGENTS.md), and the nearest note wins. And when knowledge outgrows a note, it becomes a skill (Module 11).
7. Common mistakes
rm -rf"), use a permission rule or a hook (Module 12).8. Hands-on lab (roadmap week 9)
- Draft it. Run your tool's starter (
/initin Claude Code or Codex) or write AGENTS.md by hand: commands, layout, rules with reasons, a "never" list. - Check it in the checker above. Cut it below 200 lines.
- Prove it loads. Start a fresh session in two tools and ask "what are the test commands for this repo?" without pointing at the file.
- Add a scoped rule for one folder or file type (a nested AGENTS.md, or a glob rule) and confirm it applies only there.
- Review memory in a tool that has it, and delete one stale or wrong note.
9. Self-check quiz
Where should "run tests with BAZEL_TEST=1" go so every teammate's agent knows it?
Both the root AGENTS.md and frontend/AGENTS.md set a lint command. The agent is editing frontend/app.ts. Which wins?
Why keep AGENTS.md short?
"The agent must never delete the database." What enforces that reliably?
10. Go deeper
| Resource | Time | Why |
|---|---|---|
| agents.md | 10 min | The open standard, its recommended sections and the tools that support it. |
| How Claude remembers your project (Claude Code) | 20 min | CLAUDE.md, AGENTS.md support, rules folders and auto memory in detail. |
| Custom instructions with AGENTS.md (Codex) | 10 min | How Codex merges global, repository and folder files. |
| Rules (Cursor) and Rules (Antigravity) | 15 min | Two takes on scoped rules: globs, model-decided and manual rules. |
| Custom instructions (VS Code Copilot) | 10 min | Repository instructions, applyTo files and AGENTS.md settings. |