Context file

  • Context
  • Industry term
4 steps

A context file is a file kept in a project that gives an AI coding agent lasting instructions and facts, such as how to run the project and which conventions to follow, for every task.

When a session starts, Codex adds the text of AGENTS.md ahead of your request, and Claude Code does the same with CLAUDE.md. The agent weighs those lines as instructions, alongside everything else it reads.

Where you’ll meet it

You're building a website for your photography with a coding agent. At the start of every session you explain again that the photos live in one folder, that the site uses two fonts, and that the contact form stays as it is.

What to do

Ask the agent to write those standing facts into the project's context file and show you the lines it added, so any mistake gets fixed now. When a fact changes later, such as a new photo folder, update the file too, since the agent takes what it says as current.

Easy to mix up

Who keeps it, and where?
Context fileMemory
You, in a file stored with the projectThe app, in notes tied to your account

Check yourself

Your project's context file says “Never share the customer list.” Which setup protects the list from an agent more reliably?

Go deeperA long context file crowds out the lines that count

Each line uses part of the context window, the limited text the agent can hold at once, even on tasks that never needed it. In a long file, each instruction is easier to miss. Instructions for one kind of task can go in a skill instead, a separate file the agent opens when a task calls for it.

Guidance for one part of a project can also load only there. OpenAI's Codex documentation describes reading AGENTS.md files from a global one down through each folder to the one you're working in, with the closer file winning where two disagree. Rules in Cursor's .cursor/rules or Claude Code's .claude/rules folder can be set to load only for chosen files, and Cursor's documentation marks its older single .cursorrules file as legacy.

Anyone who can open the project can read the file, so passwords and keys belong in environment variables, settings kept outside the code.

Practice Modern AI

Or take the learning quiz on a mix of every set