Write the Project's Instruction File

Your escape room project has a committed brief and plan. Each time you’ve started a session so far, your first message has had to say “Read docs/brief.md,” because a new session starts with none of your project’s decisions in its context. The fix is an instruction file, a Markdown file the agent program loads at the start of every session. You may have tried one already on a single decision.

In this lesson, you’ll write the project’s instruction file by hand. You’ll decide which few lines earn a place in every session, point the agent to the brief and plan instead of copying them, and learn where a correction belongs as the project changes. Start with what a fresh session actually has to work from.

What a Fresh Session Starts With

To decide what goes in the file, you need to know which parts of your project reach a new session on their own. A new session’s context starts with the agent program’s own instructions, any instruction files it finds, and your first message. Everything else in the folder stays on disk until the agent reads it.

Permission settings work differently. The agent program and its sandbox enforce them around every action, outside the model, even when the context describes them. Here’s how those parts fit together for your project:

The instruction file loads at start and points to the brief and plan on disk. Permission settings allow or block each action.
What Loads, What Waits on Disk, and What Gets Enforced

The instruction file is the only project file that loads by itself, so it holds pointers to docs/brief.md and docs/plan.md rather than their contents.

The agent usually reads those documents when a task needs them, because the file sends it there, and it reads the code the same way. A pointer is guidance, though, not a guarantee, so when a task depends on the brief or plan, name the document in the task too, and check afterward that the work matches it.

Two other things can load next to the project’s file. A personal instruction file in your home folder loads in every project you open, and some agents also load memory notes saved in earlier sessions. Know what your personal instruction file and memory notes hold. A resumed session is another case: it keeps the copy of the instruction file it loaded when it first started, so after you edit the file, start a new session.

Each agent looks for its own filenames, in its own places. Open the version for your agent, checked in December 2026 against Claude Code 2.1’s documentation and Codex CLI 0.172:

Claude Code loads CLAUDE.md from the folder you start it in, or .claude/CLAUDE.md there, plus any CLAUDE.md in the folders above it. Your personal ~/.claude/CLAUDE.md loads in every project. A CLAUDE.local.md next to the project’s file holds your own notes for this project, and you keep it out of Git. A CLAUDE.md in a subfolder loads once Claude Code works on a file there.

Recent versions of Claude Code read an AGENTS.md only when there’s no CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in the folder you start in or any folder above it, so any of those three files in a parent folder can hide your AGENTS.md. Your personal ~/.claude/CLAUDE.md doesn’t count here.

Auto memory is on by default, so memory notes from ~/.claude/projects/ may load too. To see what a session loaded, type /context all and read the list under Memory files.

Codex loads your personal ~/.codex/AGENTS.md first, then one AGENTS.md per folder from the repository’s root down to the folder you started it in. Nearer files come later, so their instructions win when two disagree. Codex reads at most one file per folder, preferring an AGENTS.override.md, so if your AGENTS.md doesn’t load, look for an AGENTS.override.md. By default, it stops adding files at 32 KiB in total.

Codex ignores a CLAUDE.md unless you add that name to project_doc_fallback_filenames in ~/.codex/config.toml.

Memories are off by default. If you turned them on, notes from earlier sessions may load too. To see what a session loaded, type /status and read the Agents.md row. In Codex CLI 0.167.1, it lists each instruction file loaded, such as ~/.codex/AGENTS.md, AGENTS.md, or <none>. If you ask the model instead, its answer is generated text, a hint rather than proof.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.