Context file
- Context
- Industry term
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 you can correct any misunderstanding. Give it responsibility for updating the file when you approve a change, such as a new photo folder, since later tasks may rely on that file.
Easy to mix up
Memory is notes the AI app keeps about you, tied to your account. A context file stays with a project you control, where agents maintain it and people can inspect it.
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.
Sources
- Custom instructions with AGENTS.md, OpenAI
- How Claude remembers your project, Anthropic
- Cursor Rules, Cursor